Skip to content

Commit 3314f9e

Browse files
committed
Enable llvm-libunwind by default for Hexagon targets
Fixes library linking issues where libgcc_s was incorrectly being linked instead of the appropriate LLVM runtime libraries for Hexagon targets. * Set llvm-libunwind as default for all hexagon targets in bootstrap * Exclude hexagon from automatic libgcc_s linking in unwind * Enable libunwind.a copying for hexagon targets * Remove manual library linking from hexagon target specification
1 parent ab67c37 commit 3314f9e

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

library/unwind/src/lib.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,28 @@ cfg_select! {
7373
}
7474
_ => {
7575
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
76-
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
76+
#[link(name = "gcc_s", cfg(all(not(target_feature = "crt-static"), not(target_arch = "hexagon"))))]
7777
unsafe extern "C" {}
7878
}
7979
}
8080

81+
// Hexagon with musl uses llvm-libunwind by default
82+
#[cfg(all(target_env = "musl", target_arch = "hexagon"))]
83+
cfg_select! {
84+
feature = "llvm-libunwind" => {
85+
#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
86+
unsafe extern "C" {}
87+
}
88+
feature = "system-llvm-libunwind" => {
89+
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
90+
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
91+
unsafe extern "C" {}
92+
}
93+
_ => {
94+
// Fallback: should not happen since hexagon defaults to llvm-libunwind
95+
}
96+
}
97+
8198
// This is the same as musl except that we default to using the system libunwind
8299
// instead of libgcc.
83100
#[cfg(target_env = "ohos")]

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,10 @@ fn copy_third_party_objects(
352352

353353
if target == "x86_64-fortanix-unknown-sgx"
354354
|| builder.config.llvm_libunwind(target) == LlvmLibunwind::InTree
355-
&& (target.contains("linux") || target.contains("fuchsia") || target.contains("aix"))
355+
&& (target.contains("linux")
356+
|| target.contains("fuchsia")
357+
|| target.contains("aix")
358+
|| target.contains("hexagon"))
356359
{
357360
let libunwind_path =
358361
copy_llvm_libunwind(builder, target, &builder.sysroot_target_libdir(*compiler, target));

src/bootstrap/src/core/config/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,7 @@ impl Config {
18351835
.get(&target)
18361836
.and_then(|t| t.llvm_libunwind)
18371837
.or(self.llvm_libunwind_default)
1838-
.unwrap_or(if target.contains("fuchsia") {
1838+
.unwrap_or(if target.contains("fuchsia") || target.contains("hexagon") {
18391839
LlvmLibunwind::InTree
18401840
} else {
18411841
LlvmLibunwind::No

0 commit comments

Comments
 (0)