From e2b7318b33e645bd8cebde425c9f7b7d0cceb480 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 30 Sep 2017 15:59:27 +0200 Subject: [PATCH] havelib: Make it work for CC="gcc -m32" (regression from 2017-02-19). * m4/lib-prefix.m4 (AC_LIB_PREPARE_MULTILIB): Require gl_HOST_CPU_C_ABI. When $CC produces 32-bit code, set acl_libdirstem to 'lib', not 'lib64'. * modules/havelib (Depends-on): Add host-cpu-c-abi. --- ChangeLog | 7 ++++++ m4/lib-prefix.m4 | 65 +++++++++++++++++++++++++++--------------------- modules/havelib | 1 + 3 files changed, 45 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9511d0b69..0d219bd392 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2017-09-30 Bruno Haible + + havelib: Make it work for CC="gcc -m32" (regression from 2017-02-19). + * m4/lib-prefix.m4 (AC_LIB_PREPARE_MULTILIB): Require gl_HOST_CPU_C_ABI. + When $CC produces 32-bit code, set acl_libdirstem to 'lib', not 'lib64'. + * modules/havelib (Depends-on): Add host-cpu-c-abi. + 2017-09-30 Bruno Haible uniname/uniname: Don't assume C99 compiler (regression from 2015-02-16). diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4 index 0d03dc22ba..ea3b03a633 100644 --- a/m4/lib-prefix.m4 +++ b/m4/lib-prefix.m4 @@ -1,4 +1,4 @@ -# lib-prefix.m4 serial 8 +# lib-prefix.m4 serial 9 dnl Copyright (C) 2001-2005, 2008-2017 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -174,6 +174,7 @@ AC_DEFUN([AC_LIB_PREPARE_MULTILIB], dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([gl_HOST_CPU_C_ABI]) dnl Allow the user to override the result by setting acl_cv_libdirstems. AC_CACHE_CHECK([for the common suffixes of directories in the library search path], [acl_cv_libdirstems], @@ -202,34 +203,42 @@ sixtyfour bits fi ;; *) - dnl The result is a property of the system. However, non-system - dnl compilers sometimes have odd library search paths. Therefore - dnl prefer asking /usr/bin/gcc, if available, rather than $CC. - searchpath=`(if test -f /usr/bin/gcc \ - && LC_ALL=C /usr/bin/gcc -print-search-dirs >/dev/null 2>/dev/null; then \ - LC_ALL=C /usr/bin/gcc -print-search-dirs; \ - else \ - LC_ALL=C $CC -print-search-dirs; \ - fi) 2>/dev/null \ - | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` - if test -n "$searchpath"; then - acl_save_IFS="${IFS= }"; IFS=":" - for searchdir in $searchpath; do - if test -d "$searchdir"; then - case "$searchdir" in - */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; - */../ | */.. ) - # Better ignore directories of this form. They are misleading. - ;; - *) searchdir=`cd "$searchdir" && pwd` - case "$searchdir" in - */lib64 ) acl_libdirstem=lib64 ;; - esac ;; - esac + dnl If $CC generates code for a 32-bit ABI, the libraries are + dnl surely under $prefix/lib, not $prefix/lib64. + case "$gl_cv_host_cpu_c_abi" in + i386 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | s390 | sparc) + ;; + *) # x86_64 | arm64 | hppa64 | ia64 | mips64 | powerpc64* | s390x | sparc64 | ... + dnl The result is a property of the system. However, non-system + dnl compilers sometimes have odd library search paths. Therefore + dnl prefer asking /usr/bin/gcc, if available, rather than $CC. + searchpath=`(if test -f /usr/bin/gcc \ + && LC_ALL=C /usr/bin/gcc -print-search-dirs >/dev/null 2>/dev/null; then \ + LC_ALL=C /usr/bin/gcc -print-search-dirs; \ + else \ + LC_ALL=C $CC -print-search-dirs; \ + fi) 2>/dev/null \ + | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" fi - done - IFS="$acl_save_IFS" - fi + ;; + esac ;; esac test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" diff --git a/modules/havelib b/modules/havelib index 2a264ccd97..75044356ef 100644 --- a/modules/havelib +++ b/modules/havelib @@ -8,6 +8,7 @@ m4/lib-prefix.m4 build-aux/config.rpath Depends-on: +host-cpu-c-abi configure.ac: -- 2.39.5