This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Prefer the system gcc when searching for libraries such as -lm
authorNicholas Clark <nick@ccl4.org>
Wed, 15 Jun 2011 15:24:43 +0000 (16:24 +0100)
committerRicardo Signes <rjbs@cpan.org>
Wed, 21 Mar 2012 01:17:48 +0000 (21:17 -0400)
40f026236b9959b7 added code to the Linux hints file to use gcc to locate
libraries such as -lm. However, if the user has their own gcc earlier in $PATH
than the system gcc, we don't want its libraries. So try to prefer the system
gcc.

hints/linux.sh

index 8a38373..d0ac9fa 100644 (file)
@@ -163,10 +163,18 @@ esac
 # This unconditionally uses gcc because even if the user is using another
 # compiler, we still need to find the math library and friends, and I don't
 # know how other compilers will cope with that situation.
+# Morever, if the user has their own gcc earlier in $PATH than the system gcc,
+# we don't want its libraries. So we try to prefer the system gcc
 # Still, as an escape hatch, allow Configure command line overrides to
 # plibpth to bypass this check.
+if [ -x /usr/bin/gcc ] ; then
+    gcc=/usr/bin/gcc
+else
+    gcc=gcc
+fi
+
 case "$plibpth" in
-'') plibpth=`gcc -print-search-dirs | grep libraries |
+'') plibpth=`$gcc -print-search-dirs | grep libraries |
        cut -f2- -d= | tr ':' $trnl | grep -v 'gcc' | sed -e 's:/$::'`
     set X $plibpth # Collapse all entries on one line
     shift