Skip to content

Commit

Permalink
Kbuild: Link with GCC instead of LD
Browse files Browse the repository at this point in the history
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 <joerg.krause@embedded.rocks>
  • Loading branch information
joerg-krause authored and sbabic committed Nov 1, 2015
1 parent a83c97a commit f265774
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/Makefile.build
Expand Up @@ -22,7 +22,7 @@ EXTRA_LDFLAGS :=
asflags-y :=
ccflags-y :=
cppflags-y :=
ldflags-y :=
ldflags-y := -nostdlib

subdir-asflags-y :=
subdir-ccflags-y :=
Expand Down

0 comments on commit f265774

Please sign in to comment.