Skip to content

Commit 9e18b3a

Browse files
art049not-matthias
andcommitted
fix: force C17 to build instrumenthooks
Co-authored-by: Matthias Heiden <[email protected]>
1 parent e64cdfa commit 9e18b3a

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

crates/codspeed/build.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
use std::{env, path::PathBuf};
22

33
fn main() {
4+
println!("cargo:rerun-if-changed=instrument-hooks/dist/core.c");
5+
println!("cargo:rerun-if-changed=instrument-hooks/includes/core.h");
6+
println!("cargo:rerun-if-changed=build.rs");
7+
48
if cfg!(not(target_os = "linux")) {
59
// The instrument-hooks library is only supported on Linux.
610
return;
711
}
812

9-
// Compile the C library
10-
cc::Build::new()
13+
let mut build = cc::Build::new();
14+
build
15+
.flag("-std=gnu17")
1116
.file("instrument-hooks/dist/core.c")
1217
.include("instrument-hooks/includes")
13-
.flag("-w") // Suppress all warnings
14-
.compile("instrument_hooks");
18+
.warnings(false)
19+
.extra_warnings(false)
20+
.cargo_warnings(false);
21+
22+
let result = build.try_compile("instrument_hooks");
23+
if let Err(e) = result {
24+
let compiler = build.try_get_compiler().expect("Failed to get C compiler");
25+
26+
eprintln!("\n\nERROR: Failed to compile instrument-hooks native library with cc-rs. Ensure you have an up-to-date C compiler installed.");
27+
eprintln!("Compiler information: {compiler:?}");
28+
eprintln!("Compilation error: {e}");
29+
30+
std::process::exit(1);
31+
}
1532

1633
let bindings = bindgen::Builder::default()
1734
.header("instrument-hooks/includes/core.h")

0 commit comments

Comments
 (0)