Cross-compilation

There is one impediment to cross-compiling ast software: some iffe(1) tests compile and execute programs. Fortunately iffe controls generated test program execution; it just needs a hint that the compiler under test is a cross-compiler.

Many ast tools come into play for cross-compilation. The nmake(1) probe(1) information contains:

CC.EXECTYPE
the execution host type as determined by package(1)
CC.HOSTTYPE
the target host type as determined by package(1)
nmake detects cross-compilation by $(CC.EXECTYPE) != $(CC.HOSTTYPE) and appends -x $(CC.HOSTTYPE) to IFFEFLAGS. When the -x HOSTTYPE option is set, iffe(1) executes all compiler generated test programs via crossexec(1). The crossexec(1) arguments are the HOSTTYPE and the command path and arguments to be executed. crossexec locates a host matching HOSTTYPE, copies the executable program file and file arguments to the host, and then executes the program on the host. crossexec(1) reads a per-user table $HOME/.crossexec that contains remote copy and execution information for each cross-compilation CC.HOSTYPE. This file contains one host description per line, and each line contains six tab separated fields:
HOSTTYPE
the host type as determined by package(1)
HOSTNAME
the host name suitable for the SHELL and COPY fields
USER
the user login name for HOSTNAME, - if the same as the execution host user
DIR
the HOSTNAME directory where the program files and data will be copied
SHELL
the remote execution command, rsh or ssh
COPY
the remote copy command, rcp or scp

For example, here is a $HOME/.crossexec that was used to cross-compile the ast-open package for a linux.arm target:

# HOSTTYPE	HOSTNAME	USER	DIR	SHELL	COPY
linux.arm	hostname	gsf	tmp	ssh	scp

To summarize:

  1. define CROSSTYPE=HOSTTYPE for the cross-compilation architecture
  2. add a $CROSSTYPE entry to $HOME/.crossexec
  3. package make HOSTTYPE=$CROSSTYPE CC=cross-compiling-cc


July 28, 2011