core: add BR2_HOSTARCH_NEEDS_IA32_COMPILER option
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Mon, 11 Nov 2013 16:47:25 +0000 (17:47 +0100)
committerPeter Korsgaard <peter@korsgaard.com>
Sun, 1 Dec 2013 22:30:58 +0000 (23:30 +0100)
Some bootloaders (such as Grub) need to be built for x86 (i.e IA32)
even if the target architecture is x86-64. However, when the target
architecture is x86-64, the cross-compiler generated by Buildroot is
not able to generate 32 bits code.

To solve this, we will rely on the host compiler being a x86 + x86-64
compiler. Therefore, this commit introduces the
BR2_HOSTARCH_NEEDS_IA32_COMPILER option, which tells the dependency
checking logic to verify that the host compiler is indeed capable of
building x86 32 bits code.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Config.in
support/dependencies/dependencies.sh

index d87e0f0c54e8dc795245e1379b051c373c9b7a40..677fff6204af397a104587beb419fd3bb65a0454 100644 (file)
--- a/Config.in
+++ b/Config.in
@@ -20,6 +20,12 @@ config BR2_HOSTARCH
 config BR2_HOSTARCH_NEEDS_IA32_LIBS
        bool
 
+# Hidden boolean selected by packages that need to build 32 bits
+# binaries with the host compiler, even on 64 bits build machines (e.g
+# bootloaders).
+config BR2_HOSTARCH_NEEDS_IA32_COMPILER
+       bool
+
 source "arch/Config.in"
 
 menu "Build options"
index b563f6096adf815dea6cfee1b0f1848535de8531..32b8feac5352fa7a5721613882cf03bbbb59cf54 100755 (executable)
@@ -186,6 +186,15 @@ if grep -q ^BR2_HOSTARCH_NEEDS_IA32_LIBS=y $BUILDROOT_CONFIG ; then
     fi
 fi
 
+if grep -q ^BR2_HOSTARCH_NEEDS_IA32_COMPILER=y $BUILDROOT_CONFIG ; then
+    if ! echo "int main(void) {}" | gcc -m32 -x c - ; then
+       /bin/echo -e "\nYour Buildroot configuration needs a compiler capable of building 32 bits binaries."
+       /bin/echo -e "If you're running a Debian/Ubuntu distribution, install the gcc-multilib package."
+       /bin/echo -e "For other distributions, refer to their documentation."
+       exit 1
+    fi
+fi
+
 # Check that the Perl installation is complete enough to build
 # host-autoconf.
 if ! perl  -e "require Data::Dumper" > /dev/null 2>&1 ; then