Skip to content

Commit b0062ca

Browse files
authored
Rollup merge of rust-lang#62477 - petrhosek:unwind-bootstrap, r=cramertj
Re-add bootstrap attribute to libunwind for llvm-libunwind feature This was removed in 8a7dded, but since rust-lang#62286 hasn't yet made it into beta, this is breaking the build with llvm-libunwind feature enabled. Furthemore, restrict the link attribute to Fuchsia and Linux, matching the logic in build.rs since llvm-libunwind feature isn't yet supported on other systems.
2 parents 264884d + 1dcee4c commit b0062ca

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/libunwind/build.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ fn main() {
44
println!("cargo:rerun-if-changed=build.rs");
55
let target = env::var("TARGET").expect("TARGET was not set");
66

7-
if cfg!(feature = "llvm-libunwind") &&
7+
// FIXME: the not(bootstrap) part is needed because of the issue addressed by #62286,
8+
// and could be removed once that change is in beta.
9+
if cfg!(all(not(bootstrap), feature = "llvm-libunwind")) &&
810
(target.contains("linux") ||
911
target.contains("fuchsia")) {
1012
// Build the unwinding from libunwind C/C++ source code.
11-
#[cfg(feature = "llvm-libunwind")]
13+
#[cfg(all(not(bootstrap), feature = "llvm-libunwind"))]
1214
llvm_libunwind::compile();
1315
} else if target.contains("linux") {
1416
if target.contains("musl") {
@@ -42,7 +44,7 @@ fn main() {
4244
}
4345
}
4446

45-
#[cfg(feature = "llvm-libunwind")]
47+
#[cfg(all(not(bootstrap), feature = "llvm-libunwind"))]
4648
mod llvm_libunwind {
4749
use std::env;
4850
use std::path::Path;

src/libunwind/libunwind.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ pub enum _Unwind_Context {}
6767

6868
pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn(unwind_code: _Unwind_Reason_Code,
6969
exception: *mut _Unwind_Exception);
70-
#[cfg_attr(feature = "llvm-libunwind",
70+
#[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind",
71+
any(target_os = "fuchsia", target_os = "linux")),
7172
link(name = "unwind", kind = "static"))]
7273
extern "C" {
7374
#[unwind(allowed)]
@@ -93,7 +94,8 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm
9394
}
9495
pub use _Unwind_Action::*;
9596

96-
#[cfg_attr(feature = "llvm-libunwind",
97+
#[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind",
98+
any(target_os = "fuchsia", target_os = "linux")),
9799
link(name = "unwind", kind = "static"))]
98100
extern "C" {
99101
pub fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word;
@@ -148,7 +150,8 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm
148150
pub const UNWIND_POINTER_REG: c_int = 12;
149151
pub const UNWIND_IP_REG: c_int = 15;
150152

151-
#[cfg_attr(feature = "llvm-libunwind",
153+
#[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind",
154+
any(target_os = "fuchsia", target_os = "linux")),
152155
link(name = "unwind", kind = "static"))]
153156
extern "C" {
154157
fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context,
@@ -212,7 +215,8 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm
212215
cfg_if::cfg_if! {
213216
if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] {
214217
// Not 32-bit iOS
215-
#[cfg_attr(feature = "llvm-libunwind",
218+
#[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind",
219+
any(target_os = "fuchsia", target_os = "linux")),
216220
link(name = "unwind", kind = "static"))]
217221
extern "C" {
218222
#[unwind(allowed)]
@@ -223,7 +227,8 @@ if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] {
223227
}
224228
} else {
225229
// 32-bit iOS uses SjLj and does not provide _Unwind_Backtrace()
226-
#[cfg_attr(feature = "llvm-libunwind",
230+
#[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind",
231+
any(target_os = "fuchsia", target_os = "linux")),
227232
link(name = "unwind", kind = "static"))]
228233
extern "C" {
229234
#[unwind(allowed)]

0 commit comments

Comments
 (0)