Skip to content

Commit cc68f22

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 0208ee0 commit cc68f22

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
@@ -354,7 +354,10 @@ fn copy_third_party_objects(
354354

355355
if target == "x86_64-fortanix-unknown-sgx"
356356
|| builder.config.llvm_libunwind(target) == LlvmLibunwind::InTree
357-
&& (target.contains("linux") || target.contains("fuchsia") || target.contains("aix"))
357+
&& (target.contains("linux")
358+
|| target.contains("fuchsia")
359+
|| target.contains("aix")
360+
|| target.contains("hexagon"))
358361
{
359362
let libunwind_path =
360363
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
@@ -1851,7 +1851,7 @@ impl Config {
18511851
.get(&target)
18521852
.and_then(|t| t.llvm_libunwind)
18531853
.or(self.llvm_libunwind_default)
1854-
.unwrap_or(if target.contains("fuchsia") {
1854+
.unwrap_or(if target.contains("fuchsia") || target.contains("hexagon") {
18551855
LlvmLibunwind::InTree
18561856
} else {
18571857
LlvmLibunwind::No

0 commit comments

Comments
 (0)