From f26577423eb65728fcd10f78f9978dd07d51dcb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Krause?= Date: Tue, 27 Oct 2015 22:30:06 +0100 Subject: [PATCH] Kbuild: Link with GCC instead of LD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some toolchains used in Buildroot (x86_64 and mips64) partial linking using 'ld' directly doesn't work well, as th 'ld' default emulation may not necessarily be the correct one. Note, that the default emulation depends upon how the linker was configured at build time. The leads to different kind of build errors, like: * /usr/bin/i686-pc-linux-gnu-ld: Relocatable linking with relocations from format elf64-x86-64 (core/swupdate.o) to format elf32-i386 (core/built-in.o) is not supported. * /usr/bin/mips-linux-gnu-ld: handlers/raw_handler.o: endianness incompatible with that of the selected emulation * /usr/bin/mips64el-linux-ld: core/swupdate.o: ABI is incompatible with that of the selected Linking with GCC will pass all the appropriate linker flags to the linker. '-nostdlib' has to be added to ldflags-y to link properly without pulling in GCC libs during partial linking. Note that this patch address the same issue from a previous patch "Kbuild: fix build issue with some toolchains" [1]. However, this patch did not work properly and was reverted finally. [1] https://groups.google.com/forum/#!topic/swupdate/oVIhJmYPT8A Signed-off-by: Jörg Krause --- Makefile | 2 +- scripts/Makefile.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3d6a7b7f9..157f6a532 100644 --- a/Makefile +++ b/Makefile @@ -170,7 +170,7 @@ include $(srctree)/scripts/Kbuild.include # Make variables (CC, etc...) AS = $(CROSS_COMPILE)as -LD = $(CROSS_COMPILE)ld +LD = $(CROSS_COMPILE)gcc CC = $(CROSS_COMPILE)gcc CPP = $(CC) -E AR = $(CROSS_COMPILE)ar diff --git a/scripts/Makefile.build b/scripts/Makefile.build index d43468282..a66de2627 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -22,7 +22,7 @@ EXTRA_LDFLAGS := asflags-y := ccflags-y := cppflags-y := -ldflags-y := +ldflags-y := -nostdlib subdir-asflags-y := subdir-ccflags-y :=