Skip to content

Commit

Permalink
Rollup merge of rust-lang#88483 - jethrogb:jb/llvm-libunwind-self-con…
Browse files Browse the repository at this point in the history
…tained, r=petrochenkov

Fix LLVM libunwind build for non-musl targets

Broken in rust-lang#85600. AFAICT, [only musl, mingw, and wasm](https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/compiler/rustc_target/src/spec/crt_objects.rs#L128-L132) should use the “self-contained” logic in rustbuild.
  • Loading branch information
m-ou-se committed Sep 3, 2021
2 parents cb2be32 + 446c429 commit 3ce205a
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ fn copy_and_stamp(
target_deps.push((target, dependency_type));
}

fn copy_llvm_libunwind(builder: &Builder<'_>, target: TargetSelection, libdir: &Path) -> PathBuf {
let libunwind_path = builder.ensure(native::Libunwind { target });
let libunwind_source = libunwind_path.join("libunwind.a");
let libunwind_target = libdir.join("libunwind.a");
builder.copy(&libunwind_source, &libunwind_target);
libunwind_target
}

/// Copies third party objects needed by various targets.
fn copy_third_party_objects(
builder: &Builder<'_>,
Expand All @@ -167,6 +175,15 @@ fn copy_third_party_objects(
);
}

if target == "x86_64-fortanix-unknown-sgx"
|| builder.config.llvm_libunwind == LlvmLibunwind::InTree
&& (target.contains("linux") || target.contains("fuchsia"))
{
let libunwind_path =
copy_llvm_libunwind(builder, target, &builder.sysroot_libdir(*compiler, target));
target_deps.push((libunwind_path, DependencyType::Target));
}

target_deps
}

Expand Down Expand Up @@ -208,6 +225,9 @@ fn copy_self_contained_objects(
builder.copy(&src, &target);
target_deps.push((target, DependencyType::TargetSelfContained));
}

let libunwind_path = copy_llvm_libunwind(builder, target, &libdir_self_contained);
target_deps.push((libunwind_path, DependencyType::TargetSelfContained));
} else if target.ends_with("-wasi") {
let srcdir = builder
.wasi_root(target)
Expand All @@ -234,18 +254,6 @@ fn copy_self_contained_objects(
}
}

if target.contains("musl")
|| target.contains("x86_64-fortanix-unknown-sgx")
|| builder.config.llvm_libunwind == LlvmLibunwind::InTree
&& (target.contains("linux") || target.contains("fuchsia"))
{
let libunwind_path = builder.ensure(native::Libunwind { target });
let libunwind_source = libunwind_path.join("libunwind.a");
let libunwind_target = libdir_self_contained.join("libunwind.a");
builder.copy(&libunwind_source, &libunwind_target);
target_deps.push((libunwind_target, DependencyType::TargetSelfContained));
}

target_deps
}

Expand Down

0 comments on commit 3ce205a

Please sign in to comment.