Skip to content

Commit 33806d3

Browse files
authored
Unrolled build for #150010
Rollup merge of #150010 - androm3da:bcain/make_test_linkage, r=jieyouxu Correct library linking for hexagon targets in run-make tests Fixes the run-make test framework to use target-specific library linking instead of host-based detection. Previously, tests for hexagon targets failed because the framework used uname() to detect libraries to link, which returned Linux libraries (-lm -lrt -ldl -lpthread) that don't exist on all hexagon targets. - Use target() instead of uname() to detect cross-compilation targets - Add hexagon-specific library configuration (-lunwind -lclang_rt.builtins-hexagon) - Maintain backward compatibility for host-native compilation This enables hexagon tests to compile and link successfully with the appropriate runtime libraries for the hexagon platform.
2 parents 693f365 + bf9a874 commit 33806d3

File tree

1 file changed

+16
-8
lines changed
  • src/tools/run-make-support/src/external_deps/c_cxx_compiler

1 file changed

+16
-8
lines changed

src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{is_arm64ec, is_win7, is_windows, is_windows_msvc, uname};
1+
use crate::{is_arm64ec, is_win7, is_windows, is_windows_msvc, target, uname};
22

33
fn get_windows_msvc_libs() -> Vec<&'static str> {
44
let mut libs =
@@ -22,14 +22,22 @@ pub fn extra_c_flags() -> Vec<&'static str> {
2222
vec!["-lws2_32", "-luserenv", "-lbcrypt", "-lntdll", "-lsynchronization"]
2323
}
2424
} else {
25-
match uname() {
26-
n if n.contains("Darwin") => vec!["-lresolv"],
27-
n if n.contains("FreeBSD") => vec!["-lm", "-lpthread", "-lgcc_s"],
28-
n if n.contains("SunOS") => {
29-
vec!["-lm", "-lpthread", "-lposix4", "-lsocket", "-lresolv"]
25+
// For cross-compilation targets, we need to check the target, not the host
26+
let target_triple = target();
27+
if target_triple.contains("hexagon") {
28+
// Hexagon targets need unwind support but don't have some Linux libraries
29+
vec!["-lunwind", "-lclang_rt.builtins-hexagon"]
30+
} else {
31+
// For host-based detection, fall back to uname() for non-cross compilation
32+
match uname() {
33+
n if n.contains("Darwin") => vec!["-lresolv"],
34+
n if n.contains("FreeBSD") => vec!["-lm", "-lpthread", "-lgcc_s"],
35+
n if n.contains("SunOS") => {
36+
vec!["-lm", "-lpthread", "-lposix4", "-lsocket", "-lresolv"]
37+
}
38+
n if n.contains("OpenBSD") => vec!["-lm", "-lpthread", "-lc++abi"],
39+
_ => vec!["-lm", "-lrt", "-ldl", "-lpthread"],
3040
}
31-
n if n.contains("OpenBSD") => vec!["-lm", "-lpthread", "-lc++abi"],
32-
_ => vec!["-lm", "-lrt", "-ldl", "-lpthread"],
3341
}
3442
}
3543
}

0 commit comments

Comments
 (0)