@@ -3,7 +3,7 @@ |
|
|
3 |
3 |
//! See the build.rs for libcompiler_builtins crate for details. |
4 |
4 |
|
5 |
5 |
use std::env; |
6 |
|
-use std::path::Path; |
|
6 |
+use std::path::PathBuf; |
7 |
7 |
|
8 |
8 |
fn main() { |
9 |
9 |
println!("cargo:rerun-if-env-changed=LLVM_PROFILER_RT_LIB"); |
@@ -79,9 +79,13 @@ fn main() { |
|
|
79 |
79 |
cfg.define("COMPILER_RT_HAS_ATOMICS", Some("1")); |
80 |
80 |
} |
81 |
81 |
|
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 |
+})); |
85 |
89 |
|
86 |
90 |
let src_root = root.join("lib").join("profile"); |
87 |
91 |
assert!(src_root.exists(), "profiler runtime source directory not found: {src_root:?}"); |