-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
libunwind currently need a c/cpp library that provide _Unwind_* symbols to work. libgcc_s.so/libgcc_eh.a from gcc or libunwind.so/libunwind.a from llvm can provide those symbols.
The libunwind crate is built when compiler bootstrap, and there is a flag in config.toml that choose which implementation to use. User can't change the implementation after bootstrap ( unless build-std add a flag for this )
# Use LLVM libunwind as the implementation for Rust's unwinder.
# Accepted values are 'in-tree' (formerly true), 'system' or 'no' (formerly false).
#llvm-libunwind = 'no'
in-treewill enablellvm-libunwindfeature oflibunwindsystemwill enablesystem-llvm-libunwindfeature oflibunwindnowon't enable any feature oflibunwind
Ideally, the behavior of this flags would be:
in-treewill compile the intree copy of llvm-libunwind, and link it into libunwind.rlibsystemwill link thelibunwind.so/libunwind.afrom users' systemnowill link thelibgcc_s.so/libgcc_eh.afrom users' system
But the current situation is a mess:
The probems are:
- if user set
target-feature=+crt-static, glibc/uclibc will always linklibgcc_eh.abylibccrate, see Support static linking with glibc and target-feature=+crt-static #77386. Butlibunwind.ais still linked ifllvm-libunwindfeature is enabled:This is introduced in 8d2f80b.rust/library/unwind/src/libunwind.rs
Lines 80 to 84 in e43c200
#[cfg_attr( all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static") )] extern "C" { - musl target don't follow the
llvm-libunwindfeature andsystem-llvm-libunwindfeature. - when cc=clang, and
llvm-libunwindfeature is enabled, clang don't accept-std=c++11and cause bootstrap failed, see Building rustc in Clang 9.0 error: invalid argument '-std=c++11' not allowed with 'C' #69222 - Because musl target don't follow the
system-llvm-libunwindfeature at all, my previous PR Don't build in-tree llvm-libunwind if system-llvm-libunwind is enable #80818 break the unwinder if settarget-feature=+crt-staticand enablesystem-llvm-libunwindfeature. - Other target such as fuchsia or BSDs will also break if
system-llvm-libunwindfeature is enabled.
My suggestion:
- limit the
llvm-libunwind=systemoption to linux only, as all other system only have one working unwind implementation. ( some changes tobuild.rs) - musl target should follow the
llvm-libunwindfeature andsystem-llvm-libunwindfeature. ( some changes tolib.rs) - check whether 8d2f80b is unnecessary now
- fix Building rustc in Clang 9.0 error: invalid argument '-std=c++11' not allowed with 'C' #69222
sanmai-NL and purplesyringa
Metadata
Metadata
Assignees
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
