Skip to content

Commit 60f611e

Browse files
Rollup merge of rust-lang#122003 - mati865:gnullvm-build-libunwind, r=petrochenkov
link libunwind dynamically and allow controlling it via `crt-static` on gnullvm targets Alternative to rust-lang#121794 ``` $ cargo b -r Finished `release` profile [optimized] target(s) in 0.38s $ ntldd target/release/hello.exe | rg unwind libunwind.dll => H:\msys64\clang64\bin\libunwind.dll (0x0000020c35df0000) $ RUSTFLAGS="-C target-feature=+crt-static" cargo b -r Finished `release` profile [optimized] target(s) in 0.23s $ ntldd target/release/hello.exe | rg unwind ```
2 parents 21fe748 + d442cf5 commit 60f611e

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

compiler/rustc_target/src/spec/base/windows_gnullvm.rs

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ pub(crate) fn opts() -> TargetOptions {
4242
eh_frame_header: false,
4343
no_default_libraries: false,
4444
has_thread_local: true,
45+
crt_static_allows_dylibs: true,
46+
crt_static_respected: true,
4547
// FIXME(davidtwco): Support Split DWARF on Windows GNU - may require LLVM changes to
4648
// output DWO, despite using DWARF, doesn't use ELF..
4749
debuginfo_kind: DebuginfoKind::Pdb,

library/unwind/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,8 @@ cfg_if::cfg_if! {
178178
#[cfg(target_os = "hurd")]
179179
#[link(name = "gcc_s")]
180180
extern "C" {}
181+
182+
#[cfg(all(target_os = "windows", target_env = "gnu", target_abi = "llvm"))]
183+
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
184+
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
185+
extern "C" {}

library/unwind/src/libunwind.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,9 @@ pub type _Unwind_Exception_Cleanup_Fn =
102102
// rustc_codegen_ssa::src::back::symbol_export, rustc_middle::middle::exported_symbols
103103
// and RFC 2841
104104
#[cfg_attr(
105-
any(
106-
all(
107-
feature = "llvm-libunwind",
108-
any(target_os = "fuchsia", target_os = "linux", target_os = "xous")
109-
),
110-
all(target_os = "windows", target_env = "gnu", target_abi = "llvm")
105+
all(
106+
feature = "llvm-libunwind",
107+
any(target_os = "fuchsia", target_os = "linux", target_os = "xous")
111108
),
112109
link(name = "unwind", kind = "static", modifiers = "-bundle")
113110
)]

0 commit comments

Comments
 (0)