Skip to content

Commit 5b24cc1

Browse files
committed
windows-gnullvm: Avoid linking to libunwind statically
Avoid linking against the static variant of libunwind, which is not always available. Instead, prefer to use the unwind library from the toolchain, which the linker will automatically include, depending on what's available, and depending on the crt-static feature.
1 parent d3d145e commit 5b24cc1

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ pub fn opts() -> TargetOptions {
66
// as a path since it's not added to linker search path by the default.
77
// There were attempts to make it behave like libgcc (so one can just use -l<name>)
88
// but LLVM maintainers rejected it: https://reviews.llvm.org/D51440
9-
let pre_link_args = TargetOptions::link_args(
10-
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
11-
&["-nolibc", "--unwindlib=none"],
12-
);
9+
let pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-nolibc"]);
1310
// Order of `late_link_args*` does not matter with LLD.
1411
let late_link_args = TargetOptions::link_args(
1512
LinkerFlavor::Gnu(Cc::Yes, Lld::No),

library/unwind/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(link_cfg)]
44
#![feature(staged_api)]
55
#![feature(c_unwind)]
6-
#![cfg_attr(bootstrap, feature(cfg_target_abi))]
76
#![feature(strict_provenance)]
87
#![cfg_attr(not(target_env = "msvc"), feature(libc))]
98
#![allow(internal_features)]

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)