summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2015-09-25 13:28:05 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-28 12:00:25 +0100
commit8227d49edc525bd0369d01fee8e6d6184b0f1723 (patch)
tree046b53231680dfb319d58a951f7074a41f87aa16 /meta/recipes-core/busybox
parenta3c48179a9410edb29b260595dea2d83ce20b1d8 (diff)
downloadpoky-8227d49edc525bd0369d01fee8e6d6184b0f1723.tar.gz
busybox: Use CC instead of bare LD to be the Linker
This patch was on mailing list, another patch to make sure -r is not passed directly but via -Wl switch is added. This was exposed when using clang and gold linker, clang does not have -r switch to do relocatable objects and problem happens specific to OE becuase we use LD = CC now what happens is that busybox assumes that linker will be called directly, and hence sprinkles linkers options in its kbuild system which aggregate into LDFLAGS, some of these options are happily ignored by gcc as well but it passes -r options rightly to linker so it all works, however when using clang, this falls apart since -r is not known option for clang so it drops this option and all obects which should be partially linked becomes ET_EXEC and when they are added to final link then gold starts to get confused /mnt/home/kraj/work/angstrom/build/tmp-angstrom-glibc/sysroots/x86_64-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-ld: error: applets/built-in.o: unsupported ELF file type 2 clang-3.7: error: linker command failed with exit code 1 (use -v to see invocation) (From OE-Core rev: 117282486b68e4da468c21795ea87bfc85625885) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/busybox')
-rw-r--r--meta/recipes-core/busybox/busybox/0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-and.patch114
-rw-r--r--meta/recipes-core/busybox/busybox/0002-Passthrough-r-to-linker.patch32
-rw-r--r--meta/recipes-core/busybox/busybox_1.23.2.bb2
3 files changed, 148 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-and.patch b/meta/recipes-core/busybox/busybox/0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-and.patch
new file mode 100644
index 0000000000..2bf2b91c7e
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-and.patch
@@ -0,0 +1,114 @@
1From a9333eb6a7b8dbda735947cd5bc981ff9352a2c9 Mon Sep 17 00:00:00 2001
2From: Nathan Phillip Brink <ohnobinki@ohnopublishing.net>
3Date: Thu, 10 Mar 2011 00:27:08 -0500
4Subject: [PATCH 1/2] Use $(CC) when linking instead of $(LD) and use $(CFLAGS)
5 and $(EXTRA_CFLAGS) when linking.
6
7This fixes the issue where LDFLAGS escaped with -Wl are ignored during
8compilation. It also simplifies using CFLAGS or EXTRA_CFLAGS (such as
9-m32 on x86_64 or -flto) which apply to both compilation and linking
10situations.
11
12Signed-off-by: Nathan Phillip Brink <ohnobinki@ohnopublishing.net>
13---
14Upstream-Status: Pending
15
16 Makefile | 7 ++++---
17 scripts/Makefile.build | 8 ++++----
18 scripts/Makefile.lib | 13 +++----------
19 3 files changed, 11 insertions(+), 17 deletions(-)
20
21Index: busybox-1.23.2/Makefile
22===================================================================
23--- busybox-1.23.2.orig/Makefile
24+++ busybox-1.23.2/Makefile
25@@ -309,7 +309,8 @@ CHECKFLAGS := -D__linux__ -Dlinux -D
26 MODFLAGS = -DMODULE
27 CFLAGS_MODULE = $(MODFLAGS)
28 AFLAGS_MODULE = $(MODFLAGS)
29-LDFLAGS_MODULE = -r
30+LDFLAGS_RELOCATABLE = -r -nostdlib
31+LDFLAGS_MODULE = $(LDFLAGS_RELOCATABLE)
32 CFLAGS_KERNEL =
33 AFLAGS_KERNEL =
34
35@@ -331,7 +332,7 @@ KERNELVERSION = $(VERSION).$(PATCHLEVEL)
36 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \
37 ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
38 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
39- HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
40+ HOSTCXX HOSTCXXFLAGS LDFLAGS_RELOCATABLE LDFLAGS_MODULE CHECK CHECKFLAGS
41
42 export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
43 export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
44@@ -610,7 +611,7 @@ quiet_cmd_busybox__ ?= LINK $@
45 cmd_busybox__ ?= $(srctree)/scripts/trylink \
46 "$@" \
47 "$(CC)" \
48- "$(CFLAGS) $(CFLAGS_busybox)" \
49+ "$(CFLAGS) $(CFLAGS_busybox) $(EXTRA_CFLAGS)" \
50 "$(LDFLAGS) $(EXTRA_LDFLAGS)" \
51 "$(core-y)" \
52 "$(libs-y)" \
53Index: busybox-1.23.2/scripts/Makefile.build
54===================================================================
55--- busybox-1.23.2.orig/scripts/Makefile.build
56+++ busybox-1.23.2/scripts/Makefile.build
57@@ -174,7 +174,7 @@ cmd_modversions = \
58 | $(GENKSYMS) -a $(ARCH) \
59 > $(@D)/.tmp_$(@F:.o=.ver); \
60 \
61- $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
62+ $(CC) $(ld_flags_partial) $(LDFLAGS_RELOCATABLE) -o $@ $(@D)/.tmp_$(@F) \
63 -T $(@D)/.tmp_$(@F:.o=.ver); \
64 rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
65 else \
66@@ -257,7 +257,7 @@ quiet_cmd_link_o_target = LD $@
67 # If the list of objects to link is empty, just create an empty built-in.o
68 # -nostdlib is added to make "make LD=gcc ..." work (some people use that)
69 cmd_link_o_target = $(if $(strip $(obj-y)),\
70- $(LD) -nostdlib $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
71+ $(CC) $(ld_flags_partial) $(LDFLAGS_RELOCATABLE) -o $@ $(filter $(obj-y), $^),\
72 rm -f $@; $(AR) rcs $@)
73
74 $(builtin-target): $(obj-y) FORCE
75@@ -292,10 +292,10 @@ $($(subst $(obj)/,,$(@:.o=-objs))) \
76 $($(subst $(obj)/,,$(@:.o=-y)))), $^)
77
78 quiet_cmd_link_multi-y = LD $@
79-cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)
80+cmd_link_multi-y = $(CC) $(ld_flags_partial) $(LDFLAGS_RELOCATABLE) -o $@ $(link_multi_deps)
81
82 quiet_cmd_link_multi-m = LD [M] $@
83-cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps)
84+cmd_link_multi-m = $(CC) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps)
85
86 # We would rather have a list of rules like
87 # foo.o: $(foo-objs)
88Index: busybox-1.23.2/scripts/Makefile.lib
89===================================================================
90--- busybox-1.23.2.orig/scripts/Makefile.lib
91+++ busybox-1.23.2/scripts/Makefile.lib
92@@ -121,7 +121,8 @@ cpp_flags = -Wp,-MD,$(depfile) $(NO
93 # yet ld_flags is fed to ld.
94 #ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS)
95 # Remove the -Wl, prefix from linker options normally passed through gcc
96-ld_flags = $(filter-out -Wl$(comma)%,$(LDFLAGS) $(EXTRA_LDFLAGS))
97+ld_flags = $(filter-out -Wl$(comma)%,$(LDFLAGS) $(EXTRA_LDFLAGS) $(CFLAGS) $(EXTRA_CFLAGS))
98+ld_flags_partial = $($(filter-out -shared%, $(filter-out -pie%,$(ld_flags))))
99
100
101 # Finds the multi-part object the current object will be linked into
102@@ -151,10 +152,8 @@ $(obj)/%:: $(src)/%_shipped
103 # Linking
104 # ---------------------------------------------------------------------------
105
106-# TODO: LDFLAGS usually is supposed to contain gcc's flags, not ld's.
107-# but here we feed them to ld!
108-quiet_cmd_ld = LD $@
109-cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \
110+quiet_cmd_ld = CC $@
111+cmd_ld = $(CC) $(ld_flags) $(LDFLAGS_$(@F)) \
112 $(filter-out FORCE,$^) -o $@
113
114 # Objcopy
diff --git a/meta/recipes-core/busybox/busybox/0002-Passthrough-r-to-linker.patch b/meta/recipes-core/busybox/busybox/0002-Passthrough-r-to-linker.patch
new file mode 100644
index 0000000000..de286fb746
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0002-Passthrough-r-to-linker.patch
@@ -0,0 +1,32 @@
1From df2cc76cdebc4773361477f3db203790f6986e3b Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 22 Aug 2015 23:42:40 -0700
4Subject: [PATCH 2/2] Passthrough -r to linker
5
6clang does not have -r switch and it does not pass it down to linker
7either, LDFLAGS_RELOCATABLE is used when CC is used for LD, so this
8should not cause side effects
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12Upstream-Status: Pending
13
14 Makefile | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17diff --git a/Makefile b/Makefile
18index 9da02cb..10dd4a9 100644
19--- a/Makefile
20+++ b/Makefile
21@@ -309,7 +309,7 @@ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(C
22 MODFLAGS = -DMODULE
23 CFLAGS_MODULE = $(MODFLAGS)
24 AFLAGS_MODULE = $(MODFLAGS)
25-LDFLAGS_RELOCATABLE = -r -nostdlib
26+LDFLAGS_RELOCATABLE = -Xlinker -r -nostdlib
27 LDFLAGS_MODULE = $(LDFLAGS_RELOCATABLE)
28 CFLAGS_KERNEL =
29 AFLAGS_KERNEL =
30--
312.1.4
32
diff --git a/meta/recipes-core/busybox/busybox_1.23.2.bb b/meta/recipes-core/busybox/busybox_1.23.2.bb
index 5e027326c2..25598232ae 100644
--- a/meta/recipes-core/busybox/busybox_1.23.2.bb
+++ b/meta/recipes-core/busybox/busybox_1.23.2.bb
@@ -33,6 +33,8 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
33 file://0001-Switch-to-POSIX-utmpx-API.patch \ 33 file://0001-Switch-to-POSIX-utmpx-API.patch \
34 file://0001-ifconfig-fix-double-free-fatal-error-in-INET_sprint.patch \ 34 file://0001-ifconfig-fix-double-free-fatal-error-in-INET_sprint.patch \
35 file://0001-chown-fix-help-text.patch \ 35 file://0001-chown-fix-help-text.patch \
36 file://0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-and.patch \
37 file://0002-Passthrough-r-to-linker.patch \
36 file://mount-via-label.cfg \ 38 file://mount-via-label.cfg \
37 file://sha1sum.cfg \ 39 file://sha1sum.cfg \
38 file://sha256sum.cfg \ 40 file://sha256sum.cfg \