Next: , Previous: , Up: Tips and Tricks   [Contents][Index]

7.4 Cross-compilation

Some experimental architectures lack native compilers and therefore require programs to be compiled on an architecturally distinct front-end machine. coNCePTuaL can be configured to support such an arrangement. As an example, we follow how coNCePTuaL was recently configured to run on a Cray/SNL Red Storm prototype. The Red Storm prototype requires programs to be cross-compiled from a compile server then launched from an execution server to run on the compute nodes. The CPUs in all three node types use the x86-64 architecture but the compile server and execution server run Linux while the compute nodes run the lightweight Catamount kernel. Cross-compilation is necessary to prevent the ./configure script that runs on the compile server from attempting to execute small programs to test run-time features—these would be guaranteed to fail.

./configure (see configure) enters cross-compilation mode if the build system—specified with --build—has a different CPU, comes from a different vendor, or runs a different operating system from the execution system—specified with --host. The config.guess script outputs the build-system type in the form CPU-vendor-operating system:

% ./config.guess

(That is, the CPU architecture is ‘x86_64’; the computer vendor is ‘unknown’; and, the operating system is ‘linux-gnu’.)

As a special case of cross-compilation, if the build system and execution system utilize the same CPU and operating system18 (but presumably differ in terms of other feature), ./configure provides a --with-cross-compilation option to force a cross-compile. The alternative is to modify one of the build-system name components; best is to modify the vendor component as that’s used solely for informational purposes. For our Red Storm configuration (which predated the --with-cross-compilation option) we renamed vendor from ‘unknown’ to ‘cray’.

Because configure assumes it cannot execute small test programs on the execution system, it is unable to determine valid memory-buffer alignments. Consequently, the --with-alignment option must also be passed to configure to specify explicitly the minimum number of bytes at which data must be aligned. (If not specified, the minimum alignment defaults to ‘8’.) We know a priori that the x86-64 architecture can support byte-aligned data. Hence, we specify --with-alignment=1.

A command line like the following was used to configure coNCePTuaL for the Red Storm prototype:

% ./configure --build=x86_64-unknown-linux-gnu --host=x86_64-cray-linux-gnu
    --with-alignment=1 CC=mpicc

Once coNCePTuaL is configured to cross-compile, there is nothing special about performing the compilation itself. The make command runs unmodified from its description in make.

Running make check can be tricky because it involves both compilation and execution. As stated previously, these cannot be performed on the same servers in the Red Storm prototype. The solution is first to run make check on the compile server. This compiles all of the coNCePTuaL regression tests—and unsuccessfully attempts to run them. Then, when make check is run on the execution server it does not need to compile any of the tests (which it can’t do successfully, anyway) but can simply run each of them.

One catch is that the Red Storm execution server cannot directly run compute-node programs. Rather, it needs to spawn a job launcher ( yod ) for each test program. The mechanism for doing this is the TESTS_ENVIRONMENT variable, which make check prepends to every command it executes. We were therefore able to regression-test the coNCePTuaL run-time library on the Red Storm prototype with the following command:

% make TESTS_ENVIRONMENT="yod -list 4" check

If the system for which you’re cross-compiling is unable to run Python or unable to build the interpreter-based backends, you might consider building coNCePTuaL twice—cross-compiled for the target system and compiled regularly for the front-end system. The --prefix option to configure (see configure) specifies the top-level directory for the coNCePTuaL installation.



As long as the host and build operating systems have moderately similar interfaces (e.g., both are Unix-like) and the same CPU architecture (e.g., both are x86-64 variants), --with-cross-compilation should be applicable.

Next: , Previous: , Up: Tips and Tricks   [Contents][Index]

Scott Pakin,