diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2019-04-30 10:46:21 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2019-05-08 17:02:58 +0200 |
| commit | e65ef96eafc8772ae468a6f53547e8837dbc94da (patch) | |
| tree | ab387c36b832c264af547a97fca907e121669eb8 /src/libprofiler_builtins | |
| parent | b92d360c6cf029bd98c154cb510ec9e11b39bad6 (diff) | |
| download | rust-e65ef96eafc8772ae468a6f53547e8837dbc94da.tar.gz rust-e65ef96eafc8772ae468a6f53547e8837dbc94da.zip | |
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.
Diffstat (limited to 'src/libprofiler_builtins')
| -rw-r--r-- | src/libprofiler_builtins/build.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libprofiler_builtins/build.rs b/src/libprofiler_builtins/build.rs index ff52a03d9dd..331edb73d6d 100644 --- a/src/libprofiler_builtins/build.rs +++ b/src/libprofiler_builtins/build.rs @@ -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_lowercase().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(); |
