Skip to content

Commit

Permalink
Rollup merge of rust-lang#60402 - michaelwoerister:update-profiler-rt…
Browse files Browse the repository at this point in the history
…-build, r=alexcrichton

libprofiler_builtins: Set compilation flags more correctly for C code.

In particular, set `COMPILER_RT_HAS_FCNTL_LCK` and `COMPILER_RT_HAS_ATOMICS` as appropriate. This should get rid of the various runtime warnings when executing instrumented binaries.

The build script is using a heuristic here that hopefully is sufficient for the time being.

r? @alexcrichton

Fixes rust-lang#59531.
  • Loading branch information
Centril authored Apr 30, 2019
2 parents 0d2f85e + d52fde2 commit 7874956
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/libprofiler_builtins/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ fn main() {
cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));
}

// Assume that the Unixes we are building this for have fnctl() available
if env::var_os("CARGO_CFG_UNIX").is_some() {
cfg.define("COMPILER_RT_HAS_FCNTL_LCK", Some("1"));
}

// This should be a pretty good heuristic for when to set
// COMPILER_RT_HAS_ATOMICS
if env::var_os("CARGO_CFG_TARGET_HAS_ATOMIC").map(|features| {
features.to_string_lossy().to_lower_case().contains("cas")
}).unwrap_or(false) {
cfg.define("COMPILER_RT_HAS_ATOMICS", Some("1"));
}

// The source for `compiler-rt` comes from the `compiler-builtins` crate, so
// load our env var set by cargo to find the source code.
let root = env::var_os("DEP_COMPILER_RT_COMPILER_RT").unwrap();
Expand Down

0 comments on commit 7874956

Please sign in to comment.