This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH RFA: Only define USE_COLLECT2 in host makefile fragments


Ian Lance Taylor <ian@wasabisystems.com> writes:

> As I discuss in a lengthy comment in PR 14548, the Makefile variable
> USE_COLLECT2 should be defined in host Makefile fragments, not in
> target Makefile fragments.  This is because the Makefile variable
> USE_COLLECT2, which must not be confused with the C preprocessor macro
> USE_COLLECT2, controls whether the collect2 binary should be built at
> all.  In general, we want to build the collect2 binary, if only to
> support the C++ -frepo option.  However, there are a few non-Unix
> systems which are as yet unable to build collect2.  For those systems,
> it is reasonable to avoid building collect2.  The cost is that it
> becomes impossible to use -frepo, and it becomes impossible to build a
> compiler for a target which requires using collect2 to handle global
> constructors and destructors.  (Naturally a host which can not build
> collect2 needs to use a different mechanism to handle global
> constructors and destructors).  It is better to pay this cost than it
> is to completely fail to support the system.
> 
> As it happens, there are currently two cases in which USE_COLLECT2 is
> defined in a target Makefile fragment.  This is wrong.  There is no
> target for which we do not want to build collect2.  There are only
> hosts on which we can not build collect2.  USE_COLLECT2 should only be
> defined in host Makefile fragments.

Never mind that last patch.  Here is a better one.

In this patch, I do the following:

1) Rename the Makefile variable USE_COLLECT2 to COLLECT2.  This
   eliminates the confusion between the Makefile variable and the C
   preprocessor macro, also named USE_COLLECT2, with a different
   meaning.

2) Initialize COLLECT2 to @collect2@, set by the configure script.

3) Add code to config.host to set host_collect2.

4) Make configure.ac set collect2 based on host_collect2, and
   substitute collect2 into Makefile.

5) Eliminate instances of USE_COLLECT2 in Makefile fragments.

6) As before, give an error if COLLECT2 is empty (i.e., host can not
   build collect2), and host_xm_defines includes USE_COLLECT2 (i.e.,
   target requires collect2 to handle global constructors and
   destructors).

Besides being cleaner, this patch should also fix PR 14548, although
since I don't have a mingw32 system I don't have an easy way to test
that.

OK for mainline if it bootstraps?

Ian


2004-03-19  Ian Lance Taylor  <ian@wasabisystems.com>

	PR target/14548
	* config.host: Set the shell variable host_collect2.  Set it to
	yes by default, and to no for alpha*-dec-*vms*,
	i[34567]86-*-mingw32*, and powerpc-*-beos*.
	* configure.ac: Set and substitute the shell variable collect2.
	* Makefile.in (COLLECT2): Rename from USE_COLLECT2.  Change all
	uses.  Initialize to @collect2@.
	(STAGESTUFF): Remove $(USE_COLLECT2).
	(cs-config.h): Give an error if COLLECT2 is the empty string and
	host_xm_defines includes USE_COLLECT2.
	* config/alpha/x-vms (USE_COLLECT2): Don't set.
	* config/i386/t-mingw32 (USE_COLLECT2): Likewise.
	* config/rs6000/t-beos (USE_COLLECT2): Likewise.
	* config/pa/t-pa64: Remove commented out USE_COLLECT2.
	* configure: Regenerate.


Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1263
diff -p -u -r1.1263 Makefile.in
--- Makefile.in	18 Mar 2004 16:42:29 -0000	1.1263
+++ Makefile.in	19 Mar 2004 05:03:01 -0000
@@ -539,9 +539,10 @@ EXTRA_GCC_OBJS =@extra_gcc_objs@
 # List of additional header files to install.
 EXTRA_HEADERS =@extra_headers_list@
 
-# It is convenient for configure to add the assignment at the beginning,
-# so don't override it here.
-USE_COLLECT2 = collect2$(exeext)
+# The configure script will set this to collect2$(exeext), except on a
+# (non-Unix) host which can not build collect2, for which it will be
+# set to empty.
+COLLECT2 = @collect2@
 
 # List of extra C and assembler files to add to static and shared libgcc2.
 # Assembler files should have names ending in `.asm'.
@@ -580,7 +581,7 @@ GCC_PASSES=xgcc$(exeext) cc1$(exeext) sp
 
 # List of things which should already be built whenever we try to use xgcc
 # to link anything.
-GCC_PARTS=$(GCC_PASSES) $(LIBGCC) $(EXTRA_PROGRAMS) $(USE_COLLECT2) $(EXTRA_PARTS)
+GCC_PARTS=$(GCC_PASSES) $(LIBGCC) $(EXTRA_PROGRAMS) $(COLLECT2) $(EXTRA_PARTS)
 
 # Directory to link to, when using the target `maketest'.
 DIR = ../gcc
@@ -895,7 +896,7 @@ STAGESTUFF = *$(objext) insn-flags.h ins
  xgcc$(exeext) cpp$(exeext) cc1$(exeext) $(EXTRA_PASSES) \
  $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) \
  protoize$(exeext) unprotoize$(exeext) \
- $(SPECS) collect2$(exeext) $(USE_COLLECT2) \
+ $(SPECS) collect2$(exeext) \
  gcov-iov$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
  *.[0-9][0-9].* *.[si] libcpp.a libbackend.a libgcc.mk \
  $(LANG_STAGESTUFF)
@@ -984,6 +985,12 @@ cs-config.h: Makefile
 	TARGET_CPU_DEFAULT="" \
 	HEADERS="$(host_xm_include_list)" DEFINES="$(host_xm_defines)" \
 	$(SHELL) $(srcdir)/mkconfig.sh config.h
+	if test "x$(COLLECT2)" = "x"; then \
+	  if echo "$(host_xm_defines)" | grep USE_COLLECT2 > /dev/null; then \
+	    echo 1>&2 ERROR: collect2 is required but can not be built on this host; \
+	    exit 1; \
+	  fi; \
+	else true; fi
 
 cs-bconfig.h: Makefile
 	TARGET_CPU_DEFAULT="" \
@@ -1072,7 +1079,7 @@ rest.encap: $(STMP_FIXPROTO) $(LIBGCC) $
 # This is what is made with the host's compiler
 # whether making a cross compiler or not.
 native: config.status auto-host.h build-@POSUB@ $(LANGUAGES) \
-	$(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(USE_COLLECT2)
+	$(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(COLLECT2)
 
 # Define the names for selecting languages in LANGUAGES.
 C c: cc1$(exeext)
@@ -2903,7 +2910,7 @@ install-common: native $(EXTRA_PARTS) la
 	  else true; \
 	  fi; \
 	done
-	for file in $(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(USE_COLLECT2) ..; do \
+	for file in $(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(COLLECT2) ..; do \
 	  if [ x"$$file" != x.. ]; then \
 	    rm -f $(DESTDIR)$(libexecsubdir)/$$file; \
 	    $(INSTALL_PROGRAM) $$file $(DESTDIR)$(libexecsubdir)/$$file; \
Index: config.host
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.host,v
retrieving revision 2.8
diff -p -u -r2.8 config.host
--- config.host	11 Mar 2004 03:19:03 -0000	2.8
+++ config.host	19 Mar 2004 05:03:01 -0000
@@ -49,6 +49,9 @@
 #                       be linked into the gcc driver.
 #
 #  out_host_hook_obj    An object file that provides the host hooks.
+#
+#  host_collect2	Set to yes normally, or no if the host can not
+#			build collect2
 
 # When setting any of these variables, check to see if a corresponding
 # variable is present in config.build; if so, you will likely want to 
@@ -62,6 +65,7 @@ host_exeext=
 host_extra_objs=
 host_extra_gcc_objs=
 out_host_hook_obj=host-default.o
+host_collect2=yes
 
 # Unsupported hosts list.  Generally, only include hosts known to fail here,
 # since we allow hosts not listed to be supported generically.
@@ -82,6 +86,7 @@ case ${host} in
     host_xm_file=alpha/xm-vms.h
     host_xmake_file=alpha/x-vms
     host_exeext=.exe
+    host_collect2=no
     # This removes the cpu type and manufacturer components and
     #  replaces "." with "_" in the operating system version.
     target_noncanonical=`echo $host | sed 's/.*-.*-\(.*\)$/\1/' | sed 's/\./_/g'`
@@ -137,6 +142,7 @@ case ${host} in
     host_xm_file=i386/xm-mingw32.h
     host_xmake_file=i386/x-mingw32
     host_exeext=.exe
+    host_collect2=no
     ;;
   i[34567]86-*-uwin*)
     echo "*** UWIN may not be used as a host platform because"
@@ -148,6 +154,9 @@ case ${host} in
     ;;
   i860-*-sysv4*)
     host_xmake_file=i860/x-sysv4
+    ;;
+  powerpc-*-beos*)
+    host_collect2=no
     ;;
   powerpc-*-darwin*)
     # powerpc-darwin host support.
Index: configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.ac,v
retrieving revision 2.23
diff -p -u -r2.23 configure.ac
--- configure.ac	11 Mar 2004 05:01:16 -0000	2.23
+++ configure.ac	19 Mar 2004 05:03:05 -0000
@@ -1607,6 +1607,12 @@ for file in ${extra_headers} ; do
   extra_headers_list="${extra_headers_list} \$(srcdir)/config/${cpu_type}/${file}"
 done
 
+# Define collect2 in Makefile.
+case $host_collect2 in
+  no) collect2= ;;
+  *) collect2='collect2$(exeext)' ;;
+esac
+
 # Add a definition of USE_COLLECT2 if system wants one.
 case $use_collect2 in
   no) use_collect2= ;;
@@ -2966,6 +2972,7 @@ AC_SUBST(build_install_headers_dir)
 AC_SUBST(build_xm_file_list)
 AC_SUBST(build_xm_include_list)
 AC_SUBST(build_xm_defines)
+AC_SUBST(collect2)
 AC_SUBST(check_languages)
 AC_SUBST(cc_set_by_configure)
 AC_SUBST(quoted_cc_set_by_configure)
Index: config/alpha/x-vms
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/x-vms,v
retrieving revision 1.8
diff -p -u -r1.8 x-vms
--- config/alpha/x-vms	13 Feb 2002 15:32:02 -0000	1.8
+++ config/alpha/x-vms	19 Mar 2004 05:03:12 -0000
@@ -19,6 +19,3 @@ decc.exe : vms-cc.o
 # These extra parts can only be compiled on a VMS host and are only needed
 # on a VMS target.  The rules are in t-vms.
 VMS_EXTRA_PARTS=vcrt0.o pcrt0.o
-
-# Doesn't work on VMS
-USE_COLLECT2=
Index: config/i386/t-mingw32
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/t-mingw32,v
retrieving revision 1.3
diff -p -u -r1.3 t-mingw32
--- config/i386/t-mingw32	11 Jun 2002 05:25:44 -0000	1.3
+++ config/i386/t-mingw32	19 Mar 2004 05:03:18 -0000
@@ -1,7 +1,2 @@
-#
-# collect2 doesn't work for i386-mingw32* yet.
-#
-USE_COLLECT2=
-
 # We hide calls to w32api needed for w32 thread support here:
 LIB2FUNCS_EXTRA = $(srcdir)/config/i386/gthr-win32.c
Index: config/pa/t-pa64
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/t-pa64,v
retrieving revision 1.7
diff -p -u -r1.7 t-pa64
--- config/pa/t-pa64	31 Oct 2002 03:13:44 -0000	1.7
+++ config/pa/t-pa64	19 Mar 2004 05:03:20 -0000
@@ -5,9 +5,6 @@ LIB2FUNCS_EXTRA=quadlib.c
 # We'll need this once .init sections are enabled on PA64.
 #EXTRA_PARTS = crtbegin.o crtend.o
 
-# For the time being, we are using collect.
-#USE_COLLECT2 =
-
 quadlib.c: $(srcdir)/config/pa/quadlib.c
 	rm -f quadlib.c
 	cp $(srcdir)/config/pa/quadlib.c .
Index: config/rs6000/t-beos
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/t-beos,v
retrieving revision 1.5
diff -p -u -r1.5 t-beos
--- config/rs6000/t-beos	18 Dec 2002 22:45:35 -0000	1.5
+++ config/rs6000/t-beos	19 Mar 2004 05:03:21 -0000
@@ -28,6 +28,3 @@ EXTRA_PARTS = milli.exp
 milli.exp: $(srcdir)/config/rs6000/milli.exp
 	rm -f milli.exp
 	cp $(srcdir)/config/rs6000/milli.exp ./milli.exp
-
-# Don't use collect.
-USE_COLLECT2 =


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]