Repository navigation
Closed
Labels
0.kind: bugSomething is broken
Description
Nixpkgs version
- Unstable (26.11)
Describe the bug
Due to a bug in LLVM's LLD source code, the linker provided by the result package mal-function, breaking packages compiled with it (e.g., nix-cachyos-kernel's linux-cachyos-bore-lto-x86_64-v3).
Such issue has been fixed in the upstream's main branch, but they have not yet backported to the release/21.x.
lld_22 already carries the fix.
Steps to reproduce
#!/usr/bin/env bash
# nixpkgs lld_21 corrupts `ld -r` (partial link) output.
#
# lld writes unnamed local STT_SECTION symbols with st_shndx=SHN_UNDEF into
# relocatable output. Linking that object then fails with an empty symbol name:
# ld.lld: error: undefined symbol:
# Nondeterministic: rerun to see the count change.
#
# Current output:
#
# AFFECTED (github:NixOS/nixpkgs/17841f937d296c623ce015c56fe3fa89e3d52107)
# lld : /nix/store/kznq2iav6pjmbfffh5hba1nkbvxakayj-lld-21.1.8/bin/ld.lld
# bogus syms/run : nonzero, and differs between runs (same input, same command)
# final link : ld.lld: error: undefined symbol:
# BASELINE (github:NixOS/nixpkgs/nixos-26.05)
# lld : /nix/store/ssd7jccwsqig3pf9qgxwpps9vm3y9kzj-lld-21.1.8/bin/ld.lld
# bogus syms/run : always 0
# final link : (linked OK)
#
# This reproducer script is generated with claude-code
# Assisted-by: claude-code: claude-opus-5
set -euo pipefail
# For specific revision, use github:NixOS/nixpkgs/17841f937d296c623ce015c56fe3fa89e3d52107
AFFECTED=${AFFECTED:-github:NixOS/nixpkgs/nixos-unstable} # stdenv gcc 16.2.0
BASELINE=${BASELINE:-github:NixOS/nixpkgs/nixos-26.05} # stdenv gcc 15.3.0
RUNS=${RUNS:-20}
work=$(mktemp -d); trap 'rm -rf "$work"' EXIT; cd "$work"
# 24 TUs x 60 functions, each in its own section -> many output sections,
# so `-r` creates many STT_SECTION symbols via lld's addSectionSymbols().
awk 'BEGIN{
for (f=0; f<24; f++) { out = "m" f ".c"
for (i=0; i<60; i++) {
printf "static const char *const s%d_%d[]={\"x%d\",\"y%d\",\"z%d\"};\n", f,i,i,i,i > out
printf "const char *fn%d_%d(int k){return s%d_%d[k&3];}\n", f,i,f,i > out
printf "int dv%d_%d=%d;\nconst char *gv%d_%d=\"g%d\";\n", f,i,i,f,i,i > out
} } }'
printf 'extern const char *fn0_0(int);\nint main(void){return fn0_0(1)!=0;}\n' > drv.c
# Compile once, with a fixed clang: the linker is the only variable.
nix --extra-experimental-features "nix-command flakes" shell "$WORKING#clang_21" --command bash -c '
for f in m*.c drv.c; do clang -O2 -ffunction-sections -fdata-sections -c "$f" -o "${f%.c}.o"; done'
probe() {
local label=$1 flake=$2 counts="" lderr=""
local lld; lld=$(nix --extra-experimental-features "nix-command flakes" build --no-link --print-out-paths "$flake#lld_21")/bin/ld.lld
local relf; relf=$(nix --extra-experimental-features "nix-command flakes" build --no-link --print-out-paths "$flake#llvm_21")/bin/llvm-readelf
for _ in $(seq "$RUNS"); do
"$lld" -r -o out.o m*.o
counts+=" $("$relf" --syms out.o 2>/dev/null | awk '$7=="UND" && $4=="SECTION"' | wc -l)"
done
if "$lld" out.o drv.o -o exe >ld.log 2>&1; then lderr="(linked OK)"
else lderr=$(grep -m1 "undefined symbol" ld.log || echo "(link failed, see log)"); fi
printf '%s\n lld : %s\n bogus syms/run :%s\n final link : %s\n' \
"$label" "$lld" "$counts" "$lderr"
}
probe " AFFECTED ($AFFECTED)" "$AFFECTED"
probe "BASELINE ($BASELINE)" "$BASELINE"Expected behaviour
AFFECTED (github:NixOS/nixpkgs/nixos-unstable)
lld : ...
bogus syms/run : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
final link : (linked OK)
BASELINE (github:NixOS/nixpkgs/nixos-26.05)
lld : /nix/store/ssd7jccw…-lld-21.1.8/bin/ld.lld
bogus syms/run : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
final link : (linked OK)
Screenshots
No response
Relevant log output
# Tail of `nix log /nix/store/34331vlhlh72l4n3lm1bxlj8j246l8mv-linux-cachyos-bore-lto-x86_64-v3-7.2.9.drv`
INSTALL libsubcmd_headers
HOSTCC /build/linux-src-patched/build/tools/bpf/resolve_btfids/main.o
HOSTCC /build/linux-src-patched/build/tools/bpf/resolve_btfids/rbtree.o
HOSTCC /build/linux-src-patched/build/tools/bpf/resolve_btfids/zalloc.o
HOSTCC /build/linux-src-patched/build/tools/bpf/resolve_btfids/string.o
HOSTCC /build/linux-src-patched/build/tools/bpf/resolve_btfids/ctype.o
HOSTCC /build/linux-src-patched/build/tools/bpf/resolve_btfids/str_error_r.o
HOSTLD /build/linux-src-patched/build/tools/bpf/resolve_btfids/resolve_btfids-in.o
LINK resolve_btfids
ld.lld: error: undefined symbol:
>>> referenced by btf_relocate.c
>>> libbpf-in.o:(attach_type_name.rel) in archive /build/linux-src-patched/build/tools/bpf/resolve_btfids//libbpf/libbpf.a
>>> referenced by btf_relocate.c
>>> libbpf-in.o:(link_type_name.rel) in archive /build/linux-src-patched/build/tools/bpf/resolve_btfids//libbpf/libbpf.a
>>> referenced by btf_relocate.c
>>> libbpf-in.o:(map_type_name.rel) in archive /build/linux-src-patched/build/tools/bpf/resolve_btfids//libbpf/libbpf.a
>>> referenced 295 more times
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [Makefile:94: /build/linux-src-patched/build/tools/bpf/resolve_btfids//resolve_btfids] Error 1
make[3]: *** [Makefile:77: bpf/resolve_btfids] Error 2
make[2]: *** [/build/linux-src-patched/Makefile:1610: tools/bpf/resolve_btfids] Error 2
make[1]: *** [/build/linux-src-patched/Makefile:248: __sub-make] Error 2
make[1]: Leaving directory '/build/linux-src-patched/build'
make: *** [Makefile:248: __sub-make] Error 2Additional context
No response
System metadata
- system:
"x86_64-linux" - host os:
Linux 7.2.7-cachyos-lto, NixOS, 26.05 (Yarara), 26.05.20260922.1bc55b9 - multi-user?:
yes - sandbox:
yes - version:
nix-env (Nix) 2.34.8 - nixpkgs:
/nix/store/f7bkp7s16ysiqxr9p0s9pvhb018rcmr8-source
Notify maintainers
lld: @RossComputerGuy @alyssais @Ericson2314 @emilazy @peterwaller-arm @rrbutani @balsoft @andir @pyrox0
gcc16: @vcunat @Ericson2314 @balsoft @andir @pyrox0
Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)
I assert that this issue is relevant for Nixpkgs
- I assert that this is a bug and not a support request.
- I assert that this is not a duplicate of an existing issue.
- I assert that I have read the NixOS Code of Conduct and agree to abide by it.
- I assert that I have read the automation/AI policy and that this issue report complies with it.
Is this issue important to you?
Add a 👍 reaction to issues you find important.
Reacted by Jason Bowman, 骑士姬 and Arbel Arad
Metadata
Metadata
Assignees
Labels
0.kind: bugSomething is broken
Activity
[-]llvmPackages.lld: LLD compiled with GCC 16 results in a broken linker during partial linking[/-][+]llvmPackages.lld: LLD 21 (`lld_21`) compiled with GCC 16 (`gcc16`) results in a broken linker during partial linking[/+]vcunat commentedon Oct 7, 2026
Does this PR resolve that bug, or is it another one? #568680
ShamrockLee commentedon Oct 7, 2026
I think it resolves the bug, but need to run the reproducing script with
AFFECTED=github:NixOS/nixpkgs/refs/pull/568680/headto make sure.ShamrockLee commentedon Oct 14, 2026
Running the repro script with
AFFECTED=github:NixOS/nixpkgs/refs/pull/568680/headconfirmed that PR #568680 addresses this issue.Symbolfields in the constructor #568680PR #568680 is merged, but lands on the
stagingbranch.Users and downstream projects will need to wait for it to land onto the
masterbranch.Alyssa Ross's pr-tracker: https://nixpk.gs/pr-tracker.html?pr=568680
fix(flake): stop holding nix-cachyos-kernel's nixpkgs at 2026-09-27
fix(flake): stop holding nix-cachyos-kernel's nixpkgs at 2026-09-27
fix(flake): stop holding nix-cachyos-kernel's nixpkgs at 2026-09-27