-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libtest
fails to link with lld
at main
#105967
Comments
Similar in nature to rust-lang/rust#105967 I was getting the following at the final chrome link stage :- ld.lld: error: version script assignment of 'global' to symbol \ '__libc_csu_fini' failed: symbol not defined ld.lld: error: version script assignment of 'global' to symbol \ '__libc_csu_init' failed: symbol not defined The explanation at https://reviews.llvm.org/D140591#4014995 seems to point to my self-compiled llvm/clang perhaps lacking one or both of libcxx and libcxxabi (-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"), which may have avoided the issue. Bundled clang users probably won't need to enable the patch.
I ran into this too. I wonder why rustc is attempting to export those symbols from |
This actually repros outside of Hopefully reproducing it outside of Rust's bootstrap will make it easier to debug. |
I suspect I found the issue: First, early in compilation rustc determines if a crate needs an allocator (whether or not it comes from the crate itself, or a dep). This is filled in a crate metadata struct field: rust/compiler/rustc_metadata/src/creader.rs Lines 39 to 41 in 0b439b1
If Later, rustc checks whether to codegen the rust/compiler/rustc_codegen_ssa/src/base.rs Lines 618 to 649 in 0b439b1
Notably, if any dependency is linked as a Independently, rustc determines which symbols to export when generating a rust/compiler/rustc_codegen_ssa/src/back/symbol_export.rs Lines 200 to 226 in 0b439b1
Notably it does not perform the check from the last step. Even if a @bjorn3 who helped in the Zulip discussion. Can you confirm this explanation makes sense? |
Most of it. There is a further complication that you can specify multiple crate types for a single compilation. It is then possible for some crate types to generate the allocator shim while others don't generate it. The list of exported symbols however is for all crate types at the same time. One way to fix this would be to have a separate list of exported symbols for each crate type. Another option would be to move the addition of the |
Listing exported symbols per crate type seems like the most correct fix in principle, but the lists will be almost the same except for the allocator symbols. I'll try to find a clean way to do the latter. |
@rustbot claim |
Add `--no-undefined-version` link flag and fix associated breakage LLVM upstream sets `--no-undefined-version` by default in lld: https://reviews.llvm.org/D135402. Due to a bug in how version scripts are generated, this breaks the `dylib` output type for most crates. See rust-lang#105967 (comment) for details. This PR adds the flag to gcc flavor linkers in anticipation of this LLVM change rolling in, and patches `rustc` to not attempt to export `__rust_*` allocator symbols when they weren't generated. Fixes rust-lang#105967
Add `--no-undefined-version` link flag and fix associated breakage LLVM upstream sets `--no-undefined-version` by default in lld: https://reviews.llvm.org/D135402. Due to a bug in how version scripts are generated, this breaks the `dylib` output type for most crates. See rust-lang#105967 (comment) for details. This PR adds the flag to gcc flavor linkers in anticipation of this LLVM change rolling in, and patches `rustc` to not attempt to export `__rust_*` allocator symbols when they weren't generated. Fixes rust-lang#105967
Add `--no-undefined-version` link flag and fix associated breakage LLVM upstream sets `--no-undefined-version` by default in lld: https://reviews.llvm.org/D135402. Due to a bug in how version scripts are generated, this breaks the `dylib` output type for most crates. See rust-lang#105967 (comment) for details. This PR adds the flag to gcc flavor linkers in anticipation of this LLVM change rolling in, and patches `rustc` to not attempt to export `__rust_*` allocator symbols when they weren't generated. Fixes rust-lang#105967
Add `--no-undefined-version` link flag and fix associated breakage LLVM upstream sets `--no-undefined-version` by default in lld: https://reviews.llvm.org/D135402. Due to a bug in how version scripts are generated, this breaks the `dylib` output type for most crates. See rust-lang#105967 (comment) for details. This PR adds the flag to gcc flavor linkers in anticipation of this LLVM change rolling in, and patches `rustc` to not attempt to export `__rust_*` allocator symbols when they weren't generated. Fixes rust-lang#105967
Add `--no-undefined-version` link flag and fix associated breakage LLVM upstream sets `--no-undefined-version` by default in lld: https://reviews.llvm.org/D135402. Due to a bug in how version scripts are generated, this breaks the `dylib` output type for most crates. See rust-lang/rust#105967 (comment) for details. This PR adds the flag to gcc flavor linkers in anticipation of this LLVM change rolling in, and patches `rustc` to not attempt to export `__rust_*` allocator symbols when they weren't generated. Fixes #105967
…ilding. Saw this in termux#18758. llvm appears to have upgraded a warning to an error (https://reviews.llvm.org/D135402), and while they're not wrong to do so, this package and others (rust-lang/rust#105967) depended on it. This is the simple fix, per the llvm reviews link. Fixes termux#18750.
…18813) Saw this in #18758. llvm appears to have upgraded a warning to an error (https://reviews.llvm.org/D135402), and while they're not wrong to do so, this package and others (rust-lang/rust#105967) depended on it. This is the simple fix, per the llvm reviews link. Fixes #18750 [skip ci]
…(#18813) Saw this in #18758. llvm appears to have upgraded a warning to an error (https://reviews.llvm.org/D135402), and while they're not wrong to do so, this package and others (rust-lang/rust#105967) depended on it. This is the simple fix, per the llvm reviews link. Fixes #18750 [skip ci]
…(#18813) Saw this in #18758. llvm appears to have upgraded a warning to an error (https://reviews.llvm.org/D135402), and while they're not wrong to do so, this package and others (rust-lang/rust#105967) depended on it. This is the simple fix, per the llvm reviews link. Fixes #18750 [skip ci]
…(#18813) Saw this in #18758. llvm appears to have upgraded a warning to an error (https://reviews.llvm.org/D135402), and while they're not wrong to do so, this package and others (rust-lang/rust#105967) depended on it. This is the simple fix, per the llvm reviews link. Fixes #18750 [skip ci]
…ermux#18813) Saw this in termux#18758. llvm appears to have upgraded a warning to an error (https://reviews.llvm.org/D135402), and while they're not wrong to do so, this package and others (rust-lang/rust#105967) depended on it. This is the simple fix, per the llvm reviews link. Fixes termux#18750 [skip ci]
Building Rust toolchain using latest
lld
linker at hash6443c0ee02c7785bc917fcf508f4cc7ded38487a
leads to an error when compiling libtest at stage0: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.The text was updated successfully, but these errors were encountered: