Skip to content

build: Check that the compiler and --host are consistent

Simon McVittie requested to merge smcv/libcapsule:abi-sanity-check into master

libcapsule's use with biarch containers like the Steam Runtime will frequently make it necessary to compile it for both x86_64 and i386.

On recent Debian-derived OSs this is OK, because the toolchain is provided as a complete set of cross-compiler-style prefixed tools like i686-linux-gnu-gcc; but some OSs, like Arch Linux and very old versions of Debian, rely on 'gcc -m32' for their biarch support. This makes it very easy to do

./configure --build=x86_64-linux-gnu --host=i686-linux-gnu

and accidentally produce x86_64 binaries, because there is no i686-linux-gnu-gcc. Give the user a hint towards the correct invocation in this case, which is:

./configure --build=x86_64-linux-gnu --host=i686-linux-gnu CC='gcc -m32'

I've implemented this as a reusable macro, in case we want to add it to other projects that are likely to be cross-compiled by inexperienced cross-compiler users.

Signed-off-by: Simon McVittie smcv@collabora.com


I think this would have prevented some weird behaviour that @denittis experienced yesterday, which we tracked down to his i386-linux-gnu-capsule-capture-libs mistakenly being an x86_64 binary.

Merge request reports