public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR ada/42254, avoid providing multiple copies of object files to link of GNAT tools
@ 2010-01-26 21:30 Simon Wright
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Wright @ 2010-01-26 21:30 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2198 bytes --]

This is a corrected re-post of an earlier patch, posted 11 Jan, titled just "[Ada] Avoid providing multiple copies of object files to link of GNAT tools".

gcc/ada/gcc-interface/Makefile.in provides the linker with multiple
copies of object files (those in the RTS), in two cases by explicitly
listing them (macros GNATLINK_OBJS, GNATMAKE_OBJS) and then
linking against LIBGNAT and in the others (target common-tools) by 
leaving .o files in the RTS directory for gnatbind to see and use and 
by calling up LIBGNAT twice (by including LIBGNAT in macro 
TOOLS_LIBS when it is implicitly included by gnatbind already).

This is legal if unnecessary behaviour, I think, but in Xcode 3.2
(used in darwin10, Snow Leopard) Apple have introduced a bug (radar
6320843 "duplicate symbols from static libraries not properly
ignored") which prevents building any of the GNAT tools.

Other languages have had similar though less pervasive problems, see
PR bootstrap/41180.

The only part of this patch you may be uncomfortable with is the change to target common-tools, where I delete all the .o files in the RTS directory that are already in libgna*.a before the gnatmake -b step (the problem being that if gnatbind sees a .o file it includes it in the files to be linked, being unaware that the object is already in libgna*.a). The .o files that survive are g-trasym.o and (on powerpc-wrs-vxworks) memtrack.o - but the latter doesn't get installed.

Tested on x86_64-apple-darwin10, x86_64-unknown-linux-gnu [Debian 5, I didn't say --build= which may explain the -unknown- ?] and powerpc-wrs-vxworks hosted on i386-apple-darwin10.

2010-01-26  Simon Wright  <simon@pushface.org>

	PR ada/42554
	* gcc-interface/Makefile.in (TOOLS_LIBS): remove LIB_GNAT.
	* gcc-interface/Makefile.in (GNATLINK_OBJS): remove object files
	that are present in the RTS.
	* gcc-interface/Makefile.in (GNATMAKE_OBJS): likewise.
	* gcc-interface/Makefile.in (common-tools): at the start, delete
	all the .o files in the RTS directory that are also in libraries.
	* gcc-interface/Makefile.in (../../gnatmake$(exeext)): add LIBGNAT.
	* gcc-interface/Makefile.in (../../gnatlink$(exeext)):likewise.


[-- Attachment #2: gcc-ada-gcc-interface-Makefile.in.diff --]
[-- Type: application/octet-stream, Size: 4877 bytes --]

Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in	(revision 156260)
+++ gcc/ada/gcc-interface/Makefile.in	(working copy)
@@ -241,7 +241,7 @@
 LIBDEPS = $(LIBINTL_DEP) $(LIBIBERTY)
 # Default is no TGT_LIB; one might be passed down or something
 TGT_LIB =
-TOOLS_LIBS = $(EXTRA_GNATTOOLS_OBJS) targext.o link.o $(LIBGNAT) ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB)
+TOOLS_LIBS = $(EXTRA_GNATTOOLS_OBJS) targext.o link.o ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB)
 
 # Specify the directories to be searched for header files.
 # Both . and srcdir are used, in that order,
@@ -289,29 +289,28 @@
 \f
 # Lists of files for various purposes.
 
-GNATLINK_OBJS = gnatlink.o \
- a-except.o ali.o alloc.o butil.o casing.o csets.o debug.o fmap.o fname.o \
- gnatvsn.o hostparm.o indepsw.o interfac.o i-c.o i-cstrin.o namet.o opt.o \
- osint.o output.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
- sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o tree_io.o \
- types.o validsw.o widechar.o
+# GNATLINK_OBJS, GNATMAKE_OBJS shouldn't contain any objects which are
+# part of the RTS.
 
-GNATMAKE_OBJS = a-except.o ali.o ali-util.o s-casuti.o \
- alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o\
- erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o \
- gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o \
- make.o makeusg.o makeutl.o mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o \
- mlib-tgt-specific.o mlib-utl.o namet.o nlists.o opt.o osint.o osint-m.o \
- output.o prj.o prj-attr.o prj-attr-pm.o prj-com.o prj-dect.o prj-env.o \
- prj-conf.o prj-pp.o \
- prj-err.o prj-ext.o prj-nmsc.o prj-pars.o prj-part.o prj-proc.o prj-strt.o \
- prj-tree.o prj-util.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
- scans.o scng.o sdefault.o sfn_scan.o s-purexc.o s-htable.o sinfo.o sinput.o \
- sinput-c.o sinput-p.o snames.o stand.o stringt.o styleg.o stylesw.o system.o \
- validsw.o switch.o switch-m.o table.o targparm.o tempdir.o tree_io.o types.o \
- uintp.o uname.o urealp.o usage.o widechar.o \
- $(EXTRA_GNATMAKE_OBJS)
+GNATLINK_OBJS = gnatlink.o ali.o alloc.o butil.o casing.o csets.o	\
+ debug.o fmap.o fname.o gnatvsn.o hostparm.o indepsw.o namet.o opt.o	\
+ osint.o output.o rident.o sdefault.o snames.o stylesw.o switch.o	\
+ table.o targparm.o tree_io.o types.o validsw.o widechar.o
 
+GNATMAKE_OBJS = ali.o ali-util.o alloc.o atree.o binderr.o butil.o	\
+ casing.o csets.o debug.o elists.o einfo.o erroutc.o errutil.o		\
+ err_vars.o fmap.o fname.o fname-uf.o fname-sf.o gnatmake.o gnatvsn.o	\
+ hostparm.o krunch.o lib.o make.o makeusg.o makeutl.o mlib.o		\
+ mlib-fil.o mlib-prj.o mlib-tgt.o mlib-tgt-specific.o mlib-utl.o	\
+ namet.o nlists.o opt.o osint.o osint-m.o output.o prj.o prj-attr.o	\
+ prj-attr-pm.o prj-com.o prj-dect.o prj-env.o prj-conf.o prj-pp.o	\
+ prj-err.o prj-ext.o prj-nmsc.o prj-pars.o prj-part.o prj-proc.o	\
+ prj-strt.o prj-tree.o prj-util.o rident.o scans.o scng.o sdefault.o	\
+ sfn_scan.o sinfo.o sinput.o sinput-c.o sinput-p.o snames.o stand.o	\
+ stringt.o styleg.o stylesw.o validsw.o switch.o switch-m.o table.o	\
+ targparm.o tempdir.o tree_io.o types.o uintp.o uname.o urealp.o	\
+ usage.o widechar.o $(EXTRA_GNATMAKE_OBJS)
+
 # Convert the target variable into a space separated list of architecture,
 # manufacturer, and operating system and assign each of those to its own
 # variable.
@@ -2256,7 +2255,16 @@
   vpath %.h   ../
 endif
 
+# Remove the extra object files from the RTS directory first - by now
+# we have built both static and dynamic libraries, and leaving the
+# .o's confuses the Mac OS X linker in Xcode 3.2.
 common-tools:
+	$(RM) $(addprefix ../$(RTSDIR)/,$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS))
+	$(RM) $(addprefix ../$(RTSDIR)/,$(GNATRTL_TASKING_OBJS))
+	$(RM) $(addprefix ../$(RTSDIR)/,$(GNATRTL_LINEARALGEBRA_OBJS))
+        ifeq ($(GMEM_LIB),gmemlib)
+		$(RM) ../$(RTSDIR)/memtrack.o
+        endif
 	$(GNATMAKE) -c -b $(ADA_INCLUDES) \
 	  --GNATBIND="$(GNATBIND)" --GCC="$(CC) $(ALL_ADAFLAGS)" \
 	  gnatchop gnatcmd gnatkr gnatls gnatprep gnatxref gnatfind gnatname \
@@ -2318,11 +2326,11 @@
 # Likewise for the tools
 ../../gnatmake$(exeext): $(P) b_gnatm.o link.o targext.o $(GNATMAKE_OBJS)
 	$(GCC_LINK) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) \
-		    $(TOOLS_LIBS)
+		    $(TOOLS_LIBS) $(LIBGNAT)
 
 ../../gnatlink$(exeext): $(P) b_gnatl.o link.o targext.o $(GNATLINK_OBJS)
 	$(GCC_LINK) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatl.o $(GNATLINK_OBJS) \
-		    $(TOOLS_LIBS)
+		    $(TOOLS_LIBS) $(LIBGNAT)
 
 ../stamp-gnatlib-$(RTSDIR):
 	@if [ ! -f stamp-gnatlib-$(RTSDIR) ] ; \

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of  object files to link of GNAT tools
  2010-02-01  7:23             ` Arnaud Charlet
@ 2010-02-03  6:59               ` Simon Wright
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Wright @ 2010-02-03  6:59 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: gcc-patches

Thanks for all your help on this one.

Following further investigations at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42554 (NB that _is_ the right PR, I made a mistake in the Subject: of this thread) it now seems that the root cause is a change in the behaviour of Apple's ranlib -c.

I've run check-ada, no unexpected failures.

So this patch is withdrawn per se. Parts of it (tidying up the objects/libraries passed to the build of gnatmake/gnatlink) are still valid but not essential.

--S

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of  object files to link of GNAT tools
  2010-01-31 22:54           ` Simon Wright
@ 2010-02-01  7:23             ` Arnaud Charlet
  2010-02-03  6:59               ` Simon Wright
  0 siblings, 1 reply; 12+ messages in thread
From: Arnaud Charlet @ 2010-02-01  7:23 UTC (permalink / raw)
  To: Simon Wright; +Cc: gcc-patches

> Anyway, in the interests of at least being able to build the compiler, I've tested 
> on x86_64-apple-darwin10, i686-apple-darwin10, x86_64-unknown-linux-gnu 
> [Debian 5] and powerpc-wrs-vxworks hosted on i686-apple-darwin10.

You've broken this line:

-TEXI2PDF = texi2pdf
+EXI2PDF = texi2pdf

Also, you've duplicated the same comment in two places, which is not
desirable.

And you mention that the dummy setting of TOOLS_GNATLIBC and TOOLS_NOSTDLIB
is for darwin only. Would be better to document in a general way how/when
these variables should be set.

> 2010-01-31  Simon Wright  <simon@pushface.org>
> 	PR ada/42554
> 	* gcc-interface/Makefile.in (TOOLS_LIBS, GNATLINK_OBJS, 
> 	GNATMAKE_OBJS, common-tools, ../../gnatmake$(exeext), 
> 	../../gnatlink$(exeext), gnatmake-re, gnatlink-re): on 
> 	Darwin, ensure that the linker only sees each object file 
> 	once.

Arno

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of  object files to link of GNAT tools
  2010-01-29  9:17         ` Arnaud Charlet
@ 2010-01-31 22:54           ` Simon Wright
  2010-02-01  7:23             ` Arnaud Charlet
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Wright @ 2010-01-31 22:54 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1311 bytes --]

On 29 Jan 2010, at 07:54, Arnaud Charlet wrote:

>>> Changing NOSTDLIB to TOOLS_NOSTDLIB also seems like a good idea.
>> 
>> OK (and I'll set it to empty at the top).

I've also changed GNATLIBC to TOOLS_GNATLIBC.

> Assuming your build/testing goes fine with these changes, this is OK, although
> I don't think it's a good idea to make these changes now (so late in the
> build process), since it's not a regression, and the change has some non
> negligible chances of breaking existing builds/ports.
> 
> So I'd suggest committing this change on trunk after 4.5 is branched, and
> possibly consider backporting the change if it does not cause troubles
> on trunk.

Your call, of course!

I have now discovered that 'make check' triggers the same bug.

Anyway, in the interests of at least being able to build the compiler, I've tested 
on x86_64-apple-darwin10, i686-apple-darwin10, x86_64-unknown-linux-gnu 
[Debian 5] and powerpc-wrs-vxworks hosted on i686-apple-darwin10.

2010-01-31  Simon Wright  <simon@pushface.org>
	PR ada/42554
	* gcc-interface/Makefile.in (TOOLS_LIBS, GNATLINK_OBJS, 
	GNATMAKE_OBJS, common-tools, ../../gnatmake$(exeext), 
	../../gnatlink$(exeext), gnatmake-re, gnatlink-re): on 
	Darwin, ensure that the linker only sees each object file 
	once.


[-- Attachment #2: gcc-ada-gcc-interface-Makefile.in.diff --]
[-- Type: application/octet-stream, Size: 9236 bytes --]

Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in	(revision 156398)
+++ gcc/ada/gcc-interface/Makefile.in	(working copy)
@@ -101,7 +101,7 @@
 INSTALL_DATA_DATE = cp -p
 MAKEINFO = makeinfo
 TEXI2DVI = texi2dvi
-TEXI2PDF = texi2pdf
+EXI2PDF = texi2pdf
 GNATBIND_FLAGS = -static -x
 ADA_CFLAGS =
 ADAFLAGS = -W -Wall -gnatpg -gnata
@@ -123,6 +123,10 @@
 SYMDEPS = $(LIBINTL_DEP)
 OUTPUT_OPTION = @OUTPUT_OPTION@
 
+# These two for Darwin only
+TOOLS_LIBGNATC =
+TOOLS_NOSTDLIB =
+
 objext = .o
 exeext =
 arext  = .a
@@ -241,7 +245,7 @@
 LIBDEPS = $(LIBINTL_DEP) $(LIBIBERTY)
 # Default is no TGT_LIB; one might be passed down or something
 TGT_LIB =
-TOOLS_LIBS = $(EXTRA_GNATTOOLS_OBJS) targext.o link.o $(LIBGNAT) ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB)
+TOOLS_LIBS = $(EXTRA_GNATTOOLS_OBJS) targext.o link.o ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB)
 
 # Specify the directories to be searched for header files.
 # Both . and srcdir are used, in that order,
@@ -289,29 +293,28 @@
 \f
 # Lists of files for various purposes.
 
-GNATLINK_OBJS = gnatlink.o \
- a-except.o ali.o alloc.o butil.o casing.o csets.o debug.o fmap.o fname.o \
- gnatvsn.o hostparm.o indepsw.o interfac.o i-c.o i-cstrin.o namet.o opt.o \
- osint.o output.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
- sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o tree_io.o \
- types.o validsw.o widechar.o
+# GNATLINK_OBJS, GNATMAKE_OBJS shouldn't contain any objects which are
+# part of the RTS.
 
-GNATMAKE_OBJS = a-except.o ali.o ali-util.o s-casuti.o \
- alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o\
- erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o \
- gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o \
- make.o makeusg.o makeutl.o mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o \
- mlib-tgt-specific.o mlib-utl.o namet.o nlists.o opt.o osint.o osint-m.o \
- output.o prj.o prj-attr.o prj-attr-pm.o prj-com.o prj-dect.o prj-env.o \
- prj-conf.o prj-pp.o \
- prj-err.o prj-ext.o prj-nmsc.o prj-pars.o prj-part.o prj-proc.o prj-strt.o \
- prj-tree.o prj-util.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
- scans.o scng.o sdefault.o sfn_scan.o s-purexc.o s-htable.o sinfo.o sinput.o \
- sinput-c.o sinput-p.o snames.o stand.o stringt.o styleg.o stylesw.o system.o \
- validsw.o switch.o switch-m.o table.o targparm.o tempdir.o tree_io.o types.o \
- uintp.o uname.o urealp.o usage.o widechar.o \
- $(EXTRA_GNATMAKE_OBJS)
+GNATLINK_OBJS = gnatlink.o ali.o alloc.o butil.o casing.o csets.o	\
+ debug.o fmap.o fname.o gnatvsn.o hostparm.o indepsw.o namet.o opt.o	\
+ osint.o output.o rident.o sdefault.o snames.o stylesw.o switch.o	\
+ table.o targparm.o tree_io.o types.o validsw.o widechar.o
 
+GNATMAKE_OBJS = ali.o ali-util.o alloc.o atree.o binderr.o butil.o	\
+ casing.o csets.o debug.o elists.o einfo.o erroutc.o errutil.o		\
+ err_vars.o fmap.o fname.o fname-uf.o fname-sf.o gnatmake.o gnatvsn.o	\
+ hostparm.o krunch.o lib.o make.o makeusg.o makeutl.o mlib.o		\
+ mlib-fil.o mlib-prj.o mlib-tgt.o mlib-tgt-specific.o mlib-utl.o	\
+ namet.o nlists.o opt.o osint.o osint-m.o output.o prj.o prj-attr.o	\
+ prj-attr-pm.o prj-com.o prj-dect.o prj-env.o prj-conf.o prj-pp.o	\
+ prj-err.o prj-ext.o prj-nmsc.o prj-pars.o prj-part.o prj-proc.o	\
+ prj-strt.o prj-tree.o prj-util.o rident.o scans.o scng.o sdefault.o	\
+ sfn_scan.o sinfo.o sinput.o sinput-c.o sinput-p.o snames.o stand.o	\
+ stringt.o styleg.o stylesw.o validsw.o switch.o switch-m.o table.o	\
+ targparm.o tempdir.o tree_io.o types.o uintp.o uname.o urealp.o	\
+ usage.o widechar.o $(EXTRA_GNATMAKE_OBJS)
+
 # Convert the target variable into a space separated list of architecture,
 # manufacturer, and operating system and assign each of those to its own
 # variable.
@@ -2169,6 +2172,16 @@
   LIBRARY_VERSION := $(LIB_VERSION)
   soext = .dylib
   GCC_LINK_FLAGS=
+  # The common-tools target is built in ../tools against the RTS
+  # directory, which contains both .o files and the corresponding
+  # static (and maybe dynamic) libraries. Allowing the Mac OS X linker
+  # in Xcode 3.2 to see both confuses it, so we use -nostdlib; but we
+  # do need the C-derived objects too, so we build a (local) library
+  # in ../tools for them first.
+  # We only need this trick for common-tools (at least, until there
+  # are extra tools for Mac OS X).
+  TOOLS_LIBGNATC = libgnatc$(arext)
+  TOOLS_NOSTDLIB = -nostdlib
 endif
 
 ifneq ($(EH_MECHANISM),)
@@ -2256,30 +2269,44 @@
   vpath %.h   ../
 endif
 
-common-tools:
+# We build against the RTS directory, which contains both .o files and
+# the corresponding static (and maybe dynamic) libraries. Allowing the
+# Mac OS X linker in Xcode 3.2 to see both confuses it, so we use
+# -nostdlib; but we do need the C-derived objects too, so we build a
+# (local) library for them first.
+# We only need this trick for common-tools and Darwin (at least, until
+# there are extra tools for Mac OS X).
+common-tools: $(TOOLS_LIBGNATC)
 	$(GNATMAKE) -c -b $(ADA_INCLUDES) \
 	  --GNATBIND="$(GNATBIND)" --GCC="$(CC) $(ALL_ADAFLAGS)" \
 	  gnatchop gnatcmd gnatkr gnatls gnatprep gnatxref gnatfind gnatname \
-	  gnatclean -bargs $(ADA_INCLUDES) $(GNATBIND_FLAGS)
+	  gnatclean -bargs $(ADA_INCLUDES) $(GNATBIND_FLAGS) $(TOOLS_NOSTDLIB)
 	$(GNATLINK) -v gnatcmd -o ../../gnat$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 	$(GNATLINK) -v gnatchop -o ../../gnatchop$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 	$(GNATLINK) -v gnatkr -o ../../gnatkr$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 	$(GNATLINK) -v gnatls -o ../../gnatls$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 	$(GNATLINK) -v gnatprep -o ../../gnatprep$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 	$(GNATLINK) -v gnatxref -o ../../gnatxref$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 	$(GNATLINK) -v gnatfind -o ../../gnatfind$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 	$(GNATLINK) -v gnatname -o ../../gnatname$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 	$(GNATLINK) -v gnatclean -o ../../gnatclean$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 
+# This library, built in ../tools, contains the C-derived objects in
+# the RTS. Darwin native only.
+libgnatc$(arext):
+	$(AR_FOR_TARGET) $(AR_FLAGS) $@ \
+	   $(addprefix ../$(RTSDIR)/,$(LIBGNAT_OBJS))
+	$(RANLIB_FOR_TARGET) $@
+
 ../../gnatsym$(exeext): 
 	$(GNATMAKE) -c $(ADA_INCLUDES) gnatsym --GCC="$(CC) $(ALL_ADAFLAGS)"
 	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatsym
@@ -2295,20 +2322,20 @@
 	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) vxaddr2line
 	$(GNATLINK) -v vxaddr2line -o $@ --GCC="$(GCC_LINK)" targext.o $(CLIB)
 
-gnatmake-re:  link.o targext.o
+gnatmake-re:  link.o targext.o $(TOOLS_LIBGNATC)
 	$(GNATMAKE) $(ADA_INCLUDES) -u sdefault --GCC="$(CC) $(MOST_ADA_FLAGS)"
 	$(GNATMAKE) -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) $(ALL_ADAFLAGS)"
-	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatmake
+	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) $(TOOLS_NOSTDLIB) gnatmake
 	$(GNATLINK) -v gnatmake -o ../../gnatmake$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 
 # Note the use of the "mv" command in order to allow gnatlink to be linked with
 # with the former version of gnatlink itself which cannot override itself.
-gnatlink-re:  link.o targext.o
+gnatlink-re:  link.o targext.o $(TOOLS_LIBGNATC)
 	$(GNATMAKE) -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) $(ALL_ADAFLAGS)"
-	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatlink
+	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) $(TOOLS_NOSTDLIB) gnatlink
 	$(GNATLINK) -v gnatlink -o ../../gnatlinknew$(exeext) \
-		    --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		    --GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(TOOLS_LIBGNATC)
 	$(MV)  ../../gnatlinknew$(exeext)  ../../gnatlink$(exeext)
 
 # Needs to be built with CC=gcc
@@ -2318,11 +2345,11 @@
 # Likewise for the tools
 ../../gnatmake$(exeext): $(P) b_gnatm.o link.o targext.o $(GNATMAKE_OBJS)
 	$(GCC_LINK) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) \
-		    $(TOOLS_LIBS)
+		    $(TOOLS_LIBS) $(LIBGNAT)
 
 ../../gnatlink$(exeext): $(P) b_gnatl.o link.o targext.o $(GNATLINK_OBJS)
 	$(GCC_LINK) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatl.o $(GNATLINK_OBJS) \
-		    $(TOOLS_LIBS)
+		    $(TOOLS_LIBS) $(LIBGNAT)
 
 ../stamp-gnatlib-$(RTSDIR):
 	@if [ ! -f stamp-gnatlib-$(RTSDIR) ] ; \

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of  object files to link of GNAT tools
  2010-01-28 22:52       ` Simon Wright
@ 2010-01-29  9:17         ` Arnaud Charlet
  2010-01-31 22:54           ` Simon Wright
  0 siblings, 1 reply; 12+ messages in thread
From: Arnaud Charlet @ 2010-01-29  9:17 UTC (permalink / raw)
  To: Simon Wright; +Cc: gcc-patches

> The problem I see with that is that TOOLS_LIBS is used elsewhere - 
> specifically in the targets ../../gnatmake$(exeext), ../../gnatlink$(exeext). 
> These two use the gnatbind -C option and ignore the object file/option 
> list, instead using GNATMAKE_OBJS for the local files, TOOLS_LIBS, 
> and LIBGNAT for the RTS files. So we'd be back where we started from. 
> Also, not clear where to put the dependency that causes libgnatc$(arext) 
> to be built.

OK, let's skip this idea for now then.

> > Changing NOSTDLIB to TOOLS_NOSTDLIB also seems like a good idea.
> 
> OK (and I'll set it to empty at the top).

Assuming your build/testing goes fine with these changes, this is OK, although
I don't think it's a good idea to make these changes now (so late in the
build process), since it's not a regression, and the change has some non
negligible chances of breaking existing builds/ports.

So I'd suggest committing this change on trunk after 4.5 is branched, and
possibly consider backporting the change if it does not cause troubles
on trunk.

Arno

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of object files to link of GNAT tools
  2010-01-28  9:39     ` Arnaud Charlet
@ 2010-01-28 22:52       ` Simon Wright
  2010-01-29  9:17         ` Arnaud Charlet
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Wright @ 2010-01-28 22:52 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: gcc-patches

On 28 Jan 2010, at 07:46, Arnaud Charlet wrote:

>> New strategy: in Darwin only, arrange that common-tools are built using 
>> -nostdlib and a new temporary ada/tools/libgnatc.a which contains only 
>> the C-derived objects from the RTS. This means that the binder will call 
>> in the required Ada-derived objects from the RTS and will fnd the C 
>> objects in the library; and that the RTS directory itself remains untouched.
>> 
>> There are 2 new variables NOSTDLIB and LIBGNATC and I only set them 
>> in the "ifeq ($(strip $(filter-out darwin%,$(osys))),)" section. You may want 
>> the names to be more specific (TOOLS_NOSTDLIB) and/or to be set 
>> explicitly to empty (NOSTDLIB=) at the top?
> 
> That's better, although I think you could reuse TOOLS_LIBS instead of
> defining and using LIBGNATC everywhere.

I define it once (twice, if I default it to empty at the top) and use it only in 
common-tools (I think I should use it in gnatmake-re, gnatlink-re too - 
yes, I should!).

> e.g. in the darwin section use something like:
> 
>  TOOLS_LIBS=$(TOOLS_LIBS) libgnatc$(arext)

The problem I see with that is that TOOLS_LIBS is used elsewhere - 
specifically in the targets ../../gnatmake$(exeext), ../../gnatlink$(exeext). 
These two use the gnatbind -C option and ignore the object file/option 
list, instead using GNATMAKE_OBJS for the local files, TOOLS_LIBS, 
and LIBGNAT for the RTS files. So we'd be back where we started from. 
Also, not clear where to put the dependency that causes libgnatc$(arext) 
to be built.

> This would make the change simpler/lighter for non darwin platforms

If it can be done (I will try) it would be simpler, but since my current 
proposal requires no change at all for other platforms (something I was 
trying hard to avoid) I don't see how it would be lighter for them?

> Changing NOSTDLIB to TOOLS_NOSTDLIB also seems like a good idea.

OK (and I'll set it to empty at the top).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of object  files to link of GNAT tools
  2010-01-28  6:07   ` Simon Wright
@ 2010-01-28  9:39     ` Arnaud Charlet
  2010-01-28 22:52       ` Simon Wright
  0 siblings, 1 reply; 12+ messages in thread
From: Arnaud Charlet @ 2010-01-28  9:39 UTC (permalink / raw)
  To: Simon Wright; +Cc: gcc-patches

> New strategy: in Darwin only, arrange that common-tools are built using 
> -nostdlib and a new temporary ada/tools/libgnatc.a which contains only 
> the C-derived objects from the RTS. This means that the binder will call 
> in the required Ada-derived objects from the RTS and will fnd the C 
> objects in the library; and that the RTS directory itself remains untouched.
> 
> There are 2 new variables NOSTDLIB and LIBGNATC and I only set them 
> in the "ifeq ($(strip $(filter-out darwin%,$(osys))),)" section. You may want 
> the names to be more specific (TOOLS_NOSTDLIB) and/or to be set 
> explicitly to empty (NOSTDLIB=) at the top?

That's better, although I think you could reuse TOOLS_LIBS instead of
defining and using LIBGNATC everywhere.

e.g. in the darwin section use something like:

  TOOLS_LIBS=$(TOOLS_LIBS) libgnatc$(arext)

This would make the change simpler/lighter for non darwin platforms.
Changing NOSTDLIB to TOOLS_NOSTDLIB also seems like a good idea.

Arno

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of object files to link of GNAT tools
  2010-01-26 21:45 ` Arnaud Charlet
  2010-01-26 22:09   ` Simon Wright
@ 2010-01-28  6:07   ` Simon Wright
  2010-01-28  9:39     ` Arnaud Charlet
  1 sibling, 1 reply; 12+ messages in thread
From: Simon Wright @ 2010-01-28  6:07 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2897 bytes --]

On 26 Jan 2010, at 21:30, Arnaud Charlet wrote:

>> The only part of this patch you may be uncomfortable with is the change 
>> to target common-tools, where I delete all the .o files in the RTS directory 
>> that are already in libgna*.a before the gnatmake -b step (the problem 
>> being that if gnatbind sees a .o file it includes it in the files to be linked, 
>> being unaware that the object is already in libgna*.a). The .o files that 
>> survive are g-trasym.o and (on powerpc-wrs-vxworks) memtrack.o - but 
>> the latter doesn't get installed.
> 
> Right, I'm indeed uncomfortable with this part indeed. Would be good
> to find a way to avoid this part, removing objects means always forcing
> recompilation of these files. Also, you shouldn't need to remove
> memtrack.o, it shouldn't conflict with any existing .o, so no need to.
> 
> The RM command lines generated by the Makefile may also exceed
> command line length limits on some systems (e.g. IRIX).

New strategy: in Darwin only, arrange that common-tools are built using 
-nostdlib and a new temporary ada/tools/libgnatc.a which contains only 
the C-derived objects from the RTS. This means that the binder will call 
in the required Ada-derived objects from the RTS and will fnd the C 
objects in the library; and that the RTS directory itself remains untouched.

There are 2 new variables NOSTDLIB and LIBGNATC and I only set them 
in the "ifeq ($(strip $(filter-out darwin%,$(osys))),)" section. You may  want 
the names to be more specific (TOOLS_NOSTDLIB) and/or to be set 
explicitly to empty (NOSTDLIB=) at the top?

Tested on x86_64-apple-darwin10, x86_64-unknown-linux-gnu [Debian 
5] and powerpc-wrs-vxworks hosted on i386-apple-darwin10.

>> 2010-01-26  Simon Wright  <simon@pushface.org>
>> 
>> 	PR ada/42554
>> 	* gcc-interface/Makefile.in (TOOLS_LIBS): remove LIB_GNAT.
>> 	* gcc-interface/Makefile.in (GNATLINK_OBJS): remove object files
>> 	that are present in the RTS.
>> 	* gcc-interface/Makefile.in (GNATMAKE_OBJS): likewise.
>> 	* gcc-interface/Makefile.in (common-tools): at the start, delete
>> 	all the .o files in the RTS directory that are also in libraries.
>> 	* gcc-interface/Makefile.in (../../gnatmake$(exeext)): add LIBGNAT.
>> 	* gcc-interface/Makefile.in (../../gnatlink$(exeext)):likewise.
> 
> This changelog is also not in the right format, there should be
> only one mention of the file name.
> 
> The other parts of the patch (removing run-time objects from the explicit
> list of gnatmake/gnatlink objects, removing the duplicated libgnat) look
> reasonable.

2010-01-27  Simon Wright  <simon@pushface.org>
	PR ada/42554
	* gcc-interface/Makefile.in (TOOLS_LIBS, GNATLINK_OBJS, 
	GNATMAKE_OBJS, common-tools, ../../gnatmake$(exeext), 
	../../gnatlink$(exeext)): on Darwin, ensure that the
	linker only sees each object file once.


[-- Attachment #2: gcc-ada-gcc-interface-Makefile.in.diff --]
[-- Type: application/octet-stream, Size: 7352 bytes --]

Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in	(revision 156263)
+++ gcc/ada/gcc-interface/Makefile.in	(working copy)
@@ -241,7 +241,7 @@
 LIBDEPS = $(LIBINTL_DEP) $(LIBIBERTY)
 # Default is no TGT_LIB; one might be passed down or something
 TGT_LIB =
-TOOLS_LIBS = $(EXTRA_GNATTOOLS_OBJS) targext.o link.o $(LIBGNAT) ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB)
+TOOLS_LIBS = $(EXTRA_GNATTOOLS_OBJS) targext.o link.o ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB)
 
 # Specify the directories to be searched for header files.
 # Both . and srcdir are used, in that order,
@@ -289,29 +289,28 @@
 \f
 # Lists of files for various purposes.
 
-GNATLINK_OBJS = gnatlink.o \
- a-except.o ali.o alloc.o butil.o casing.o csets.o debug.o fmap.o fname.o \
- gnatvsn.o hostparm.o indepsw.o interfac.o i-c.o i-cstrin.o namet.o opt.o \
- osint.o output.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
- sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o tree_io.o \
- types.o validsw.o widechar.o
+# GNATLINK_OBJS, GNATMAKE_OBJS shouldn't contain any objects which are
+# part of the RTS.
 
-GNATMAKE_OBJS = a-except.o ali.o ali-util.o s-casuti.o \
- alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o\
- erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o \
- gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o \
- make.o makeusg.o makeutl.o mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o \
- mlib-tgt-specific.o mlib-utl.o namet.o nlists.o opt.o osint.o osint-m.o \
- output.o prj.o prj-attr.o prj-attr-pm.o prj-com.o prj-dect.o prj-env.o \
- prj-conf.o prj-pp.o \
- prj-err.o prj-ext.o prj-nmsc.o prj-pars.o prj-part.o prj-proc.o prj-strt.o \
- prj-tree.o prj-util.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
- scans.o scng.o sdefault.o sfn_scan.o s-purexc.o s-htable.o sinfo.o sinput.o \
- sinput-c.o sinput-p.o snames.o stand.o stringt.o styleg.o stylesw.o system.o \
- validsw.o switch.o switch-m.o table.o targparm.o tempdir.o tree_io.o types.o \
- uintp.o uname.o urealp.o usage.o widechar.o \
- $(EXTRA_GNATMAKE_OBJS)
+GNATLINK_OBJS = gnatlink.o ali.o alloc.o butil.o casing.o csets.o	\
+ debug.o fmap.o fname.o gnatvsn.o hostparm.o indepsw.o namet.o opt.o	\
+ osint.o output.o rident.o sdefault.o snames.o stylesw.o switch.o	\
+ table.o targparm.o tree_io.o types.o validsw.o widechar.o
 
+GNATMAKE_OBJS = ali.o ali-util.o alloc.o atree.o binderr.o butil.o	\
+ casing.o csets.o debug.o elists.o einfo.o erroutc.o errutil.o		\
+ err_vars.o fmap.o fname.o fname-uf.o fname-sf.o gnatmake.o gnatvsn.o	\
+ hostparm.o krunch.o lib.o make.o makeusg.o makeutl.o mlib.o		\
+ mlib-fil.o mlib-prj.o mlib-tgt.o mlib-tgt-specific.o mlib-utl.o	\
+ namet.o nlists.o opt.o osint.o osint-m.o output.o prj.o prj-attr.o	\
+ prj-attr-pm.o prj-com.o prj-dect.o prj-env.o prj-conf.o prj-pp.o	\
+ prj-err.o prj-ext.o prj-nmsc.o prj-pars.o prj-part.o prj-proc.o	\
+ prj-strt.o prj-tree.o prj-util.o rident.o scans.o scng.o sdefault.o	\
+ sfn_scan.o sinfo.o sinput.o sinput-c.o sinput-p.o snames.o stand.o	\
+ stringt.o styleg.o stylesw.o validsw.o switch.o switch-m.o table.o	\
+ targparm.o tempdir.o tree_io.o types.o uintp.o uname.o urealp.o	\
+ usage.o widechar.o $(EXTRA_GNATMAKE_OBJS)
+
 # Convert the target variable into a space separated list of architecture,
 # manufacturer, and operating system and assign each of those to its own
 # variable.
@@ -2169,6 +2168,16 @@
   LIBRARY_VERSION := $(LIB_VERSION)
   soext = .dylib
   GCC_LINK_FLAGS=
+  # The common-tools target is built in ../tools against the RTS
+  # directory, which contains both .o files and the corresponding
+  # static (and maybe dynamic) libraries. Allowing the Mac OS X linker
+  # in Xcode 3.2 to see both confuses it, so we use -nostdlib; but we
+  # do need the C-derived objects too, so we build a (local) library
+  # in ../tools for them first.
+  # We only need this trick for common-tools (at least, until there
+  # are extra tools for Mac OS X).
+  LIBGNATC = libgnatc$(arext)
+  NOSTDLIB = -nostdlib
 endif
 
 ifneq ($(EH_MECHANISM),)
@@ -2256,30 +2265,44 @@
   vpath %.h   ../
 endif
 
-common-tools:
+# We build against the RTS directory, which contains both .o files and
+# the corresponding static (and maybe dynamic) libraries. Allowing the
+# Mac OS X linker in Xcode 3.2 to see both confuses it, so we use
+# -nostdlib; but we do need the C-derived objects too, so we build a
+# (local) library for them first.
+# We only need this trick for common-tools and Darwin (at least, until
+# there are extra tools for Mac OS X).
+common-tools: $(LIBGNATC)
 	$(GNATMAKE) -c -b $(ADA_INCLUDES) \
 	  --GNATBIND="$(GNATBIND)" --GCC="$(CC) $(ALL_ADAFLAGS)" \
 	  gnatchop gnatcmd gnatkr gnatls gnatprep gnatxref gnatfind gnatname \
-	  gnatclean -bargs $(ADA_INCLUDES) $(GNATBIND_FLAGS)
+	  gnatclean -bargs $(ADA_INCLUDES) $(GNATBIND_FLAGS) $(NOSTDLIB)
 	$(GNATLINK) -v gnatcmd -o ../../gnat$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(LIBGNATC)
 	$(GNATLINK) -v gnatchop -o ../../gnatchop$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(LIBGNATC)
 	$(GNATLINK) -v gnatkr -o ../../gnatkr$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(LIBGNATC)
 	$(GNATLINK) -v gnatls -o ../../gnatls$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(LIBGNATC)
 	$(GNATLINK) -v gnatprep -o ../../gnatprep$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(LIBGNATC)
 	$(GNATLINK) -v gnatxref -o ../../gnatxref$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(LIBGNATC)
 	$(GNATLINK) -v gnatfind -o ../../gnatfind$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(LIBGNATC)
 	$(GNATLINK) -v gnatname -o ../../gnatname$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(LIBGNATC)
 	$(GNATLINK) -v gnatclean -o ../../gnatclean$(exeext) \
-		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
+		--GCC="$(GCC_LINK)" $(TOOLS_LIBS) $(LIBGNATC)
 
+# This library, built in ../tools, contains the C-derived objects in
+# the RTS. Darwin native only.
+libgnatc$(arext):
+	$(AR_FOR_TARGET) $(AR_FLAGS) $@ \
+	   $(addprefix ../$(RTSDIR)/,$(LIBGNAT_OBJS))
+	$(RANLIB_FOR_TARGET) $@
+
 ../../gnatsym$(exeext): 
 	$(GNATMAKE) -c $(ADA_INCLUDES) gnatsym --GCC="$(CC) $(ALL_ADAFLAGS)"
 	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatsym
@@ -2318,11 +2341,11 @@
 # Likewise for the tools
 ../../gnatmake$(exeext): $(P) b_gnatm.o link.o targext.o $(GNATMAKE_OBJS)
 	$(GCC_LINK) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) \
-		    $(TOOLS_LIBS)
+		    $(TOOLS_LIBS) $(LIBGNAT)
 
 ../../gnatlink$(exeext): $(P) b_gnatl.o link.o targext.o $(GNATLINK_OBJS)
 	$(GCC_LINK) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatl.o $(GNATLINK_OBJS) \
-		    $(TOOLS_LIBS)
+		    $(TOOLS_LIBS) $(LIBGNAT)
 
 ../stamp-gnatlib-$(RTSDIR):
 	@if [ ! -f stamp-gnatlib-$(RTSDIR) ] ; \

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of object  files to link of GNAT tools
  2010-01-26 22:09   ` Simon Wright
@ 2010-01-26 22:45     ` Arnaud Charlet
  0 siblings, 0 replies; 12+ messages in thread
From: Arnaud Charlet @ 2010-01-26 22:45 UTC (permalink / raw)
  To: Simon Wright; +Cc: gcc-patches

> Will fix. Do you need to see the (MACRO) and (target) indications?

Well yes, that's part of the ChangeLog standard format.

Arno

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of object files to link of GNAT tools
  2010-01-26 21:45 ` Arnaud Charlet
@ 2010-01-26 22:09   ` Simon Wright
  2010-01-26 22:45     ` Arnaud Charlet
  2010-01-28  6:07   ` Simon Wright
  1 sibling, 1 reply; 12+ messages in thread
From: Simon Wright @ 2010-01-26 22:09 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: gcc-patches

On 26 Jan 2010, at 21:30, Arnaud Charlet wrote:

>> The only part of this patch you may be uncomfortable with is the change 
>> to target common-tools, where I delete all the .o files in the RTS directory 
>> that are already in libgna*.a before the gnatmake -b step (the problem 
>> being that if gnatbind sees a .o file it includes it in the files to be linked, 
>> being unaware that the object is already in libgna*.a). The .o files that 
>> survive are g-trasym.o and (on powerpc-wrs-vxworks) memtrack.o - but 
>> the latter doesn't get installed.
> 
> Right, I'm indeed uncomfortable with this part indeed. Would be good
> to find a way to avoid this part, removing objects means always forcing
> recompilation of these files. Also, you shouldn't need to remove
> memtrack.o, it shouldn't conflict with any existing .o, so no need to.

I will think about this some more, then.

memtrack.o - it'll only get deleted if it isn't in libgmem.a, and it doesn't seem 
to get installed anyway (target install-gnatlib at line 2357 only installs 
g-trasym$(objext)).  [NB inconsstency between use of .o and $(objext)!]

> The RM command lines generated by the Makefile may also exceed
> command line length limits on some systems (e.g. IRIX).

I took the idea for these commands from similar commands at line 2462ff in 
target gnatlib. So that would need fixing too if there is a problem (presumably 
not).

>> 2010-01-26  Simon Wright  <simon@pushface.org>
>> 
>> 	PR ada/42554
>> 	* gcc-interface/Makefile.in (TOOLS_LIBS): remove LIB_GNAT.
>> 	* gcc-interface/Makefile.in (GNATLINK_OBJS): remove object files
>> 	that are present in the RTS.
>> 	* gcc-interface/Makefile.in (GNATMAKE_OBJS): likewise.
>> 	* gcc-interface/Makefile.in (common-tools): at the start, delete
>> 	all the .o files in the RTS directory that are also in libraries.
>> 	* gcc-interface/Makefile.in (../../gnatmake$(exeext)): add LIBGNAT.
>> 	* gcc-interface/Makefile.in (../../gnatlink$(exeext)):likewise.
> 
> This changelog is also not in the right format, there should be
> only one mention of the file name.

Will fix. Do you need to see the (MACRO) and (target) indications?

> The other parts of the patch (removing run-time objects from the explicit
> list of gnatmake/gnatlink objects, removing the duplicated libgnat) look
> reasonable.

Good!

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of  object files to link of GNAT tools
  2010-01-26 21:30 Simon Wright
@ 2010-01-26 21:45 ` Arnaud Charlet
  2010-01-26 22:09   ` Simon Wright
  2010-01-28  6:07   ` Simon Wright
  0 siblings, 2 replies; 12+ messages in thread
From: Arnaud Charlet @ 2010-01-26 21:45 UTC (permalink / raw)
  To: Simon Wright; +Cc: gcc-patches

> The only part of this patch you may be uncomfortable with is the change 
> to target common-tools, where I delete all the .o files in the RTS directory 
> that are already in libgna*.a before the gnatmake -b step (the problem 
> being that if gnatbind sees a .o file it includes it in the files to be linked, 
> being unaware that the object is already in libgna*.a). The .o files that 
> survive are g-trasym.o and (on powerpc-wrs-vxworks) memtrack.o - but 
> the latter doesn't get installed.

Right, I'm indeed uncomfortable with this part indeed. Would be good
to find a way to avoid this part, removing objects means always forcing
recompilation of these files. Also, you shouldn't need to remove
memtrack.o, it shouldn't conflict with any existing .o, so no need to.

The RM command lines generated by the Makefile may also exceed
command line length limits on some systems (e.g. IRIX).

> 2010-01-26  Simon Wright  <simon@pushface.org>
> 
> 	PR ada/42554
> 	* gcc-interface/Makefile.in (TOOLS_LIBS): remove LIB_GNAT.
> 	* gcc-interface/Makefile.in (GNATLINK_OBJS): remove object files
> 	that are present in the RTS.
> 	* gcc-interface/Makefile.in (GNATMAKE_OBJS): likewise.
> 	* gcc-interface/Makefile.in (common-tools): at the start, delete
> 	all the .o files in the RTS directory that are also in libraries.
> 	* gcc-interface/Makefile.in (../../gnatmake$(exeext)): add LIBGNAT.
> 	* gcc-interface/Makefile.in (../../gnatlink$(exeext)):likewise.

This changelog is also not in the right format, there should be
only one mention of the file name.

The other parts of the patch (removing run-time objects from the explicit
list of gnatmake/gnatlink objects, removing the duplicated libgnat) look
reasonable.

Arno

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] PR ada/42254, avoid providing multiple copies of object files to link of GNAT tools
@ 2010-01-26 21:30 Simon Wright
  2010-01-26 21:45 ` Arnaud Charlet
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Wright @ 2010-01-26 21:30 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2269 bytes --]

I've corrected the ridiculously long lines, sorry

This is a corrected re-post of an earlier patch, posted 11 Jan, titled just 
"[Ada] Avoid providing multiple copies of object files to link of GNAT tools".

gcc/ada/gcc-interface/Makefile.in provides the linker with multiple
copies of object files (those in the RTS), in two cases by explicitly
listing them (macros GNATLINK_OBJS, GNATMAKE_OBJS) and then
linking against LIBGNAT and in the others (target common-tools) by 
leaving .o files in the RTS directory for gnatbind to see and use and 
by calling up LIBGNAT twice (by including LIBGNAT in macro 
TOOLS_LIBS when it is implicitly included by gnatbind already).

This is legal if unnecessary behaviour, I think, but in Xcode 3.2
(used in darwin10, Snow Leopard) Apple have introduced a bug (radar
6320843 "duplicate symbols from static libraries not properly
ignored") which prevents building any of the GNAT tools.

Other languages have had similar though less pervasive problems, see
PR bootstrap/41180.

The only part of this patch you may be uncomfortable with is the change 
to target common-tools, where I delete all the .o files in the RTS directory 
that are already in libgna*.a before the gnatmake -b step (the problem 
being that if gnatbind sees a .o file it includes it in the files to be linked, 
being unaware that the object is already in libgna*.a). The .o files that 
survive are g-trasym.o and (on powerpc-wrs-vxworks) memtrack.o - but 
the latter doesn't get installed.

Tested on x86_64-apple-darwin10, x86_64-unknown-linux-gnu [Debian 
5, I didn't say --build= which may explain the -unknown- ?] and 
powerpc-wrs-vxworks hosted on i386-apple-darwin10.

2010-01-26  Simon Wright  <simon@pushface.org>

	PR ada/42554
	* gcc-interface/Makefile.in (TOOLS_LIBS): remove LIB_GNAT.
	* gcc-interface/Makefile.in (GNATLINK_OBJS): remove object files
	that are present in the RTS.
	* gcc-interface/Makefile.in (GNATMAKE_OBJS): likewise.
	* gcc-interface/Makefile.in (common-tools): at the start, delete
	all the .o files in the RTS directory that are also in libraries.
	* gcc-interface/Makefile.in (../../gnatmake$(exeext)): add LIBGNAT.
	* gcc-interface/Makefile.in (../../gnatlink$(exeext)):likewise.


[-- Attachment #2: gcc-ada-gcc-interface-Makefile.in.diff --]
[-- Type: application/octet-stream, Size: 4877 bytes --]

Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in	(revision 156260)
+++ gcc/ada/gcc-interface/Makefile.in	(working copy)
@@ -241,7 +241,7 @@
 LIBDEPS = $(LIBINTL_DEP) $(LIBIBERTY)
 # Default is no TGT_LIB; one might be passed down or something
 TGT_LIB =
-TOOLS_LIBS = $(EXTRA_GNATTOOLS_OBJS) targext.o link.o $(LIBGNAT) ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB)
+TOOLS_LIBS = $(EXTRA_GNATTOOLS_OBJS) targext.o link.o ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB)
 
 # Specify the directories to be searched for header files.
 # Both . and srcdir are used, in that order,
@@ -289,29 +289,28 @@
 \f
 # Lists of files for various purposes.
 
-GNATLINK_OBJS = gnatlink.o \
- a-except.o ali.o alloc.o butil.o casing.o csets.o debug.o fmap.o fname.o \
- gnatvsn.o hostparm.o indepsw.o interfac.o i-c.o i-cstrin.o namet.o opt.o \
- osint.o output.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
- sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o tree_io.o \
- types.o validsw.o widechar.o
+# GNATLINK_OBJS, GNATMAKE_OBJS shouldn't contain any objects which are
+# part of the RTS.
 
-GNATMAKE_OBJS = a-except.o ali.o ali-util.o s-casuti.o \
- alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o\
- erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o \
- gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o \
- make.o makeusg.o makeutl.o mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o \
- mlib-tgt-specific.o mlib-utl.o namet.o nlists.o opt.o osint.o osint-m.o \
- output.o prj.o prj-attr.o prj-attr-pm.o prj-com.o prj-dect.o prj-env.o \
- prj-conf.o prj-pp.o \
- prj-err.o prj-ext.o prj-nmsc.o prj-pars.o prj-part.o prj-proc.o prj-strt.o \
- prj-tree.o prj-util.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
- scans.o scng.o sdefault.o sfn_scan.o s-purexc.o s-htable.o sinfo.o sinput.o \
- sinput-c.o sinput-p.o snames.o stand.o stringt.o styleg.o stylesw.o system.o \
- validsw.o switch.o switch-m.o table.o targparm.o tempdir.o tree_io.o types.o \
- uintp.o uname.o urealp.o usage.o widechar.o \
- $(EXTRA_GNATMAKE_OBJS)
+GNATLINK_OBJS = gnatlink.o ali.o alloc.o butil.o casing.o csets.o	\
+ debug.o fmap.o fname.o gnatvsn.o hostparm.o indepsw.o namet.o opt.o	\
+ osint.o output.o rident.o sdefault.o snames.o stylesw.o switch.o	\
+ table.o targparm.o tree_io.o types.o validsw.o widechar.o
 
+GNATMAKE_OBJS = ali.o ali-util.o alloc.o atree.o binderr.o butil.o	\
+ casing.o csets.o debug.o elists.o einfo.o erroutc.o errutil.o		\
+ err_vars.o fmap.o fname.o fname-uf.o fname-sf.o gnatmake.o gnatvsn.o	\
+ hostparm.o krunch.o lib.o make.o makeusg.o makeutl.o mlib.o		\
+ mlib-fil.o mlib-prj.o mlib-tgt.o mlib-tgt-specific.o mlib-utl.o	\
+ namet.o nlists.o opt.o osint.o osint-m.o output.o prj.o prj-attr.o	\
+ prj-attr-pm.o prj-com.o prj-dect.o prj-env.o prj-conf.o prj-pp.o	\
+ prj-err.o prj-ext.o prj-nmsc.o prj-pars.o prj-part.o prj-proc.o	\
+ prj-strt.o prj-tree.o prj-util.o rident.o scans.o scng.o sdefault.o	\
+ sfn_scan.o sinfo.o sinput.o sinput-c.o sinput-p.o snames.o stand.o	\
+ stringt.o styleg.o stylesw.o validsw.o switch.o switch-m.o table.o	\
+ targparm.o tempdir.o tree_io.o types.o uintp.o uname.o urealp.o	\
+ usage.o widechar.o $(EXTRA_GNATMAKE_OBJS)
+
 # Convert the target variable into a space separated list of architecture,
 # manufacturer, and operating system and assign each of those to its own
 # variable.
@@ -2256,7 +2255,16 @@
   vpath %.h   ../
 endif
 
+# Remove the extra object files from the RTS directory first - by now
+# we have built both static and dynamic libraries, and leaving the
+# .o's confuses the Mac OS X linker in Xcode 3.2.
 common-tools:
+	$(RM) $(addprefix ../$(RTSDIR)/,$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS))
+	$(RM) $(addprefix ../$(RTSDIR)/,$(GNATRTL_TASKING_OBJS))
+	$(RM) $(addprefix ../$(RTSDIR)/,$(GNATRTL_LINEARALGEBRA_OBJS))
+        ifeq ($(GMEM_LIB),gmemlib)
+		$(RM) ../$(RTSDIR)/memtrack.o
+        endif
 	$(GNATMAKE) -c -b $(ADA_INCLUDES) \
 	  --GNATBIND="$(GNATBIND)" --GCC="$(CC) $(ALL_ADAFLAGS)" \
 	  gnatchop gnatcmd gnatkr gnatls gnatprep gnatxref gnatfind gnatname \
@@ -2318,11 +2326,11 @@
 # Likewise for the tools
 ../../gnatmake$(exeext): $(P) b_gnatm.o link.o targext.o $(GNATMAKE_OBJS)
 	$(GCC_LINK) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) \
-		    $(TOOLS_LIBS)
+		    $(TOOLS_LIBS) $(LIBGNAT)
 
 ../../gnatlink$(exeext): $(P) b_gnatl.o link.o targext.o $(GNATLINK_OBJS)
 	$(GCC_LINK) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatl.o $(GNATLINK_OBJS) \
-		    $(TOOLS_LIBS)
+		    $(TOOLS_LIBS) $(LIBGNAT)
 
 ../stamp-gnatlib-$(RTSDIR):
 	@if [ ! -f stamp-gnatlib-$(RTSDIR) ] ; \

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-02-03  6:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-26 21:30 [PATCH] PR ada/42254, avoid providing multiple copies of object files to link of GNAT tools Simon Wright
  -- strict thread matches above, loose matches on Subject: below --
2010-01-26 21:30 Simon Wright
2010-01-26 21:45 ` Arnaud Charlet
2010-01-26 22:09   ` Simon Wright
2010-01-26 22:45     ` Arnaud Charlet
2010-01-28  6:07   ` Simon Wright
2010-01-28  9:39     ` Arnaud Charlet
2010-01-28 22:52       ` Simon Wright
2010-01-29  9:17         ` Arnaud Charlet
2010-01-31 22:54           ` Simon Wright
2010-02-01  7:23             ` Arnaud Charlet
2010-02-03  6:59               ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).