Skip to content

build: stop passing loader_options.ld twice to the linker#1409

Open
gburd wants to merge 1 commit into
cloudius-systems:masterfrom
gburd:pr/linker-loader-options-dedup
Open

build: stop passing loader_options.ld twice to the linker#1409
gburd wants to merge 1 commit into
cloudius-systems:masterfrom
gburd:pr/linker-loader-options-dedup

Conversation

@gburd

@gburd gburd commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

arch/x64/loader.ld includes loader_options.ld with an INCLUDE
directive (added in 0b8eb87). The loader.elf and zfs_builder.elf
link rules also list $(loader_options_dep) as a prerequisite, and the
link line runs $(patsubst %.ld,-T %.ld,$^) over the whole prerequisite
list, so loader_options.ld is also passed as -T loader_options.ld
on the ld command line.

Older binutils tolerated the same linker script being pulled in twice.
binutils 2.46 does not — it errors with:

loader_options.ld appears multiple times

which breaks the build on any toolchain shipping binutils >= 2.46.

Fix

Filter loader_options.ld out of the -T patsubst input in both link
rules, while keeping it as a prerequisite so a change to its generated
contents (APP_LOCAL_EXEC_TLS_SIZE) still forces a relink. The INCLUDE
inside loader.ld continues to resolve it via the existing
-L$(out)/arch/$(arch) search path, so nothing is lost.

Test plan

  • make build/release.x64/loader.elf links cleanly under binutils 2.46 (previously failed with "appears multiple times")
  • make build/release.x64/zfs_builder.elf links cleanly under binutils 2.46
  • Diff is two lines, no behavioral change beyond removing the duplicate -T

loader.ld already pulls in loader_options.ld via INCLUDE, but the
loader.elf and zfs_builder.elf link rules also list loader_options.ld as
a prerequisite, so the $(patsubst %.ld,-T %.ld,$^) turns it into a second
-T loader_options.ld on the ld command line. binutils 2.46 rejects a
linker script that is included more than once ("loader_options.ld appears
multiple times"), breaking the build.

Filter loader_options.ld out of the -T patsubst input while keeping it as
a prerequisite (so a change to its contents still forces a relink). The
INCLUDE inside loader.ld resolves it via the existing -L search path.

Verified: loader.elf and zfs_builder.elf both link cleanly under
binutils 2.46 with the aws driver profile.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant