@@ -107,18 +107,18 @@ pub fn prebuilt_llvm_config(
107107
108108 // If we're using a custom LLVM bail out here, but we can only use a
109109 // custom LLVM for the build triple.
110- if let Some(config) = builder.config.target_config.get(&target) {
111- if let Some(ref s) = config.llvm_config {
112- check_llvm_version(builder, s);
113- let llvm_config = s.to_path_buf( );
114- let mut llvm_cmake_dir = llvm_config.clone ();
115- llvm_cmake_dir.pop ();
116- llvm_cmake_dir.pop();
117- llvm_cmake_dir.push("lib" );
118- llvm_cmake_dir.push("cmake ");
119- llvm_cmake_dir.push("llvm ");
120- return LlvmBuildStatus::AlreadyBuilt(LlvmResult { llvm_config, llvm_cmake_dir } );
121- }
110+ if let Some(config) = builder.config.target_config.get(&target)
111+ && let Some(ref s) = config.llvm_config
112+ {
113+ check_llvm_version(builder, s );
114+ let llvm_config = s.to_path_buf ();
115+ let mut llvm_cmake_dir = llvm_config.clone ();
116+ llvm_cmake_dir.pop();
117+ llvm_cmake_dir.pop( );
118+ llvm_cmake_dir.push("lib ");
119+ llvm_cmake_dir.push("cmake ");
120+ llvm_cmake_dir.push("llvm" );
121+ return LlvmBuildStatus::AlreadyBuilt(LlvmResult { llvm_config, llvm_cmake_dir });
122122 }
123123
124124 if handle_submodule_when_needed {
@@ -467,10 +467,10 @@ impl Step for Llvm {
467467 cfg.define("LLVM_ENABLE_RUNTIMES", enabled_llvm_runtimes.join(";"));
468468 }
469469
470- if let Some(num_linkers) = builder.config.llvm_link_jobs {
471- if num_linkers > 0 {
472- cfg.define("LLVM_PARALLEL_LINK_JOBS", num_linkers.to_string());
473- }
470+ if let Some(num_linkers) = builder.config.llvm_link_jobs
471+ && num_linkers > 0
472+ {
473+ cfg.define("LLVM_PARALLEL_LINK_JOBS", num_linkers.to_string());
474474 }
475475
476476 // https://llvm.org/docs/HowToCrossCompileLLVM.html
@@ -596,10 +596,10 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
596596
597597 let version = get_llvm_version(builder, llvm_config);
598598 let mut parts = version.split('.').take(2).filter_map(|s| s.parse::<u32>().ok());
599- if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
600- if major >= 19 {
601- return;
602- }
599+ if let (Some(major), Some(_minor)) = (parts.next(), parts.next())
600+ && major >= 19
601+ {
602+ return;
603603 }
604604 panic!("\n\nbad LLVM version: {version}, need >=19\n\n")
605605}
@@ -729,11 +729,9 @@ fn configure_cmake(
729729
730730 // If ccache is configured we inform the build a little differently how
731731 // to invoke ccache while also invoking our compilers.
732- if use_compiler_launcher {
733- if let Some(ref ccache) = builder.config.ccache {
734- cfg.define("CMAKE_C_COMPILER_LAUNCHER", ccache)
735- .define("CMAKE_CXX_COMPILER_LAUNCHER", ccache);
736- }
732+ if use_compiler_launcher && let Some(ref ccache) = builder.config.ccache {
733+ cfg.define("CMAKE_C_COMPILER_LAUNCHER", ccache)
734+ .define("CMAKE_CXX_COMPILER_LAUNCHER", ccache);
737735 }
738736 cfg.define("CMAKE_C_COMPILER", sanitize_cc(&cc))
739737 .define("CMAKE_CXX_COMPILER", sanitize_cc(&cxx))
@@ -791,20 +789,20 @@ fn configure_cmake(
791789 cxxflags.push(format!(" --target={target}"));
792790 }
793791 cfg.define("CMAKE_CXX_FLAGS", cxxflags);
794- if let Some(ar) = builder.ar(target) {
795- if ar.is_absolute() {
796- // LLVM build breaks if `CMAKE_AR` is a relative path, for some reason it
797- // tries to resolve this path in the LLVM build directory.
798- cfg.define("CMAKE_AR", sanitize_cc(&ar));
799- }
792+ if let Some(ar) = builder.ar(target)
793+ && ar.is_absolute()
794+ {
795+ // LLVM build breaks if `CMAKE_AR` is a relative path, for some reason it
796+ // tries to resolve this path in the LLVM build directory.
797+ cfg.define("CMAKE_AR", sanitize_cc(&ar));
800798 }
801799
802- if let Some(ranlib) = builder.ranlib(target) {
803- if ranlib.is_absolute() {
804- // LLVM build breaks if `CMAKE_RANLIB` is a relative path, for some reason it
805- // tries to resolve this path in the LLVM build directory.
806- cfg.define("CMAKE_RANLIB", sanitize_cc(&ranlib));
807- }
800+ if let Some(ranlib) = builder.ranlib(target)
801+ && ranlib.is_absolute()
802+ {
803+ // LLVM build breaks if `CMAKE_RANLIB` is a relative path, for some reason it
804+ // tries to resolve this path in the LLVM build directory.
805+ cfg.define("CMAKE_RANLIB", sanitize_cc(&ranlib));
808806 }
809807
810808 if let Some(ref flags) = builder.config.llvm_ldflags {
@@ -1037,13 +1035,14 @@ impl Step for Lld {
10371035 // when doing PGO on CI, cmake or clang-cl don't automatically link clang's
10381036 // profiler runtime in. In that case, we need to manually ask cmake to do it, to avoid
10391037 // linking errors, much like LLVM's cmake setup does in that situation.
1040- if builder.config.llvm_profile_generate && target.is_msvc() {
1041- if let Some(clang_cl_path) = builder.config.llvm_clang_cl.as_ref() {
1042- // Find clang's runtime library directory and push that as a search path to the
1043- // cmake linker flags.
1044- let clang_rt_dir = get_clang_cl_resource_dir(builder, clang_cl_path);
1045- ldflags.push_all(format!("/libpath:{}", clang_rt_dir.display()));
1046- }
1038+ if builder.config.llvm_profile_generate
1039+ && target.is_msvc()
1040+ && let Some(clang_cl_path) = builder.config.llvm_clang_cl.as_ref()
1041+ {
1042+ // Find clang's runtime library directory and push that as a search path to the
1043+ // cmake linker flags.
1044+ let clang_rt_dir = get_clang_cl_resource_dir(builder, clang_cl_path);
1045+ ldflags.push_all(format!("/libpath:{}", clang_rt_dir.display()));
10471046 }
10481047
10491048 // LLD is built as an LLVM tool, but is distributed outside of the `llvm-tools` component,
0 commit comments