diff options
author | Ron Yorston <rmy@pobox.com> | 2024-01-18 08:01:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-01-18 08:01:49 +0000 |
commit | 992387539f26de1aeb2cdca62d85fddbde27b798 (patch) | |
tree | 877ac39f317f4ff884103b43d1162221902d39a1 | |
parent | 99d22da0e95d8356239c63199eb03f70adbf7a61 (diff) | |
download | busybox-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.build | 11 | ||||
-rwxr-xr-x | scripts/trylink | 2 | ||||
-rw-r--r-- | win32/resources/Kbuild.src | 1 | ||||
-rw-r--r-- | win32/resources/dummy.c | 2 |
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 | # |
255 | ifdef builtin-target | 255 | ifdef builtin-target |
256 | quiet_cmd_link_o_target = LD $@ | 256 | quiet_cmd_link_o_target = LD $@ |
257 | ifeq ($(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) |
259 | cmd_link_o_target = $(if $(strip $(obj-y)),\ | 260 | cmd_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 $@) |
263 | else | ||
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. | ||
268 | cmd_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), $^)) | ||
272 | endif | ||
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 | |||
96 | START_GROUP="-Wl,--start-group" | 96 | START_GROUP="-Wl,--start-group" |
97 | END_GROUP="-Wl,--end-group" | 97 | END_GROUP="-Wl,--end-group" |
98 | INFO_OPTS() { | 98 | INFO_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 @@ | |||
7 | obj-y := | 7 | obj-y := |
8 | 8 | ||
9 | obj-$(CONFIG_FEATURE_RESOURCES) += resources.o | 9 | obj-$(CONFIG_FEATURE_RESOURCES) += resources.o |
10 | obj-$(CONFIG_FEATURE_RESOURCES) += dummy.o | ||
11 | 10 | ||
12 | # return commit level if available or 0 | 11 | # return commit level if available or 0 |
13 | bb_level = $(or $(word 2,$(subst -, ,$1)),0) | 12 | bb_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 @@ | |||
1 | extern void wibble(void); | ||
2 | void wibble(void) {} | ||