Skip to content

Commit bbb88ea

Browse files
authored
Rollup merge of #93604 - tmandry:libunwind-fuchsia-default, r=Mark-Simulacrum
Make llvm-libunwind a per-target option Fuchsia doesn't ship libunwind in its SDK, so we must provide it statically.
2 parents 6ac8ada + f1e3d40 commit bbb88ea

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

config.toml.example

+15-10
Original file line numberDiff line numberDiff line change
@@ -605,16 +605,9 @@ changelog-seen = 2
605605
# development of NLL
606606
#test-compare-mode = false
607607

608-
# Use LLVM libunwind as the implementation for Rust's unwinder.
609-
# Accepted values are 'in-tree' (formerly true), 'system' or 'no' (formerly false).
610-
# This option only applies for Linux and Fuchsia targets.
611-
# On Linux target, if crt-static is not enabled, 'no' means dynamic link to
612-
# `libgcc_s.so`, 'in-tree' means static link to the in-tree build of llvm libunwind
613-
# and 'system' means dynamic link to `libunwind.so`. If crt-static is enabled,
614-
# the behavior is depend on the libc. On musl target, 'no' and 'in-tree' both
615-
# means static link to the in-tree build of llvm libunwind, and 'system' means
616-
# static link to `libunwind.a` provided by system. Due to the limitation of glibc,
617-
# it must link to `libgcc_eh.a` to get a working output, and this option have no effect.
608+
# Global default for llvm-libunwind for all targets. See the target-specific
609+
# documentation for llvm-libunwind below. Note that the target-specific
610+
# option will override this if set.
618611
#llvm-libunwind = 'no'
619612

620613
# Enable Windows Control Flow Guard checks in the standard library.
@@ -671,6 +664,18 @@ changelog-seen = 2
671664
# not, you can specify an explicit file name for it.
672665
#llvm-filecheck = "/path/to/llvm-version/bin/FileCheck"
673666

667+
# Use LLVM libunwind as the implementation for Rust's unwinder.
668+
# Accepted values are 'in-tree' (formerly true), 'system' or 'no' (formerly false).
669+
# This option only applies for Linux and Fuchsia targets.
670+
# On Linux target, if crt-static is not enabled, 'no' means dynamic link to
671+
# `libgcc_s.so`, 'in-tree' means static link to the in-tree build of llvm libunwind
672+
# and 'system' means dynamic link to `libunwind.so`. If crt-static is enabled,
673+
# the behavior is depend on the libc. On musl target, 'no' and 'in-tree' both
674+
# means static link to the in-tree build of llvm libunwind, and 'system' means
675+
# static link to `libunwind.a` provided by system. Due to the limitation of glibc,
676+
# it must link to `libgcc_eh.a` to get a working output, and this option have no effect.
677+
#llvm-libunwind = 'no' if Linux, 'in-tree' if Fuchsia
678+
674679
# If this target is for Android, this option will be required to specify where
675680
# the NDK for the target lives. This is used to find the C compiler to link and
676681
# build native code.

src/bootstrap/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn copy_third_party_objects(
176176

177177
if target == "x86_64-fortanix-unknown-sgx"
178178
|| target.contains("pc-windows-gnullvm")
179-
|| builder.config.llvm_libunwind == LlvmLibunwind::InTree
179+
|| builder.config.llvm_libunwind(target) == LlvmLibunwind::InTree
180180
&& (target.contains("linux") || target.contains("fuchsia"))
181181
{
182182
let libunwind_path =

src/bootstrap/config.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ pub struct Config {
6767
pub rustc_error_format: Option<String>,
6868
pub json_output: bool,
6969
pub test_compare_mode: bool,
70-
pub llvm_libunwind: LlvmLibunwind,
7170
pub color: Color,
7271
pub patch_binaries_for_nix: bool,
7372

@@ -151,6 +150,7 @@ pub struct Config {
151150
pub rust_profile_generate: Option<String>,
152151
pub llvm_profile_use: Option<String>,
153152
pub llvm_profile_generate: bool,
153+
pub llvm_libunwind_default: Option<LlvmLibunwind>,
154154

155155
pub build: TargetSelection,
156156
pub hosts: Vec<TargetSelection>,
@@ -342,6 +342,7 @@ pub struct Target {
342342
pub llvm_config: Option<PathBuf>,
343343
/// Some(path to FileCheck) if one was specified.
344344
pub llvm_filecheck: Option<PathBuf>,
345+
pub llvm_libunwind: Option<LlvmLibunwind>,
345346
pub cc: Option<PathBuf>,
346347
pub cxx: Option<PathBuf>,
347348
pub ar: Option<PathBuf>,
@@ -680,6 +681,7 @@ define_config! {
680681
linker: Option<String> = "linker",
681682
llvm_config: Option<String> = "llvm-config",
682683
llvm_filecheck: Option<String> = "llvm-filecheck",
684+
llvm_libunwind: Option<String> = "llvm-libunwind",
683685
android_ndk: Option<String> = "android-ndk",
684686
sanitizers: Option<bool> = "sanitizers",
685687
profiler: Option<bool> = "profiler",
@@ -1043,10 +1045,6 @@ impl Config {
10431045
set(&mut config.rust_rpath, rust.rpath);
10441046
set(&mut config.jemalloc, rust.jemalloc);
10451047
set(&mut config.test_compare_mode, rust.test_compare_mode);
1046-
config.llvm_libunwind = rust
1047-
.llvm_libunwind
1048-
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"))
1049-
.unwrap_or_default();
10501048
set(&mut config.backtrace, rust.backtrace);
10511049
set(&mut config.channel, rust.channel);
10521050
config.description = rust.description;
@@ -1069,6 +1067,9 @@ impl Config {
10691067
config.rust_thin_lto_import_instr_limit = rust.thin_lto_import_instr_limit;
10701068
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);
10711069
set(&mut config.control_flow_guard, rust.control_flow_guard);
1070+
config.llvm_libunwind_default = rust
1071+
.llvm_libunwind
1072+
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
10721073

10731074
if let Some(ref backends) = rust.codegen_backends {
10741075
config.rust_codegen_backends =
@@ -1095,6 +1096,10 @@ impl Config {
10951096
if let Some(ref s) = cfg.llvm_filecheck {
10961097
target.llvm_filecheck = Some(config.src.join(s));
10971098
}
1099+
target.llvm_libunwind = cfg
1100+
.llvm_libunwind
1101+
.as_ref()
1102+
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
10981103
if let Some(ref s) = cfg.android_ndk {
10991104
target.ndk = Some(config.src.join(s));
11001105
}
@@ -1328,6 +1333,14 @@ impl Config {
13281333
self.rust_codegen_backends.contains(&INTERNER.intern_str("llvm"))
13291334
}
13301335

1336+
pub fn llvm_libunwind(&self, target: TargetSelection) -> LlvmLibunwind {
1337+
self.target_config
1338+
.get(&target)
1339+
.and_then(|t| t.llvm_libunwind)
1340+
.or(self.llvm_libunwind_default)
1341+
.unwrap_or(LlvmLibunwind::No)
1342+
}
1343+
13311344
pub fn submodules(&self, rust_info: &GitInfo) -> bool {
13321345
self.submodules.unwrap_or(rust_info.is_git())
13331346
}

src/bootstrap/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ impl Build {
720720
fn std_features(&self, target: TargetSelection) -> String {
721721
let mut features = "panic-unwind".to_string();
722722

723-
match self.config.llvm_libunwind {
723+
match self.config.llvm_libunwind(target) {
724724
LlvmLibunwind::InTree => features.push_str(" llvm-libunwind"),
725725
LlvmLibunwind::System => features.push_str(" system-llvm-libunwind"),
726726
LlvmLibunwind::No => {}

0 commit comments

Comments
 (0)