diff mbox

[RFC] Detect lack of 32-bit devel environment on x86_64-linux targets

Message ID 08855916-EED2-4485-AE68-4BD91FE4393A@gmail.com
State New
Headers show

Commit Message

FX Coudert Aug. 24, 2013, 2:24 p.m. UTC
ping


> Given that I did not receive any feedback on my earlier email on this topic, I would like to send this patch for RFC. I'm not expert at this configury-stuff, so please try to comment on both the test proposed and my actual implementation :)
> 
> The idea is to find a patch which both catches probable issues early on for most x86_64-linux users, yet does not make build more complex for our power users. So, I propose to include a specific check in toplevel configure:
> 
> The cumulative conditions I suggest, in order to make it as unobtrusive as possible for current users, are:
> 
> 1. if we build a native compiler,
> 2. on x86_64-linux (and possible other x86_64 targets whose maintainers want to opt in),
> 3. and neither --enable-multilib nor --disable-multilib were passed
> 
> then:
> 
> a. we check that the native compiler can handle 32-bit, by compiling a test executable with the "-m32" option
> b. if we fail, we error out of the configure process, indicating that this can be overriden with --{enable,disable}-multilib
> 
> I suspect this might catch (at configure time) the large majority of users who currently get stuck at stage 2 with the "gnu/stubs-32.h" error, while being invisible to a large majority of the power users.
> 
> So, what do you think?
> 
> FX
>
diff mbox

Patch

Index: configure.ac
===================================================================
--- configure.ac	(revision 201292)
+++ configure.ac	(working copy)
@@ -2861,6 +2861,26 @@  case "${target}" in
     ;;
 esac
 
+# Special user-friendly check for native x86_64-linux build, if
+# multilib is not explicitly enabled.
+case "$target:$have_compiler:$host:$target:$enable_multilib" in
+  x86_64-*linux*:yes:$build:$build:)
+    # Make sure we have a developement environment that handles 32-bit
+    dev64=no
+    echo "int main () { return 0; }" > conftest.c
+    ${CC} -m32 -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c
+    if test $? = 0 ; then
+      if test -s conftest || test -s conftest.exe ; then
+	dev64=yes
+      fi
+    fi 
+    rm -f conftest*
+    if test x${dev64} != xyes ; then
+      AC_MSG_ERROR([I suspect your system does not have 32-bit developement libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.])
+    fi
+    ;;
+esac
+
 # Default to --enable-multilib.
 if test x${enable_multilib} = x ; then
   target_configargs="--enable-multilib ${target_configargs}"