aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-01-18 08:01:49 +0000
committerRon Yorston <rmy@pobox.com>2024-01-18 08:01:49 +0000
commit992387539f26de1aeb2cdca62d85fddbde27b798 (patch)
tree877ac39f317f4ff884103b43d1162221902d39a1
parent99d22da0e95d8356239c63199eb03f70adbf7a61 (diff)
downloadbusybox-w32-992387539f26de1aeb2cdca62d85fddbde27b798.tar.gz
busybox-w32-992387539f26de1aeb2cdca62d85fddbde27b798.tar.bz2
busybox-w32-992387539f26de1aeb2cdca62d85fddbde27b798.zip
build system: more clang/llvm tweaks
Linkers associated with clang/llvm may not support the -r option. This is used to create built-in.o object files. It turns out that all such files in busybox-w32 are either empty or only contain one object file. The first case is already supported and the second can be handled by simply copying the object file to built-in.o. The linker is therefore never invoked with the -r option. One adjustment is required: the workaround adopted for GitHub issue #200 linked the dummy C file with the resource object file. This is no longer done so only one object file is used. Since it was the linking that broke the resource file, copying it is an equally effective fix for the issue. Some old linkers don't support the --warn-common option. The lack of this option was being detected but it was still sometimes used.
-rw-r--r--scripts/Makefile.build11
-rwxr-xr-xscripts/trylink2
-rw-r--r--win32/resources/Kbuild.src1
-rw-r--r--win32/resources/dummy.c2
4 files changed, 12 insertions, 4 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 5eac45f91..2a9f451f3 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -254,11 +254,22 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
254# 254#
255ifdef builtin-target 255ifdef builtin-target
256quiet_cmd_link_o_target = LD $@ 256quiet_cmd_link_o_target = LD $@
257ifeq ($(CONFIG_PLATFORM_POSIX),y)
257# If the list of objects to link is empty, just create an empty built-in.o 258# If the list of objects to link is empty, just create an empty built-in.o
258# -nostdlib is added to make "make LD=gcc ..." work (some people use that) 259# -nostdlib is added to make "make LD=gcc ..." work (some people use that)
259cmd_link_o_target = $(if $(strip $(obj-y)),\ 260cmd_link_o_target = $(if $(strip $(obj-y)),\
260 $(LD) -nostdlib $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\ 261 $(LD) -nostdlib $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
261 rm -f $@; $(AR) rcs $@) 262 rm -f $@; $(AR) rcs $@)
263else
264# In default builds of busybox-w32 all builtin targets have either
265# zero or one object files. In the latter case copy the object to
266# the target. This avoids the need to use the linker: the llvm
267# linker doesn't support the -r option.
268cmd_link_o_target = $(intcmp $(words $(obj-y)),1,\
269 rm -f $@; $(AR) rcs $@,\
270 cp $(obj-y) $@,\
271 $(LD) -nostdlib $(ld_flags) -r -o $@ $(filter $(obj-y), $^))
272endif
262 273
263$(builtin-target): $(obj-y) FORCE 274$(builtin-target): $(obj-y) FORCE
264 $(call if_changed,link_o_target) 275 $(call if_changed,link_o_target)
diff --git a/scripts/trylink b/scripts/trylink
index 2255deee7..776fd484a 100755
--- a/scripts/trylink
+++ b/scripts/trylink
@@ -96,7 +96,7 @@ fi
96START_GROUP="-Wl,--start-group" 96START_GROUP="-Wl,--start-group"
97END_GROUP="-Wl,--end-group" 97END_GROUP="-Wl,--end-group"
98INFO_OPTS() { 98INFO_OPTS() {
99 echo "-Wl,--warn-common -Wl,-Map,$EXE.map -Wl,--verbose" 99 echo "$SORT_COMMON -Wl,-Map,$EXE.map -Wl,--verbose"
100} 100}
101 101
102# gold may not support --sort-common (yet) 102# gold may not support --sort-common (yet)
diff --git a/win32/resources/Kbuild.src b/win32/resources/Kbuild.src
index e2d884e98..d056a5964 100644
--- a/win32/resources/Kbuild.src
+++ b/win32/resources/Kbuild.src
@@ -7,7 +7,6 @@
7obj-y := 7obj-y :=
8 8
9obj-$(CONFIG_FEATURE_RESOURCES) += resources.o 9obj-$(CONFIG_FEATURE_RESOURCES) += resources.o
10obj-$(CONFIG_FEATURE_RESOURCES) += dummy.o
11 10
12# return commit level if available or 0 11# return commit level if available or 0
13bb_level = $(or $(word 2,$(subst -, ,$1)),0) 12bb_level = $(or $(word 2,$(subst -, ,$1)),0)
diff --git a/win32/resources/dummy.c b/win32/resources/dummy.c
index 2d4b87680..e69de29bb 100644
--- a/win32/resources/dummy.c
+++ b/win32/resources/dummy.c
@@ -1,2 +0,0 @@
1extern void wibble(void);
2void wibble(void) {}