This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Hard-link to in-tree tools (take 2)
$(SHELL); also permissions.
Fixed.
Ok for mainline?
Paolo
2005-05-18 Paolo Bonzini <bonzini@gnu.org>
* Makefile.def (configure-gcc): Depend on all-binutils, all-gas, all-ld.
(all-gcc): Do not depend on all-binutils, all-gas, all-ld.
* Makefile.in: Regenerate.
gcc:
2005-05-18 Paolo Bonzini <bonzini@gnu.org>
Daniel Jacobowitz <drow@codesourcery.com>
* configure.ac (gcc_version): Set near the beginning.
(as, ld, nm): Do not link in-tree tools. Set gcc_cv_* if tools are
found in the tree. Use gcc_AC_PROG to find the tools in the system.
(objdump): Do not look for it.
* Makefile.in (NM_FOR_TARGET): Point to ./nm
(ORIGINAL_AS_FOR_TARGET, ORIGINAL_LD_FOR_TARGET,
ORIGINAL_NM_FOR_TARGET): Substitute from autoconf.
(as, ld, nm): New rules.
(libgcc.mk): Depend on them.
* aclocal.m4 (gcc_AC_PROG): New.
* configure: Regenerate.
Index: Makefile.def
===================================================================
RCS file: /cvs/gcc/gcc/Makefile.def,v
retrieving revision 1.50
diff -p -u -u -r1.50 Makefile.def
--- Makefile.def 30 Mar 2005 08:17:44 -0000 1.50
+++ Makefile.def 19 May 2005 09:23:01 -0000
@@ -242,9 +242,9 @@ dependencies = { module=all-build-fixinc
// Host modules specific to gcc.
dependencies = { module=configure-gcc; on=configure-intl; };
-dependencies = { module=configure-gcc; on=configure-binutils; };
-dependencies = { module=configure-gcc; on=configure-gas; };
-dependencies = { module=configure-gcc; on=configure-ld; };
+dependencies = { module=configure-gcc; on=all-binutils; };
+dependencies = { module=configure-gcc; on=all-gas; };
+dependencies = { module=configure-gcc; on=all-ld; };
dependencies = { module=all-gcc; on=all-libiberty; hard=true; };
dependencies = { module=all-gcc; on=all-intl; };
dependencies = { module=all-gcc; on=all-build-texinfo; };
@@ -253,9 +253,6 @@ dependencies = { module=all-gcc; on=all-
dependencies = { module=all-gcc; on=all-build-flex; };
dependencies = { module=all-gcc; on=all-build-libiberty; };
dependencies = { module=all-gcc; on=all-build-fixincludes; };
-dependencies = { module=all-gcc; on=all-binutils; };
-dependencies = { module=all-gcc; on=all-gas; };
-dependencies = { module=all-gcc; on=all-ld; };
dependencies = { module=all-gcc; on=all-zlib; };
dependencies = { module=all-gcc; on=all-libcpp; hard=true; };
dependencies = { module=all-gcc; on=all-libiberty; };
Index: gcc/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.ac,v
retrieving revision 2.112
diff -p -u -u -r2.112 configure.ac
--- gcc/configure.ac 17 May 2005 15:00:26 -0000 2.112
+++ gcc/configure.ac 19 May 2005 08:19:55 -0000
@@ -30,6 +30,8 @@ AC_INIT
AC_CONFIG_SRCDIR(tree.c)
AC_CONFIG_HEADER(auto-host.h:config.in)
+gcc_version=`cat $srcdir/BASE-VER`
+
# Determine the host, build, and target systems
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
@@ -1760,8 +1762,7 @@ elif test -f $gcc_cv_as_gas_srcdir/confi
# we'll use what we're building after installation anyway.
in_tree_gas=yes
_gcc_COMPUTE_GAS_VERSION
- rm -f as$build_exeext
- $LN_S ../gas/as-new$build_exeext as$build_exeext 2>/dev/null
+ gcc_cv_as=../gas/as-new$build_exeext
in_tree_gas_is_elf=no
if grep 'obj_format = elf' ../gas/Makefile > /dev/null \
|| (grep 'obj_format = multi' ../gas/Makefile \
@@ -1776,73 +1777,7 @@ elif test -x "$AS" && test x$host = x$ta
gcc_cv_as="$AS"
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
- else
- test_prefix=$exec_prefix
- fi
-
- # 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.
- if test "x$program_prefix" != xNONE; then
- gcc_cv_as=${program_prefix}as$build_exeext
- elif test x$build != x$host && test x$build != x$target; then
- gcc_cv_as=${target_noncanonical}-as$build_exeext
- else
- 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
- break;
- fi
- done
-fi
+gcc_AC_PROG(gcc_cv_as, as, ORIGINAL_AS_FOR_TARGET)
case $in_tree_gas in
yes)
AC_MSG_RESULT("newly built gas")
@@ -1897,79 +1832,14 @@ changequote(,)dnl
gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"`
gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
changequote([,])dnl
- rm -f collect-ld$build_exeext
- $LN_S ../ld/ld-new$build_exeext collect-ld$build_exeext 2>/dev/null
+ gcc_cv_ld=../ld/ld-new$build_exeext
elif test -x "$LD_FOR_TARGET"; then
gcc_cv_ld="$LD_FOR_TARGET"
elif test -x "$LD" && test x$host = x$target; then
gcc_cv_ld="$LD"
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
- else
- test_prefix=$prefix
- fi
- else
- test_prefix=$exec_prefix
- fi
-
- # If the loop below does not find a linker, then use whatever
- # one we can find in the users's path. We are looking for a
- # ${build} -> ${target} linker.
- if test "x$program_prefix" != xNONE; then
- gcc_cv_ld=${program_prefix}ld$build_exeext
- elif test x$build != x$host && test x$build != x$target; then
- gcc_cv_ld=${target_noncanonical}-ld$build_exeext
- else
- 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
- break;
- fi
- done
-fi
+gcc_AC_PROG(gcc_cv_ld, ld, ORIGINAL_LD_FOR_TARGET)
case $in_tree_ld in
yes)
AC_MSG_RESULT("newly built ld")
@@ -1989,16 +1859,14 @@ elif test -f $gcc_cv_binutils_srcdir/con
&& test -f ../binutils/Makefile; then
# Single tree build which includes binutils.
in_tree_nm=yes
- gcc_cv_nm=./nm$build_exeext
- rm -f nm$build_exeext
- $LN_S ../binutils/nm-new$build_exeext nm$build_exeext 2>/dev/null
+ gcc_cv_nm=../binutils/nm-new$build_exeext
elif test "x$program_prefix" != xNONE; then
gcc_cv_nm=${program_prefix}nm$build_exeext
elif test x$build != x$host && test x$build != x$target; then
gcc_cv_nm=${target_noncanonical}-nm$build_exeext
-else
- gcc_cv_nm=`echo nm | sed "${program_transform_name}"`$build_exeext
fi
+
+gcc_AC_PROG(gcc_cv_nm, nm, ORIGINAL_NM_FOR_TARGET)
case $in_tree_nm in
yes) AC_MSG_RESULT("newly built nm") ;;
no) AC_MSG_RESULT($gcc_cv_nm) ;;
@@ -2013,9 +1881,7 @@ elif test -f $gcc_cv_binutils_srcdir/con
&& test -f ../binutils/Makefile; then
# Single tree build which includes binutils.
in_tree_objdump=yes
- gcc_cv_objdump=./objdump$build_exeext
- rm -f objdump$build_exeext
- $LN_S ../binutils/objdump$build_exeext objdump$build_exeext 2>/dev/null
+ gcc_cv_objdump=../binutils/objdump$build_exeext
elif test "x$program_prefix" != xNONE; then
gcc_cv_objdump=${program_prefix}objdump$build_exeext
elif test x$build != x$host && test x$build != x$target; then
Index: gcc/Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1487
diff -p -u -u -r1.1487 Makefile.in
--- gcc/Makefile.in 17 May 2005 16:27:43 -0000 1.1487
+++ gcc/Makefile.in 19 May 2005 13:45:16 -0000
@@ -343,6 +343,7 @@ AR_FOR_TARGET := $(shell \
AR_FLAGS_FOR_TARGET =
AR_CREATE_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) rc
AR_EXTRACT_FOR_TARGET = $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) x
+ORIGINAL_AS_FOR_TARGET = @ORIGINAL_AS_FOR_TARGET@
RANLIB_FOR_TARGET := $(shell \
if [ -f $(objdir)/../binutils/ranlib ] ; then \
echo $(objdir)/../binutils/ranlib ; \
@@ -353,18 +354,9 @@ RANLIB_FOR_TARGET := $(shell \
t='$(program_transform_name)'; echo ranlib | sed -e $$t ; \
fi; \
fi)
-NM_FOR_TARGET := $(shell \
- if [ -f ./nm ] ; then \
- echo ./nm ; \
- elif [ -f $(objdir)/../binutils/nm-new ] ; then \
- echo $(objdir)/../binutils/nm-new ; \
- else \
- if [ "$(host)" = "$(target)" ] ; then \
- echo $(NM); \
- else \
- t='$(program_transform_name)'; echo nm | sed -e $$t ; \
- fi; \
- fi)
+ORIGINAL_LD_FOR_TARGET = @ORIGINAL_LD_FOR_TARGET@
+ORIGINAL_NM_FOR_TARGET = @ORIGINAL_NM_FOR_TARGET@
+NM_FOR_TARGET = ./nm
# --------
# UNSORTED
@@ -1202,6 +1194,33 @@ cpp$(exeext): gcc.o cppspec.o version.o
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ gcc.o cppspec.o intl.o \
prefix.o version.o $(EXTRA_GCC_OBJS) $(LIBS)
+# Create links to binutils, especially for in-tree builds, to make -B.
+# use them. We need hard links so that directories can be shuffled
+# during toplevel bootstrap.
+as$(exeext): $(ORIGINAL_AS_FOR_TARGET)
+ @echo creating $@; rm -f $@; \
+ case "$<" in \
+ ../*) echo $(LN) $< $@; $(LN) $< $@ || cp $< $@ ;; \
+ *) echo '#! $(SHELL)' > $@; echo 'exec $< "$$@"' >> $@ ; \
+ chmod +x $@ ;; \
+ esac
+
+collect-ld$(exeext): $(ORIGINAL_LD_FOR_TARGET)
+ @echo creating $@; rm -f $@; \
+ case "$<" in \
+ ../*) echo $(LN) $< $@; $(LN) $< $@ || cp $< $@ ;; \
+ *) echo '#! $(SHELL)' > $@; echo 'exec $< "$$@"' >> $@ ; \
+ chmod +x $@ ;; \
+ esac
+
+nm$(exeext): $(ORIGINAL_NM_FOR_TARGET)
+ @echo creating $@; rm -f $@; \
+ case "$<" in \
+ ../*) echo $(LN) $< $@; $(LN) $< $@ || cp $< $@ ;; \
+ *) echo '#! $(SHELL)' > $@; echo 'exec $< "$$@"' >> $@ ; \
+ chmod +x $@ ;; \
+ esac
+
# Dump a specs file to make -B./ read these specs over installed ones.
$(SPECS): xgcc$(exeext)
$(GCC_FOR_TARGET) -dumpspecs > tmp-specs
@@ -1231,7 +1250,8 @@ xlimits.h: glimits.h limitx.h limity.h
LIB2ADD = $(LIB2FUNCS_EXTRA)
LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA)
-libgcc.mk: config.status Makefile mklibgcc $(LIB2ADD) $(LIB2ADD_ST) xgcc$(exeext) specs
+libgcc.mk: config.status Makefile mklibgcc $(LIB2ADD) $(LIB2ADD_ST) specs \
+ xgcc$(exeext) as$(exeext) collect-ld$(exeext) nm$(exeext)
objext='$(objext)' \
LIB1ASMFUNCS='$(LIB1ASMFUNCS)' \
LIB2FUNCS_ST='$(LIB2FUNCS_ST)' \
Index: gcc/aclocal.m4
===================================================================
RCS file: /cvs/gcc/gcc/gcc/aclocal.m4,v
retrieving revision 1.104
diff -p -u -u -r1.104 aclocal.m4
--- gcc/aclocal.m4 8 May 2005 10:13:16 -0000 1.104
+++ gcc/aclocal.m4 19 May 2005 12:33:39 -0000
@@ -676,3 +676,73 @@ m4_ifdef([GCC_TARGET_TEMPLATE($1)],[],[#
])[#undef $1]m4_ifdef([GCC_TARGET_TEMPLATE($1)],[],[
#endif
]))])
+
+m4_define([gcc_AC_PROG], [
+if test "x[$]$1" = x; then
+ # Search the same directories that the installed compiler will
+ # search. Else we may find the wrong tool and lose. If we
+ # do not find a suitable tool 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
+ else
+ test_prefix=$exec_prefix
+ fi
+
+ # If the loop below does not find a tool, then use whatever
+ # one we can find in the users's path. We are looking for a
+ # ${build} -> ${target} tool.
+ if test "x$program_prefix" != xNONE; then
+ $1=${program_prefix}$2$build_exeext
+ elif test x$build != x$host && test x$build != x$target; then
+ $1=${target_noncanonical}-$2$build_exeext
+ else
+ $1=`echo $2 | 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/$2$build_exeext; then
+ $1=$dir/$2$build_exeext
+ break;
+ fi
+ done
+fi
+$3="[$]$1"
+AC_SUBST($3)dnl
+])