Closed rakslice closed 3 years ago
This is not the only cross compilation problem that BII/SS have; it also relies (especially for Unix
) on configure-time tests of system behaviour to choose what features to enable at run-time, which of course doesn't work if the target system isn't the local one.
Also in the case of dyngen.c
some care should be taken to avoid a similar problem in headers that it includes (e.g. elf-defs.h
)
The
CONFIG_$os
andHOST_$arch
style macros used indyngen.c
for#ifdefs
come with remarks like this one forCONFIG_WIN32
:However in the existing code, they are not being set up correctly for this use; they are being set based on common platform/arch pre-compiler macros present in whatever compiler they are being compiled with, e.g.:
This is incorrect for the situation.
To be clear, for a particular source file that is actually being cross compiled when cross compiling SS for another arch, this would be correct; the file would compiled with a cross toolchain that is building for the target platform & arch and has built in defines to match as well as a set of target system headers, so using the common platform/arch pre-compiler macros is correct, and no special alternate
CONFIG_
* macros or whatever are needed in the code itself to handle that case. The comment will be confusing to people for this reason.However when SheepShaver is being cross-compiled,
dyngen.c
itself is not being cross-compiled, it is being built to operate on code for the target platform that SheepShaver is being built for, but it runs on the host machine at build time, so is actually being compiled for the host machine where the rest of the compilation is taking place. So, being built with a native host compiler, not a cross compiler, but needing to work with objects and code for the target platform, it needs to not try to use common platform/arch pre-compiler macros from the compiler, which will be about the host platform, as a source of information about the target platform.At the very least, just having this separate layer of macros would allow someone to manually override them on the compiler command line, and so would allow for cross compilation to be done with just a custom makefile and no further code changes.
However, ideally introspection would be done on the cross-compiler to find its macros, say at configure time, and settings of the
HOST_*
/CONFIG_*
macros would be set appropriately based on that in a separate header, so that whendyngen.c
is compiled (withHOST_CC
) it has access to those.I don't know to what degree
autoconf
already facilitates some or all of this.