[U-Boot] [PATCH] common: Link with GCC instead of LD

Andreas Bießmann andreas.devel at googlemail.com
Wed Oct 31 20:51:44 CET 2012


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,<param> . 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 <marex at denx.de>
> Cc: Albert Aribaud <albert.u.boot at aribaud.net>
> Cc: Joe Hershberger <joe.hershberger at ni.com>
> Cc: Mike Frysinger <vapier at gentoo.org>
> Cc: Tom Rini <trini at ti.com>
> Cc: Wolfgang Denk <wd at denx.de>
> ---

> 
> 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.
> 

<snip>

> 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


More information about the U-Boot mailing list