Skip to content

libtest fails to link with lld at main #105967

Closed
@andrewpollack

Description

@andrewpollack

Building Rust toolchain using latest lld linker at hash 6443c0ee02c7785bc917fcf508f4cc7ded38487a leads to an error when compiling libtest at stage0:

Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compiling cc v1.0.76
   Compiling core v0.0.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/core)
   Compiling libc v0.2.138
   Compiling memchr v2.5.0
   Compiling std v0.0.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/std)
   Compiling compiler_builtins v0.1.85
   Compiling unwind v0.0.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/unwind)
   Compiling profiler_builtins v0.0.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/profiler_builtins)
   Compiling rustc-std-workspace-core v1.99.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/alloc)
   Compiling cfg-if v1.0.0
   Compiling adler v1.0.2
   Compiling rustc-demangle v0.1.21
   Compiling rustc-std-workspace-alloc v1.99.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/rustc-std-workspace-alloc)
   Compiling panic_abort v0.0.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/panic_abort)
   Compiling panic_unwind v0.0.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/panic_unwind)
   Compiling gimli v0.26.1
   Compiling miniz_oxide v0.5.3
   Compiling std_detect v0.1.5 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/stdarch/crates/std_detect)
   Compiling hashbrown v0.12.3
   Compiling object v0.29.0
   Compiling addr2line v0.17.0
   Compiling rustc-std-workspace-std v1.99.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/rustc-std-workspace-std)
   Compiling proc_macro v0.0.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/proc_macro)
   Compiling unicode-width v0.1.10
   Compiling getopts v0.2.21
   Compiling test v0.0.0 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/test)
error: linking with `/b/s/w/ir/x/w/cipd/bin/clang++` failed: exit status: 1
  |
  = note: "/b/s/w/ir/x/w/cipd/bin/clang++" "-Wl,--version-script=/b/s/w/ir/x/t/rustctgpUpK/list" "-m64" "/b/s/w/ir/x/t/rustctgpUpK/symbols.o" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/test-3bd20e94ef73cd68.test.d3d4ef93-cgu.0.rcgu.o" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/test-3bd20e94ef73cd68.1w1vzuec12odskdf.rcgu.rmeta" "-Wl,--as-needed" "-L" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps" "-L" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/release/deps" "-L" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/build/compiler_builtins-1f459caf2b14046b/out" "-L" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/build/profiler_builtins-a255468473e62d4f/out" "-L" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/libgetopts-023b5f868ec7a238.rlib" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/libunicode_width-e0099b6d5dcba458.rlib" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/librustc_std_workspace_std-8f7f1564c2f2e122.rlib" "-L" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps" "-Wl,-Bdynamic" "-lstd-77833ca844ade20f" "-Wl,-Bstatic" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-63346244df871953.rlib" "-Wl,-Bdynamic" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/b/s/w/ir/x/w/staging/build/fuchsia-build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/libtest-3bd20e94ef73cd68.so" "-shared" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs" "--target=x86_64-unknown-linux-gnu" "--sysroot=/b/s/w/ir/x/w/cipd/linux" "-fuse-ld=lld" "-Wl,-z,origin" "-Wl,-rpath,$ORIGIN/../lib"
  = note: ld.lld: error: version script assignment of 'global' to symbol '__rust_alloc' failed: symbol not defined
          ld.lld: error: version script assignment of 'global' to symbol '__rust_alloc_error_handler_should_panic' failed: symbol not defined
          ld.lld: error: version script assignment of 'global' to symbol '__rust_alloc_zeroed' failed: symbol not defined
          ld.lld: error: version script assignment of 'global' to symbol '__rust_dealloc' failed: symbol not defined
          ld.lld: error: version script assignment of 'global' to symbol '__rust_realloc' failed: symbol not defined
          clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
          
error: could not compile `test` due to previous error

Error is coming from https://reviews.llvm.org/D135402 (Enable --no-undefined-version by default.), with the description indicating that our version scripts were not correct.

Local workaround is to pass -Clink-arg=-Wl,--undefined-version in Rustflags.

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions