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: Use $(COMPILER) to build objects


Paolo Bonzini <bonzini@gnu.org> writes:

> Joseph S. Myers wrote:
>> On Wed, 20 May 2009, Ian Lance Taylor wrote:
>> 
>>> This is a preliminary step toward supporting a configure option to build
>>> gcc using either a C compiler or a C++ compiler.  I think it would lead
>>> to long term confusion to use $(CC) in a Makefile to represent a C++
>>> compiler.  This patch instead arranges to compile all code using
>>> $(COMPILER).  CFLAGS changes to COMPILER_FLAGS and ALL_CFLAGS changes to
>>> ALL_COMPILERFLAGS.  The COMPILER make variable is currently always set
>>> to $(CC); my intent is that in the future, a configure option will
>>> permit it to be set to either $(CC) or $(CXX).
>>>
>>> This is a mechanical patch.  I'm sure there will be some details to
>>> clean up when we are ready to optionally set COMPILER to $(CXX).
>> 
>> In particular, I believe the command for compiling should be separated 
>> from the command used for linking, so that --with-host-libstdcxx will 
>> cause linking with the C compiler.  (There is no -static-libstdc++ option 
>> so you can't readily make the C++ compiler link with static libstdc++ when 
>> desired.)
>
> Ian, as a followup please add LINKER and LINKER_FLAGS and change
> COMPILER to LINKER where relevant.

Here is that followup patch.  (I also intend to implement
-static-libstdc++, so I think this patch is not essential for gcc-in-cxx
work.)

Bootstrapped on i686-pc-linux-gnu.  OK for mainline?

Ian


gcc/ChangeLog:

2009-05-26  Ian Lance Taylor  <iant@google.com>

	* Makefile.in (LINKER, LINKER_FLAGS): Define.
	(LINKER_FOR_BUILD, BUILD_LINKERFLAGS): Define.
	(ALL_LINKERFLAGS): Define.
	(xgcc$(exeext)): Change $(COMPILER) to $(LINKER).
	(cpp$(exeext), cc1-dummy$(exeext), cc1$(exeext)): Likewise.
	(collect2$(exeext), mips-tfile, mips-tdump): Likewise.
	(gcov$(exeext), gcov-dump$(exeext)): Likewise.
	(build/gen%$(build_exeext)): Change $(COMPILER_FOR_BUILD) to
	$(LINKER_FOR_BUILD).
	(build/gcov-iov$(build_exeext)): Likewise.

gcc/cp/ChangeLog:

2009-05-26  Ian Lance Taylor  <iant@google.com>

	* Make-lang.in (g++$(exeext)): Change $(COMPILER) to $(LINKER).
	(cc1plus-dummy$(exeext), cc1plus$(exeext)): Likewise.

gcc/fortran/ChangeLog:

2009-05-26  Ian Lance Taylor  <iant@google.com>

	* Make-lang.in (gfortran$(exeext)): Change $(COMPILER) to
	$(LINKER).
	(f951$(exeext)): Likewise.

gcc/java/ChangeLog:

2009-05-26  Ian Lance Taylor  <iant@google.com>

	* Make-lang.in ($(XGCJ)$(exeext)): Change $(COMPILER) to
	$(LINKER).
	(jc1$(exeext), jcf-dump$(exeext), jvgenmain$(exeext)): Likewise.

gcc/objc/ChangeLog:

2009-05-26  Ian Lance Taylor  <iant@google.com>

	* Make-lang.in (cc1obj-dummy$(exeext)): Change $(COMPILER) to
	$(LINKER).
	(cc1obj$(exeext)): Likewise.

gcc/objcp/ChangeLog:

2009-05-26  Ian Lance Taylor  <iant@google.com>

	* Make-lang.in (cc1objplus-dummy$(exeext)): Change $(COMPILER) to
	$(LINKER).
	(cc1objplus$(exeext)): Likewise.


Index: gcc/java/Make-lang.in
===================================================================
--- gcc/java/Make-lang.in	(revision 147873)
+++ gcc/java/Make-lang.in	(working copy)
@@ -65,7 +65,7 @@ jvspec.o: $(srcdir)/java/jvspec.c $(SYST
 # Create the compiler driver for $(XGCJ).
 $(XGCJ)$(exeext): $(GCC_OBJS) jvspec.o java/jcf-path.o version.o \
 	   prefix.o intl.o $(LIBDEPS) $(EXTRA_GCC_OBJS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \
 	  jvspec.o java/jcf-path.o prefix.o intl.o \
 	  version.o $(EXTRA_GCC_OBJS) $(LIBS)
 
@@ -100,17 +100,17 @@ jvspec.o-warn = -Wno-error
 
 jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(LIBDEPS) attribs.o
 	rm -f $@
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 		$(JAVA_OBJS) $(BACKEND) $(ZLIB) $(LIBICONV) $(LIBS) attribs.o $(BACKENDLIBS)
 
 jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIBDEPS)
 	rm -f $@
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ $(JCFDUMP_OBJS) \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(JCFDUMP_OBJS) \
 		$(CPPLIBS) $(ZLIB) $(LDEXP_LIB) $(LIBS)
 
 jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS)
 	rm -f $@
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) \
 		$(LIBS)
 
 #
Index: gcc/objc/Make-lang.in
===================================================================
--- gcc/objc/Make-lang.in	(revision 147873)
+++ gcc/objc/Make-lang.in	(working copy)
@@ -52,7 +52,7 @@ OBJC_OBJS = objc/objc-lang.o objc/objc-a
 objc_OBJS = $(OBJC_OBJS) cc1obj-checksum.o
 
 cc1obj-dummy$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) dummy-checksum.o $(BACKEND) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 	      $(OBJC_OBJS) $(C_AND_OBJC_OBJS) dummy-checksum.o \
 	      $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
@@ -62,7 +62,7 @@ cc1obj-checksum.c : cc1obj-dummy$(exeext
 cc1obj-checksum.o : cc1obj-checksum.c
 
 cc1obj$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o $(BACKEND) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 	      $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o \
 	      $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
Index: gcc/objcp/Make-lang.in
===================================================================
--- gcc/objcp/Make-lang.in	(revision 147873)
+++ gcc/objcp/Make-lang.in	(working copy)
@@ -55,7 +55,7 @@ obj-c++_OBJS = $(OBJCXX_OBJS) cc1objplus
 
 cc1objplus-dummy$(exeext): $(OBJCXX_OBJS) dummy-checksum.o $(BACKEND) \
 		$(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 		$(OBJCXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
 cc1objplus-checksum.c : cc1objplus-dummy$(exeext) build/genchecksum$(build_exeext)
@@ -64,7 +64,7 @@ cc1objplus-checksum.c : cc1objplus-dummy
 cc1objplus-checksum.o : cc1objplus-checksum.c
 
 cc1objplus$(exeext): $(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 		$(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
 # Objective C++ language specific files.
Index: gcc/cp/Make-lang.in
===================================================================
--- gcc/cp/Make-lang.in	(revision 147873)
+++ gcc/cp/Make-lang.in	(working copy)
@@ -60,7 +60,7 @@ g++spec.o: $(srcdir)/cp/g++spec.c $(SYST
 # Create the compiler driver for g++.
 GXX_OBJS = $(GCC_OBJS) g++spec.o intl.o prefix.o version.o
 g++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 	  $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
 
 # Create a version of the g++ driver which calls the cross-compiler.
@@ -92,7 +92,7 @@ c++_OBJS = $(CXX_OBJS) dummy-checksum.o 
 cp-warn = $(STRICT_WARN)
 
 cc1plus-dummy$(exeext): $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 	      $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
 cc1plus-checksum.c : cc1plus-dummy$(exeext) build/genchecksum$(build_exeext)
@@ -101,7 +101,7 @@ cc1plus-checksum.c : cc1plus-dummy$(exee
 cc1plus-checksum.o : cc1plus-checksum.c
 
 cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 	      $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
 # Special build rules.
Index: gcc/fortran/Make-lang.in
===================================================================
--- gcc/fortran/Make-lang.in	(revision 147873)
+++ gcc/fortran/Make-lang.in	(working copy)
@@ -86,7 +86,7 @@ gfortranspec.o: $(srcdir)/fortran/gfortr
 # Create the compiler driver gfortran.
 GFORTRAN_D_OBJS = $(GCC_OBJS) gfortranspec.o version.o prefix.o intl.o
 gfortran$(exeext): $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 	  $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
 
 # Create a version of the gfortran driver which calls the cross-compiler.
@@ -97,7 +97,7 @@ gfortran-cross$(exeext): gfortran$(exeex
 # The compiler itself is called f951.
 f951$(exeext): $(F95_OBJS) \
 		$(BACKEND) $(LIBDEPS) attribs.o
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 		$(F95_OBJS) $(BACKEND) $(LIBS) attribs.o $(BACKENDLIBS)
 
 gt-fortran-trans.h    : s-gtype; @true
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 147873)
+++ gcc/Makefile.in	(working copy)
@@ -201,6 +201,8 @@ RANLIB_FLAGS = @ranlib_flags@
 # future this may change to $(CXX).
 COMPILER = $(CC)
 COMPILER_FLAGS = $(CFLAGS)
+LINKER = $(CC)
+LINKER_FLAGS = $(CFLAGS)
 
 # -------------------------------------------
 # Programs which operate on the build machine
@@ -707,6 +709,10 @@ BUILD_CFLAGS= @BUILD_CFLAGS@ -DGENERATOR
 COMPILER_FOR_BUILD = $(CC_FOR_BUILD)
 BUILD_COMPILERFLAGS = $(BUILD_CFLAGS)
 
+# Native linker that we use.
+LINKER_FOR_BUILD = $(CC_FOR_BUILD)
+BUILD_LINKERFLAGS = $(BUILD_CFLAGS)
+
 # Native linker and preprocessor flags.  For x-fragment overrides.
 BUILD_LDFLAGS=@BUILD_LDFLAGS@
 BUILD_CPPFLAGS=$(ALL_CPPFLAGS)
@@ -918,6 +924,9 @@ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
 # This is the variable to use when using $(COMPILER).
 ALL_COMPILERFLAGS = $(ALL_CFLAGS)
 
+# This is the variable to use when using $(LINKER).
+ALL_LINKERFLAGS = $(ALL_CFLAGS)
+
 # Build and host support libraries.
 LIBIBERTY = ../libiberty/libiberty.a
 BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
@@ -1639,7 +1648,7 @@ libbackend.a: $(OBJS@onestep@)
 # and CC is `gcc'.  It is renamed to `gcc' when it is installed.
 xgcc$(exeext): $(GCC_OBJS) gccspec.o version.o intl.o prefix.o \
    version.o $(LIBDEPS) $(EXTRA_GCC_OBJS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \
 	  gccspec.o intl.o prefix.o version.o $(EXTRA_GCC_OBJS) $(LIBS)
 
 # cpp is to cpp0 as gcc is to cc1.
@@ -1647,7 +1656,7 @@ xgcc$(exeext): $(GCC_OBJS) gccspec.o ver
 # instead of gccspec.o.
 cpp$(exeext): $(GCC_OBJS) cppspec.o version.o intl.o prefix.o \
    version.o $(LIBDEPS) $(EXTRA_GCC_OBJS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \
 	  cppspec.o intl.o prefix.o version.o $(EXTRA_GCC_OBJS) $(LIBS)
 
 # Dump a specs file to make -B./ read these specs over installed ones.
@@ -1664,7 +1673,7 @@ gcc-cross$(exeext): xgcc$(exeext)
 dummy-checksum.o : dummy-checksum.c
 
 cc1-dummy$(exeext): $(C_OBJS) dummy-checksum.o $(BACKEND) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \
 	  dummy-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
 cc1-checksum.c : cc1-dummy$(exeext) build/genchecksum$(build_exeext)
@@ -1673,7 +1682,7 @@ cc1-checksum.c : cc1-dummy$(exeext) buil
 cc1-checksum.o : cc1-checksum.c
 
 cc1$(exeext): $(C_OBJS) cc1-checksum.o $(BACKEND) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \
 	  cc1-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
 #
@@ -1890,7 +1899,7 @@ COLLECT2_OBJS = collect2.o tlink.o intl.
 COLLECT2_LIBS = @COLLECT2_LIBS@
 collect2$(exeext): $(COLLECT2_OBJS) $(LIBDEPS)
 # Don't try modifying collect2 (aka ld) in place--it might be linking this.
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o T$@ \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o T$@ \
 		$(COLLECT2_OBJS) $(LIBS) $(COLLECT2_LIBS)
 	mv -f T$@ $@
 
@@ -3117,14 +3126,14 @@ $(out_object_file): $(out_file) $(CONFIG
 
 # Build auxiliary files that support ecoff format.
 mips-tfile: mips-tfile.o version.o $(LIBDEPS)
-	$(COMPILER) $(COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(LINKERFLAGS) $(LDFLAGS) -o $@ \
 		mips-tfile.o version.o $(LIBS)
 
 mips-tfile.o : mips-tfile.c $(CONFIG_H) $(RTL_H) $(SYSTEM_H) coretypes.h \
    $(TM_H) version.h $(srcdir)/../include/getopt.h $(GSTAB_H) intl.h
 
 mips-tdump: mips-tdump.o version.o $(LIBDEPS)
-	$(COMPILER) $(COMPILERFLAGS) $(LDFLAGS) -o $@ \
+	$(LINKER) $(LINKERFLAGS) $(LDFLAGS) -o $@ \
 		mips-tdump.o version.o $(LIBS)
 
 mips-tdump.o : mips-tdump.c $(CONFIG_H) $(RTL_H) $(SYSTEM_H) coretypes.h \
@@ -3490,7 +3499,7 @@ build/genrecog.o : genrecog.c $(RTL_BASE
 
 # As a general rule...
 build/gen%$(build_exeext): build/gen%.o $(BUILD_LIBDEPS)
-	$(COMPILER_FOR_BUILD) $(BUILD_COMPILERFLAGS) $(BUILD_LDFLAGS) -o $@ \
+	$(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ \
 	    $(filter-out $(BUILD_LIBDEPS), $^) $(BUILD_LIBS)
 
 # All these programs use the MD reader ($(BUILD_RTL)).
@@ -3548,7 +3557,7 @@ build/gcov-iov.o: gcov-iov.c $(BCONFIG_H
   $(SYSTEM_H) coretypes.h $(TM_H)
 
 build/gcov-iov$(build_exeext): build/gcov-iov.o
-	$(COMPILER_FOR_BUILD) $(BUILD_COMPILERFLAGS) $(BUILD_LDFLAGS) \
+	$(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) \
 		build/gcov-iov.o -o $@
 
 gcov-iov.h: s-iov
@@ -3565,10 +3574,10 @@ gcov-dump.o: gcov-dump.c gcov-io.c $(GCO
 
 GCOV_OBJS = gcov.o intl.o version.o errors.o
 gcov$(exeext): $(GCOV_OBJS) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) $(GCOV_OBJS) $(LIBS) -o $@
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) $(GCOV_OBJS) $(LIBS) -o $@
 GCOV_DUMP_OBJS = gcov-dump.o version.o errors.o
 gcov-dump$(exeext): $(GCOV_DUMP_OBJS) $(LIBDEPS)
-	$(COMPILER) $(ALL_COMPILERFLAGS) $(LDFLAGS) $(GCOV_DUMP_OBJS) \
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) $(GCOV_DUMP_OBJS) \
 		$(LIBS) -o $@
 #
 # Build the include directories.  The stamp files are stmp-* rather than

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