diff mbox

[libbacktrace/libsanitizer] fix multilib builds

Message ID 54C18B4F.4020308@ubuntu.com
State New
Headers show

Commit Message

Matthias Klose Jan. 22, 2015, 11:44 p.m. UTC
In the past I had some issues on various linux platforms to build some multilib
configurations, all not building libbacktrace and libsanitizer, seen on powerpc,
ix86 and x86_64.  All fail like

Running configure in multilib subdir x32
pwd: /«PKGBUILDDIR»/build/i586-linux-gnu
configure: creating cache ./config.cache
checking build system type... i586-pc-linux-gnu
checking host system type... i586-pc-linux-gnu
checking target system type... i586-pc-linux-gnu
checking for i586-linux-gnu-gcc... /«PKGBUILDDIR»/build/./gcc/xgcc
-B/«PKGBUILDDIR»/build/./gcc/ -B/usr/i586-linux-gnu/bin/
-B/usr/i586-linux-gnu/lib/ -isystem /usr/i586-linux-gnu/include -isystem
/usr/i586-linux-gnu/sys-include -isystem /«PKGBUILDDIR»/build/sys-include  -mx32
checking for C compiler default output file name... a.out
checking whether the C compiler works... configure: error: in
`/«PKGBUILDDIR»/build/i586-linux-gnu/x32/libbacktrace':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.

The issue here is that the kernel used for the build is not configured for x32,
and I'm trying to build x32 multilibs.  The same thing happens when trying to
build 64bit multilibs on powerpc, s390 or ix86 kernels, not being able to
execute 64bit binaries.  The autoconf generated configury assumes that it should
be able to execute any multilib built binary, however config/multi.m4 knows
better about this ...

# Even if the default multilib is not a cross compilation,
# it may be that some of the other multilibs are.
if test $cross_compiling = no && test $multilib = yes \
   && test "x${with_multisubdir}" != x ; then
   cross_compiling=maybe
fi

However for the libbacktrace and the libsanitizer builds, the AM_ENABLE_MULTILIB
macro is included way too late.  Scan the generated configure file for
"cross_compiling" and see that the above snippet is added after the failing
checks. The fix seems to be simple, just move the AM_ENABLE_MULTILIB macro up so
that the "cross_compiling" value is corrected before it is tested.  This is what
the patch is doing.

However ... for every runtime library there is still something wrong, at least
one linker check in the generated configure is done before the expansion of the
AM_ENABLE_MULTILIB macro. I'm not trying to fix that with this patch ...
autoconf offers a AC_REQUIRE macro, so AM_ENABLE_MULTILIB should add one to
ensure that this macros is always expanded before the first check for
"cross_compiling", but I'm not sure which one.

Small patch, but took me some time to find out  :-/

This patch should go to trunk and all active branches. Ok to check in?

  Matthias

Comments

Ian Lance Taylor Jan. 23, 2015, 1:53 a.m. UTC | #1
On Thu, Jan 22, 2015 at 3:44 PM, Matthias Klose <doko@ubuntu.com> wrote:
>
> However for the libbacktrace and the libsanitizer builds, the AM_ENABLE_MULTILIB
> macro is included way too late.  Scan the generated configure file for
> "cross_compiling" and see that the above snippet is added after the failing
> checks. The fix seems to be simple, just move the AM_ENABLE_MULTILIB macro up so
> that the "cross_compiling" value is corrected before it is tested.  This is what
> the patch is doing.
>
> However ... for every runtime library there is still something wrong, at least
> one linker check in the generated configure is done before the expansion of the
> AM_ENABLE_MULTILIB macro. I'm not trying to fix that with this patch ...
> autoconf offers a AC_REQUIRE macro, so AM_ENABLE_MULTILIB should add one to
> ensure that this macros is always expanded before the first check for
> "cross_compiling", but I'm not sure which one.
>
> Small patch, but took me some time to find out  :-/
>
> This patch should go to trunk and all active branches. Ok to check in?

The libbacktrace library is unusual because we build it for both the
host and the target.  When building for the host, we do not want to
multilib it--that would make no sense.  You've moved the
AM_ENABLE_MULTILIB out of the test -n "${with_target_subdir}"; don't
do that.

It's fine with me if you move AM_ENABLE_MULTILIB earlier as long as
you keep the test.

Probably a build maintainer should take a look at this patch.

Ian
diff mbox

Patch

--- a/src/libbacktrace/configure.ac
+++ b/src/libbacktrace/configure.ac
@@ -34,6 +34,8 @@ 
 AC_CONFIG_SRCDIR(backtrace.h)
 AC_CONFIG_HEADER(config.h)
 
+AM_ENABLE_MULTILIB(, ..)
+
 AC_CANONICAL_SYSTEM
 target_alias=${target_alias-$host_alias}
 
@@ -83,7 +85,6 @@ 
 if test -n "${with_target_subdir}"; then
   # We are compiling a GCC library.  We can assume that the unwind
   # library exists.
-  AM_ENABLE_MULTILIB(, ..)
   BACKTRACE_FILE="backtrace.lo simple.lo"
 else
   AC_CHECK_HEADER([unwind.h],
--- a/src/libsanitizer/configure.ac
+++ b/src/libsanitizer/configure.ac
@@ -5,6 +5,8 @@ 
 AC_INIT(package-unused, version-unused, libsanitizer)
 AC_CONFIG_SRCDIR([include/sanitizer/common_interface_defs.h])
 
+AM_ENABLE_MULTILIB(, ..)
+
 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
 AC_ARG_ENABLE(version-specific-runtime-libs,
 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
@@ -26,7 +28,6 @@ 
 GCC_LIBSTDCXX_RAW_CXX_FLAGS
 
 AM_INIT_AUTOMAKE(foreign no-dist)
-AM_ENABLE_MULTILIB(, ..)
 AM_MAINTAINER_MODE
 
 # Calculate toolexeclibdir