Skip to content

Commit a437005

Browse files
committed
Build library/profiler_builtins from ci-llvm if appropriate
1 parent eb747e5 commit a437005

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: profiler_builtins/build.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! See the build.rs for libcompiler_builtins crate for details.
44
55
use std::env;
6-
use std::path::Path;
6+
use std::path::PathBuf;
77

88
fn main() {
99
println!("cargo:rerun-if-env-changed=LLVM_PROFILER_RT_LIB");
@@ -79,9 +79,13 @@ fn main() {
7979
cfg.define("COMPILER_RT_HAS_ATOMICS", Some("1"));
8080
}
8181

82-
// Note that this should exist if we're going to run (otherwise we just
83-
// don't build profiler builtins at all).
84-
let root = Path::new("../../src/llvm-project/compiler-rt");
82+
// Get the LLVM `compiler-rt` directory from bootstrap.
83+
println!("cargo:rerun-if-env-changed=RUST_COMPILER_RT_FOR_PROFILER");
84+
let root = PathBuf::from(env::var("RUST_COMPILER_RT_FOR_PROFILER").unwrap_or_else(|_| {
85+
let path = "../../src/llvm-project/compiler-rt";
86+
println!("RUST_COMPILER_RT_FOR_PROFILER was not set; falling back to {path:?}");
87+
path.to_owned()
88+
}));
8589

8690
let src_root = root.join("lib").join("profile");
8791
assert!(src_root.exists(), "profiler runtime source directory not found: {src_root:?}");

0 commit comments

Comments
 (0)