From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Andreas_Bie=DFmann?= Date: Wed, 31 Oct 2012 20:51:44 +0100 Subject: [U-Boot] [PATCH] common: Link with GCC instead of LD In-Reply-To: <1351701168-7293-1-git-send-email-marex@denx.de> References: <1351701168-7293-1-git-send-email-marex@denx.de> Message-ID: <50918150.1030202@googlemail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Marek Vasut, On 31.10.12 17:32, Marek Vasut wrote: > Flip over from linking with LD to linking with GCC. This has some > long-term benefits, like easy path to enabling LTO. > > Most of this patch is about passing parameters to the linker invoked > by GCC at the linking stage. This involves prefixing most of these with > -Wl, . A few more adjustments had to be made though. > > The LDFLAGS had to be extended by --build-id=none to prevent generation > of the .note.gnu.build-id section, which contains unique build-id we > don't care about. Moreover -nostdlib had to be added to LDFLAGS to link > properly without pulling in GCC libs during partial link. > > The LDFLAGS_FINAL had to be augmented by -Wl,-allow-multiple-definition > to prevent GCC from complaining about multiple definitions of the register > containing global data. > > Signed-off-by: Marek Vasut > Cc: Albert Aribaud > Cc: Joe Hershberger > Cc: Mike Frysinger > Cc: Tom Rini > Cc: Wolfgang Denk > --- > > NOTE: It should mostly work, but _PLEASE_ test it properly. I definitelly > can not run it on most of the affected platforms. Besides, it might > still hit some build issues, it's not properly compiler-tested. Any > additional fixes are welcome ;-) > > NOTE: I detected code size being smaller by a few bytes, but then it might > cause breakage, so I'd be really cautious here. > > diff --git a/config.mk b/config.mk > index b7cd481..ec8cd6b 100644 > --- a/config.mk > +++ b/config.mk > @@ -137,9 +137,8 @@ binutils-version = $(shell $(SHELL) $(SRCTREE)/tools/binutils-version.sh $(AS)) > # > AS = $(CROSS_COMPILE)as > > -# Always use GNU ld > -LD = $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \ > - then echo "$(CROSS_COMPILE)ld.bfd"; else echo "$(CROSS_COMPILE)ld"; fi;) > +# Link with GCC > +LD = $(CROSS_COMPILE)gcc with this change we should also remove LD_VERSION_STRING from $(VERSION_FILE). Currently it will call 'gcc -v' which will print compile switches to stderr. Compiled and runtime tested on avr32 atngw100mkii, on first sight it seems sane. Best regards Andreas Bie?mann