Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit a67f5e9

Browse files
committed
Try hardter to find a C compiler
1 parent 1aa6f5d commit a67f5e9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

crates/libm-cdylib/src/test_utils.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,16 @@ pub(crate) fn compile_cdylib() {
2525
/// Compiles the test C program with source at `src_path` into
2626
/// an executable at `bin_path`.
2727
pub(crate) fn compile_file(src_path: &Path, bin_path: &Path) {
28-
let mut cmd = process::Command::new("CC");
28+
let cc = if std::env::var("CC").is_ok() {
29+
std::env::var("CC").unwrap().to_string()
30+
} else if cfg!(target_os = "linux") {
31+
"gcc".to_string()
32+
} else if cfg!(target_os = "macos") {
33+
"clang".to_string()
34+
} else {
35+
panic!("unknown platform - Ccompiler not found")
36+
};
37+
let mut cmd = process::Command::new(&cc);
2938
// We disable the usage of builtin functions, e.g., from libm.
3039
// This should ideally produce a link failure if libm is not dynamically
3140
// linked.

0 commit comments

Comments
 (0)