Rollup merge of #77703 - Keruspe:system-libunwind, r=Mark-Simulacrum
add system-llvm-libunwind config option allows using the system-wide llvm-libunwind as the unwinder Workaround for #76020
This commit is contained in:
commit
2c307fab49
8 changed files with 58 additions and 9 deletions
|
@ -527,7 +527,8 @@ changelog-seen = 2
|
||||||
#test-compare-mode = false
|
#test-compare-mode = false
|
||||||
|
|
||||||
# Use LLVM libunwind as the implementation for Rust's unwinder.
|
# Use LLVM libunwind as the implementation for Rust's unwinder.
|
||||||
#llvm-libunwind = false
|
# Accepted values are 'in-tree' (formerly true), 'system' or 'no' (formerly false).
|
||||||
|
#llvm-libunwind = 'no'
|
||||||
|
|
||||||
# Enable Windows Control Flow Guard checks in the standard library.
|
# Enable Windows Control Flow Guard checks in the standard library.
|
||||||
# This only applies from stage 1 onwards, and only for Windows targets.
|
# This only applies from stage 1 onwards, and only for Windows targets.
|
||||||
|
|
|
@ -61,6 +61,7 @@ profiler = ["profiler_builtins"]
|
||||||
compiler-builtins-c = ["alloc/compiler-builtins-c"]
|
compiler-builtins-c = ["alloc/compiler-builtins-c"]
|
||||||
compiler-builtins-mem = ["alloc/compiler-builtins-mem"]
|
compiler-builtins-mem = ["alloc/compiler-builtins-mem"]
|
||||||
llvm-libunwind = ["unwind/llvm-libunwind"]
|
llvm-libunwind = ["unwind/llvm-libunwind"]
|
||||||
|
system-llvm-libunwind = ["unwind/system-llvm-libunwind"]
|
||||||
|
|
||||||
# Make panics and failed asserts immediately abort without formatting any message
|
# Make panics and failed asserts immediately abort without formatting any message
|
||||||
panic_immediate_abort = ["core/panic_immediate_abort"]
|
panic_immediate_abort = ["core/panic_immediate_abort"]
|
||||||
|
|
|
@ -27,6 +27,7 @@ backtrace = ["std/backtrace"]
|
||||||
compiler-builtins-c = ["std/compiler-builtins-c"]
|
compiler-builtins-c = ["std/compiler-builtins-c"]
|
||||||
compiler-builtins-mem = ["std/compiler-builtins-mem"]
|
compiler-builtins-mem = ["std/compiler-builtins-mem"]
|
||||||
llvm-libunwind = ["std/llvm-libunwind"]
|
llvm-libunwind = ["std/llvm-libunwind"]
|
||||||
|
system-llvm-libunwind = ["std/system-llvm-libunwind"]
|
||||||
panic-unwind = ["std/panic_unwind"]
|
panic-unwind = ["std/panic_unwind"]
|
||||||
panic_immediate_abort = ["std/panic_immediate_abort"]
|
panic_immediate_abort = ["std/panic_immediate_abort"]
|
||||||
profiler = ["std/profiler"]
|
profiler = ["std/profiler"]
|
||||||
|
|
|
@ -23,3 +23,4 @@ cc = { version = "1.0.1" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
llvm-libunwind = []
|
llvm-libunwind = []
|
||||||
|
system-llvm-libunwind = []
|
||||||
|
|
|
@ -45,10 +45,24 @@ extern "C" {}
|
||||||
// When building with crt-static, we get `gcc_eh` from the `libc` crate, since
|
// When building with crt-static, we get `gcc_eh` from the `libc` crate, since
|
||||||
// glibc needs it, and needs it listed later on the linker command line. We
|
// glibc needs it, and needs it listed later on the linker command line. We
|
||||||
// don't want to duplicate it here.
|
// don't want to duplicate it here.
|
||||||
#[cfg(all(target_os = "linux", target_env = "gnu", not(feature = "llvm-libunwind")))]
|
#[cfg(all(
|
||||||
|
target_os = "linux",
|
||||||
|
target_env = "gnu",
|
||||||
|
not(feature = "llvm-libunwind"),
|
||||||
|
not(feature = "system-llvm-libunwind")
|
||||||
|
))]
|
||||||
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
|
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
|
||||||
extern "C" {}
|
extern "C" {}
|
||||||
|
|
||||||
|
#[cfg(all(
|
||||||
|
target_os = "linux",
|
||||||
|
target_env = "gnu",
|
||||||
|
not(feature = "llvm-libunwind"),
|
||||||
|
feature = "system-llvm-libunwind"
|
||||||
|
))]
|
||||||
|
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
|
||||||
|
extern "C" {}
|
||||||
|
|
||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
#[link(name = "gcc_eh", kind = "static-nobundle", cfg(target_feature = "crt-static"))]
|
#[link(name = "gcc_eh", kind = "static-nobundle", cfg(target_feature = "crt-static"))]
|
||||||
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
|
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
|
||||||
|
|
|
@ -10,6 +10,7 @@ use std::ffi::OsString;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::cache::{Interned, INTERNER};
|
use crate::cache::{Interned, INTERNER};
|
||||||
use crate::flags::Flags;
|
use crate::flags::Flags;
|
||||||
|
@ -65,7 +66,7 @@ pub struct Config {
|
||||||
pub rustc_error_format: Option<String>,
|
pub rustc_error_format: Option<String>,
|
||||||
pub json_output: bool,
|
pub json_output: bool,
|
||||||
pub test_compare_mode: bool,
|
pub test_compare_mode: bool,
|
||||||
pub llvm_libunwind: bool,
|
pub llvm_libunwind: Option<LlvmLibunwind>,
|
||||||
|
|
||||||
pub on_fail: Option<String>,
|
pub on_fail: Option<String>,
|
||||||
pub stage: u32,
|
pub stage: u32,
|
||||||
|
@ -177,6 +178,32 @@ pub struct Config {
|
||||||
pub out: PathBuf,
|
pub out: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
pub enum LlvmLibunwind {
|
||||||
|
No,
|
||||||
|
InTree,
|
||||||
|
System,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for LlvmLibunwind {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::No
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for LlvmLibunwind {
|
||||||
|
type Err = String;
|
||||||
|
|
||||||
|
fn from_str(value: &str) -> Result<Self, Self::Err> {
|
||||||
|
match value {
|
||||||
|
"no" => Ok(Self::No),
|
||||||
|
"in-tree" => Ok(Self::InTree),
|
||||||
|
"system" => Ok(Self::System),
|
||||||
|
invalid => Err(format!("Invalid value '{}' for rust.llvm-libunwind config.", invalid)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct TargetSelection {
|
pub struct TargetSelection {
|
||||||
pub triple: Interned<String>,
|
pub triple: Interned<String>,
|
||||||
|
@ -457,7 +484,7 @@ struct Rust {
|
||||||
remap_debuginfo: Option<bool>,
|
remap_debuginfo: Option<bool>,
|
||||||
jemalloc: Option<bool>,
|
jemalloc: Option<bool>,
|
||||||
test_compare_mode: Option<bool>,
|
test_compare_mode: Option<bool>,
|
||||||
llvm_libunwind: Option<bool>,
|
llvm_libunwind: Option<String>,
|
||||||
control_flow_guard: Option<bool>,
|
control_flow_guard: Option<bool>,
|
||||||
new_symbol_mangling: Option<bool>,
|
new_symbol_mangling: Option<bool>,
|
||||||
}
|
}
|
||||||
|
@ -799,7 +826,9 @@ impl Config {
|
||||||
set(&mut config.rust_rpath, rust.rpath);
|
set(&mut config.rust_rpath, rust.rpath);
|
||||||
set(&mut config.jemalloc, rust.jemalloc);
|
set(&mut config.jemalloc, rust.jemalloc);
|
||||||
set(&mut config.test_compare_mode, rust.test_compare_mode);
|
set(&mut config.test_compare_mode, rust.test_compare_mode);
|
||||||
set(&mut config.llvm_libunwind, rust.llvm_libunwind);
|
config.llvm_libunwind = rust
|
||||||
|
.llvm_libunwind
|
||||||
|
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
|
||||||
set(&mut config.backtrace, rust.backtrace);
|
set(&mut config.backtrace, rust.backtrace);
|
||||||
set(&mut config.channel, rust.channel);
|
set(&mut config.channel, rust.channel);
|
||||||
set(&mut config.rust_dist_src, rust.dist_src);
|
set(&mut config.rust_dist_src, rust.dist_src);
|
||||||
|
|
|
@ -65,7 +65,7 @@ v("llvm-cflags", "llvm.cflags", "build LLVM with these extra compiler flags")
|
||||||
v("llvm-cxxflags", "llvm.cxxflags", "build LLVM with these extra compiler flags")
|
v("llvm-cxxflags", "llvm.cxxflags", "build LLVM with these extra compiler flags")
|
||||||
v("llvm-ldflags", "llvm.ldflags", "build LLVM with these extra linker flags")
|
v("llvm-ldflags", "llvm.ldflags", "build LLVM with these extra linker flags")
|
||||||
|
|
||||||
o("llvm-libunwind", "rust.llvm-libunwind", "use LLVM libunwind")
|
v("llvm-libunwind", "rust.llvm-libunwind", "use LLVM libunwind")
|
||||||
|
|
||||||
# Optimization and debugging options. These may be overridden by the release
|
# Optimization and debugging options. These may be overridden by the release
|
||||||
# channel, etc.
|
# channel, etc.
|
||||||
|
|
|
@ -121,7 +121,7 @@ use std::os::windows::fs::symlink_file;
|
||||||
use build_helper::{mtime, output, run, run_suppressed, t, try_run, try_run_suppressed};
|
use build_helper::{mtime, output, run, run_suppressed, t, try_run, try_run_suppressed};
|
||||||
use filetime::FileTime;
|
use filetime::FileTime;
|
||||||
|
|
||||||
use crate::config::TargetSelection;
|
use crate::config::{LlvmLibunwind, TargetSelection};
|
||||||
use crate::util::{exe, libdir, CiEnv};
|
use crate::util::{exe, libdir, CiEnv};
|
||||||
|
|
||||||
mod builder;
|
mod builder;
|
||||||
|
@ -540,8 +540,10 @@ impl Build {
|
||||||
fn std_features(&self) -> String {
|
fn std_features(&self) -> String {
|
||||||
let mut features = "panic-unwind".to_string();
|
let mut features = "panic-unwind".to_string();
|
||||||
|
|
||||||
if self.config.llvm_libunwind {
|
match self.config.llvm_libunwind.unwrap_or_default() {
|
||||||
features.push_str(" llvm-libunwind");
|
LlvmLibunwind::InTree => features.push_str(" llvm-libunwind"),
|
||||||
|
LlvmLibunwind::System => features.push_str(" system-llvm-libunwind"),
|
||||||
|
LlvmLibunwind::No => {}
|
||||||
}
|
}
|
||||||
if self.config.backtrace {
|
if self.config.backtrace {
|
||||||
features.push_str(" backtrace");
|
features.push_str(" backtrace");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue