Skip to content

Commit 446c429

Browse files
author
Jethro Beekman
committed
Fix LLVM libunwind build for non-musl targets
Broken in rust-lang#85600
1 parent 9556d7a commit 446c429

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/bootstrap/compile.rs

+20-12
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ fn copy_and_stamp(
142142
target_deps.push((target, dependency_type));
143143
}
144144

145+
fn copy_llvm_libunwind(builder: &Builder<'_>, target: TargetSelection, libdir: &Path) -> PathBuf {
146+
let libunwind_path = builder.ensure(native::Libunwind { target });
147+
let libunwind_source = libunwind_path.join("libunwind.a");
148+
let libunwind_target = libdir.join("libunwind.a");
149+
builder.copy(&libunwind_source, &libunwind_target);
150+
libunwind_target
151+
}
152+
145153
/// Copies third party objects needed by various targets.
146154
fn copy_third_party_objects(
147155
builder: &Builder<'_>,
@@ -167,6 +175,15 @@ fn copy_third_party_objects(
167175
);
168176
}
169177

178+
if target == "x86_64-fortanix-unknown-sgx"
179+
|| builder.config.llvm_libunwind == LlvmLibunwind::InTree
180+
&& (target.contains("linux") || target.contains("fuchsia"))
181+
{
182+
let libunwind_path =
183+
copy_llvm_libunwind(builder, target, &builder.sysroot_libdir(*compiler, target));
184+
target_deps.push((libunwind_path, DependencyType::Target));
185+
}
186+
170187
target_deps
171188
}
172189

@@ -208,6 +225,9 @@ fn copy_self_contained_objects(
208225
builder.copy(&src, &target);
209226
target_deps.push((target, DependencyType::TargetSelfContained));
210227
}
228+
229+
let libunwind_path = copy_llvm_libunwind(builder, target, &libdir_self_contained);
230+
target_deps.push((libunwind_path, DependencyType::TargetSelfContained));
211231
} else if target.ends_with("-wasi") {
212232
let srcdir = builder
213233
.wasi_root(target)
@@ -234,18 +254,6 @@ fn copy_self_contained_objects(
234254
}
235255
}
236256

237-
if target.contains("musl")
238-
|| target.contains("x86_64-fortanix-unknown-sgx")
239-
|| builder.config.llvm_libunwind == LlvmLibunwind::InTree
240-
&& (target.contains("linux") || target.contains("fuchsia"))
241-
{
242-
let libunwind_path = builder.ensure(native::Libunwind { target });
243-
let libunwind_source = libunwind_path.join("libunwind.a");
244-
let libunwind_target = libdir_self_contained.join("libunwind.a");
245-
builder.copy(&libunwind_source, &libunwind_target);
246-
target_deps.push((libunwind_target, DependencyType::TargetSelfContained));
247-
}
248-
249257
target_deps
250258
}
251259

0 commit comments

Comments
 (0)