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]

PATCH RFA: Only define USE_COLLECT2 in host makefile fragments


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.

This patch fixes this.

This patch also adds a test in Makefile.in to catch the case of
building a compiler for a target which requires collect2 on a host
which can not build collect2.  This catches the case of trying to
build a cross-compiler which will not be able to support global
constructors or destructors.  I think it is better to catch this case
at make time then it is to have a silent error occur later.

OK for mainline?

Ian


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

	* config/i386/x-mingw32 (USE_COLLECT2): Define.
	* config/i386/t-mingw32 (USE_COLLECT2): Don't define.
	* config/rs6000/x-beos: New file to define USE_COLLECT2.
	* config/rs6000/t-beos (USE_COLLECT2): Don't define.
	* config/pa/t-pa64: Remove comment about USE_COLLECT2.
	* Makefile.in (cs-config.h): Make sure that we will build collect2
	if it is required for the target.


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 04:21:05 -0000
@@ -984,6 +984,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$(USE_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="" \
Index: i386/t-mingw32
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/t-mingw32,v
retrieving revision 1.3
diff -u -r1.3 t-mingw32
--- i386/t-mingw32	11 Jun 2002 05:25:44 -0000	1.3
+++ i386/t-mingw32	19 Mar 2004 03:51:55 -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: i386/x-mingw32
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/x-mingw32,v
retrieving revision 1.2
diff -u -r1.2 x-mingw32
--- i386/x-mingw32	28 May 2003 21:06:23 -0000	1.2
+++ i386/x-mingw32	19 Mar 2004 03:51:55 -0000
@@ -2,3 +2,7 @@
 # Make local_includedir relative to EXEC_PREFIX 
 #
 local_includedir=$(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include
+#
+# collect2 doesn't work for i386-mingw32* yet.
+#
+USE_COLLECT2=
Index: pa/t-pa64
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/t-pa64,v
retrieving revision 1.7
diff -u -r1.7 t-pa64
--- pa/t-pa64	31 Oct 2002 03:13:44 -0000	1.7
+++ pa/t-pa64	19 Mar 2004 03:51:56 -0000
@@ -5,9 +5,6 @@
 # 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: rs6000/t-beos
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/t-beos,v
retrieving revision 1.5
diff -u -r1.5 t-beos
--- rs6000/t-beos	18 Dec 2002 22:45:35 -0000	1.5
+++ rs6000/t-beos	19 Mar 2004 03:51:56 -0000
@@ -28,6 +28,3 @@
 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: rs6000/x-beos
===================================================================
RCS file: rs6000/x-beos
diff -N rs6000/x-beos
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ rs6000/x-beos	19 Mar 2004 03:51:56 -0000
@@ -0,0 +1,2 @@
+# Don't build collect2.
+USE_COLLECT2 =


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