bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

havelib: make it work again for CC="gcc -m32"


From: Bruno Haible
Subject: havelib: make it work again for CC="gcc -m32"
Date: Sat, 30 Sep 2017 16:03:30 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-93-generic; KDE/5.18.0; x86_64; ; )

On Linux/powerpc64 and Linux/sparc64 platforms (at least), the change from
2017-02-19 has the effect that the AC_LIB_LINKFLAGS macro will search for
the libraries under $prefix/lib64 - even if CC="gcc -m32".

This fixes it.

2017-09-30  Bruno Haible  <address@hidden>

        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.

diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4
index 0d03dc2..ea3b03a 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 2a264cc..7504435 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:
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]