@@ -698,6 +698,20 @@ impl<'a> Builder<'a> {
698
698
cmd
699
699
}
700
700
701
+ /// Return the path to `llvm-config` for the target, if it exists.
702
+ ///
703
+ /// Note that this returns `None` if LLVM is disabled, or if we're in a
704
+ /// check build or dry-run, where there's no need to build all of LLVM.
705
+ fn llvm_config ( & self , target : Interned < String > ) -> Option < PathBuf > {
706
+ if self . config . llvm_enabled ( ) && self . kind != Kind :: Check && !self . config . dry_run {
707
+ let llvm_config = self . ensure ( native:: Llvm { target } ) ;
708
+ if llvm_config. is_file ( ) {
709
+ return Some ( llvm_config) ;
710
+ }
711
+ }
712
+ None
713
+ }
714
+
701
715
/// Prepares an invocation of `cargo` to be run.
702
716
///
703
717
/// This will create a `Command` that represents a pending execution of
@@ -1038,14 +1052,11 @@ impl<'a> Builder<'a> {
1038
1052
// requirement, but the `-L` library path is not propagated across
1039
1053
// separate Cargo projects. We can add LLVM's library path to the
1040
1054
// platform-specific environment variable as a workaround.
1041
- //
1042
- // Note that this is disabled if LLVM itself is disabled or we're in a
1043
- // check build, where if we're in a check build there's no need to build
1044
- // all of LLVM and such.
1045
- if self . config . llvm_enabled ( ) && self . kind != Kind :: Check && mode == Mode :: ToolRustc {
1046
- let llvm_config = self . ensure ( native:: Llvm { target } ) ;
1047
- let llvm_libdir = output ( Command :: new ( & llvm_config) . arg ( "--libdir" ) ) ;
1048
- add_link_lib_path ( vec ! [ llvm_libdir. trim( ) . into( ) ] , & mut cargo) ;
1055
+ if mode == Mode :: ToolRustc {
1056
+ if let Some ( llvm_config) = self . llvm_config ( target) {
1057
+ let llvm_libdir = output ( Command :: new ( & llvm_config) . arg ( "--libdir" ) ) ;
1058
+ add_link_lib_path ( vec ! [ llvm_libdir. trim( ) . into( ) ] , & mut cargo) ;
1059
+ }
1049
1060
}
1050
1061
1051
1062
if self . config . incremental {
0 commit comments