This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] gcc configure's determination of ld and as
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 2 Jun 2005 20:52:22 +0930
- Subject: [PATCH] gcc configure's determination of ld and as
Today, I found to my dismay that using --with-ld=path_to_ld when
configuring gcc leads to a compiler that effectively ignores -B paths
when searching for ld. This meant that binutils "make check" on my
powerpc64-linux box has been testing an installed linker for some of the
ld tests, rather than the newly built one. So I've missed seeing ld
regressions.
Now, the reason I use --with-ld is that I have left /usr/bin/ld
unchanged from my original Linux installation, and build bleeding edge
toolchains installed in /usr/local/. My path selects the /usr/local
versions, but gcc configure goes looking in /usr/bin before checking
my PATH environment var. Which is annoying because a number of
configure tests fail if /usr/bin/ld is used, and plain wrong because the
newly built compiler will use /usr/local/bin/ld before /usr/bin/ld.
Apparently this is because some gcc targets used to specify an
MD_EXEC_PREFIX of "/usr/bin/". So I decided to fix this sad piece of
configure hackery by not looking at (an out of date) list of "all known
MD_EXEC_PREFIX values", but instead discover the actual MD_EXEC_PREFIX
from tm files.
* configure.ac (gcc_cv_as, gcc_cv_ld): Examine MD_EXEC_PREFIX in
tm files to determine compiler search path. Kill code duplication.
Tested powerpc-linux. OK to install? How about 4.0 and 3.4 too?
diff -urp -xCVS -x'*~' -x'.#*' gcc-virgin/gcc/configure.ac gcc-current/gcc/configure.ac
--- gcc-virgin/gcc/configure.ac 2005-06-02 18:15:26.000000000 +0930
+++ gcc-current/gcc/configure.ac 2005-06-02 18:46:31.000000000 +0930
@@ -1776,28 +1776,48 @@ fi
gcc_version=`cat $srcdir/BASE-VER`
-if test "x$gcc_cv_as" = x; then
- # Search the same directories that the installed compiler will
- # search. Else we may find the wrong assembler and lose. If we
- # do not find a suitable assembler binary, then try the user's
- # path.
- #
- # Also note we have to check MD_EXEC_PREFIX before checking the
- # user's path. Unfortunately, there is no good way to get at the
- # value of MD_EXEC_PREFIX here. So we do a brute force search
- # through all the known MD_EXEC_PREFIX values. Ugh. This needs
- # to be fixed as part of the make/configure rewrite too.
-
- if test "x$exec_prefix" = xNONE; then
- if test "x$prefix" = xNONE; then
- test_prefix=/usr/local
- else
- test_prefix=$prefix
- fi
+# When searching for the assembler or linker, search the same directories
+# that the installed compiler will search. Else we may find the wrong
+# assembler or linker and lose. If we do not find a suitable binary,
+# then try the user's path.
+#
+# Also note we have to check MD_EXEC_PREFIX before checking the user's path.
+if test "x$exec_prefix" = xNONE; then
+ if test "x$prefix" = xNONE; then
+ test_prefix=/usr/local
else
- test_prefix=$exec_prefix
+ test_prefix=$prefix
fi
+else
+ test_prefix=$exec_prefix
+fi
+
+if test x$host = x$build; then
+ test_dirs="$test_prefix/libexec/gcc/$target_noncanonical/$gcc_version \
+ $test_prefix/libexec/gcc/$target_noncanonical \
+ /usr/lib/gcc/$target_noncanonical/$gcc_version \
+ /usr/lib/gcc/$target_noncanonical \
+ $test_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version \
+ $test_prefix/$target_noncanonical/bin"
+else
+ test_dirs=
+fi
+if test x$build = x$target; then
+# Rummage through tm_files looking for MD_EXEC_PREFIX
+ md_dirs=
+ for f in ${tm_file_list}; do
+ if test -f $f; then
+ if grep '^#[ ]*undef[ ]*MD_EXEC_PREFIX' $f > /dev/null; then
+ md_dirs=
+ fi
+ md_dirs="$md_dirs "`sed -n -e 's@^#[ ]*define[ ]*MD_EXEC_PREFIX[ ]*"\(.*\)/"@\1@p' < $f`
+ fi
+ done
+ test_dirs="$test_dirs $md_dirs"
+fi
+
+if test "x$gcc_cv_as" = x; then
# If the loop below does not find an assembler, then use whatever
# one we can find in the users's path. We are looking for a
# ${build} -> ${target} assembler.
@@ -1809,31 +1829,6 @@ if test "x$gcc_cv_as" = x; then
gcc_cv_as=`echo as | sed "${program_transform_name}"`$build_exeext
fi
- if test x$host = x$build; then
- test_dirs="$test_prefix/libexec/gcc/$target_noncanonical/$gcc_version \
- $test_prefix/libexec/gcc/$target_noncanonical \
- /usr/lib/gcc/$target_noncanonical/$gcc_version \
- /usr/lib/gcc/$target_noncanonical \
- $test_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version \
- $test_prefix/$target_noncanonical/bin"
- else
- test_dirs=
- fi
-
- if test x$build = x$target; then
- test_dirs="$test_dirs \
- /usr/libexec \
- /usr/ccs/gcc \
- /usr/ccs/bin \
- /udk/usr/ccs/bin \
- /bsd43/usr/lib/cmplrs/cc \
- /usr/cross64/usr/bin \
- /usr/lib/cmplrs/cc \
- /sysv/usr/lib/cmplrs/cc \
- /svr4/usr/lib/cmplrs/cc \
- /usr/bin"
- fi
-
for dir in $test_dirs; do
if test -x $dir/as$build_exeext; then
gcc_cv_as=$dir/as$build_exeext
@@ -1904,17 +1899,6 @@ elif test -x "$LD" && test x$host = x$ta
fi
if test "x$gcc_cv_ld" = x; then
- # Search the same directories that the installed compiler will
- # search. Else we may find the wrong linker and lose. If we
- # do not find a suitable linker binary, then try the user's
- # path.
- #
- # Also note we have to check MD_EXEC_PREFIX before checking the
- # user's path. Unfortunately, there is no good way to get at the
- # value of MD_EXEC_PREFIX here. So we do a brute force search
- # through all the known MD_EXEC_PREFIX values. Ugh. This needs
- # to be fixed as part of the make/configure rewrite too.
-
if test "x$exec_prefix" = xNONE; then
if test "x$prefix" = xNONE; then
test_prefix=/usr/local
@@ -1936,31 +1920,6 @@ if test "x$gcc_cv_ld" = x; then
gcc_cv_ld=`echo ld | sed "${program_transform_name}"`$build_exeext
fi
- if test x$host = x$build; then
- test_dirs="$test_prefix/libexec/gcc/$target_noncanonical/$gcc_version \
- $test_prefix/libexec/gcc/$target_noncanonical \
- /usr/lib/gcc/$target_noncanonical/$gcc_version \
- /usr/lib/gcc/$target_noncanonical \
- $test_prefix/$target_noncanonical/bin/$target_noncanonical/$gcc_version \
- $test_prefix/$target_noncanonical/bin"
- else
- test_dirs=
- fi
-
- if test x$build = x$target; then
- test_dirs="$test_dirs \
- /usr/libexec \
- /usr/ccs/gcc \
- /usr/ccs/bin \
- /udk/usr/ccs/bin \
- /bsd43/usr/lib/cmplrs/cc \
- /usr/cross64/usr/bin \
- /usr/lib/cmplrs/cc \
- /sysv/usr/lib/cmplrs/cc \
- /svr4/usr/lib/cmplrs/cc \
- /usr/bin"
- fi
-
for dir in $test_dirs; do
if test -x $dir/ld$build_exeext; then
gcc_cv_ld=$dir/ld$build_exeext
--
Alan Modra
IBM OzLabs - Linux Technology Centre