Skip to content

rustc fails to build with in-tree libunwind and lld #93349

Closed
@gburgessiv

Description

@gburgessiv

Trying to build rustc on Debian with the following config used to work, but now fails:

changelog-seen = 2

[llvm]
ninja = true

[rust]
use-lld = true
llvm-libunwind = 'in-tree'

./x.py build exits with:

error: linking with `cc` failed: exit status: 1                                                                       
  |                                                                                                                   
  = note: "cc" "-m64" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_main-f54cdb57b4be29de.rustc_main.fcfbea46-cgu.0.rcgu.o" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_main-f54cdb57b4be29de.rustc_main.fcfbea46-cgu.1.rcgu.o" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/re
lease/deps/rustc_main-f54cdb57b4be29de.rustc_main.fcfbea46-cgu.2.rcgu.o" "-Wl,--as-needed" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/psm-b9043e4a2f1f60fc/out" "-L" "/home/george/code/g
ithub/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/rustc_llvm-bb58500732d87599/out" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/llvm/build/lib" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_driver-823f1
f0eeb9a9bf8" "-Wl,--start-group" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-2b94913ec1c710dc" "-Wl,--end-group" "-Wl,-Bstatic" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-4ab75a05eb98bf89.rlib" "-Wl,-Bdynamic" "-lrt" "-ldl" "-lpthread" "-lm" "-lz" "-lstdc++" "-ldl" "-lutil" "-lrt" "-lpthrea
d" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_main-f54cdb57b4be29de" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs" "-Wl,-z,origin" "-Wl,-rpath,$ORIGIN/../lib" "-fuse-ld=lld"
  = note: ld.lld: error: /home/george/code/github/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_driver-823f1f0eeb9a9bf8.so: undefined reference to _Unwind_Backtrace [--no-allow-shlib-undefined]

git bisect points to 1c07096 as the culprit. It seems that the changes to libunwind.rs at line 237 accidentally dropped #[link(name = "unwind", kind = "static")] from _Unwind_Backtrace; readding this attribute allows rustc to build successfully.

I have a fix for this I'll upload shortly; just wanted to file an issue to reference first. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions