File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 33//! See the build.rs for libcompiler_builtins crate for details.
44
55use std:: env;
6- use std:: path:: Path ;
6+ use std:: path:: PathBuf ;
77
88fn 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:?}" ) ;
You can’t perform that action at this time.
0 commit comments