Skip to content

Commit e21ce6e

Browse files
committed
Try to avoid sccache MSVC hack
1 parent 8f57495 commit e21ce6e

File tree

1 file changed

+48
-48
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+48
-48
lines changed

src/bootstrap/src/core/build_steps/llvm.rs

+48-48
Original file line numberDiff line numberDiff line change
@@ -736,56 +736,56 @@ fn configure_cmake(
736736
};
737737

738738
// Handle msvc + ninja + ccache specially (this is what the bots use)
739-
if target.is_msvc() && builder.ninja() && builder.config.ccache.is_some() {
740-
let mut wrap_cc = env::current_exe().expect("failed to get cwd");
741-
wrap_cc.set_file_name("sccache-plus-cl.exe");
742-
743-
cfg.define("CMAKE_C_COMPILER", sanitize_cc(&wrap_cc))
744-
.define("CMAKE_CXX_COMPILER", sanitize_cc(&wrap_cc));
745-
cfg.env("SCCACHE_PATH", builder.config.ccache.as_ref().unwrap())
746-
.env("SCCACHE_TARGET", target.triple)
747-
.env("SCCACHE_CC", &cc)
748-
.env("SCCACHE_CXX", &cxx);
749-
750-
// Building LLVM on MSVC can be a little ludicrous at times. We're so far
751-
// off the beaten path here that I'm not really sure this is even half
752-
// supported any more. Here we're trying to:
753-
//
754-
// * Build LLVM on MSVC
755-
// * Build LLVM with `clang-cl` instead of `cl.exe`
756-
// * Build a project with `sccache`
757-
// * Build for 32-bit as well
758-
// * Build with Ninja
759-
//
760-
// For `cl.exe` there are different binaries to compile 32/64 bit which
761-
// we use but for `clang-cl` there's only one which internally
762-
// multiplexes via flags. As a result it appears that CMake's detection
763-
// of a compiler's architecture and such on MSVC **doesn't** pass any
764-
// custom flags we pass in CMAKE_CXX_FLAGS below. This means that if we
765-
// use `clang-cl.exe` it's always diagnosed as a 64-bit compiler which
766-
// definitely causes problems since all the env vars are pointing to
767-
// 32-bit libraries.
768-
//
769-
// To hack around this... again... we pass an argument that's
770-
// unconditionally passed in the sccache shim. This'll get CMake to
771-
// correctly diagnose it's doing a 32-bit compilation and LLVM will
772-
// internally configure itself appropriately.
773-
if builder.config.llvm_clang_cl.is_some() && target.contains("i686") {
774-
cfg.env("SCCACHE_EXTRA_ARGS", "-m32");
775-
}
776-
} else {
777-
// If ccache is configured we inform the build a little differently how
778-
// to invoke ccache while also invoking our compilers.
779-
if use_compiler_launcher {
780-
if let Some(ref ccache) = builder.config.ccache {
781-
cfg.define("CMAKE_C_COMPILER_LAUNCHER", ccache)
782-
.define("CMAKE_CXX_COMPILER_LAUNCHER", ccache);
783-
}
739+
// if target.is_msvc() && builder.ninja() && builder.config.ccache.is_some() {
740+
// let mut wrap_cc = env::current_exe().expect("failed to get cwd");
741+
// wrap_cc.set_file_name("sccache-plus-cl.exe");
742+
//
743+
// cfg.define("CMAKE_C_COMPILER", sanitize_cc(&wrap_cc))
744+
// .define("CMAKE_CXX_COMPILER", sanitize_cc(&wrap_cc));
745+
// cfg.env("SCCACHE_PATH", builder.config.ccache.as_ref().unwrap())
746+
// .env("SCCACHE_TARGET", target.triple)
747+
// .env("SCCACHE_CC", &cc)
748+
// .env("SCCACHE_CXX", &cxx);
749+
//
750+
// // Building LLVM on MSVC can be a little ludicrous at times. We're so far
751+
// // off the beaten path here that I'm not really sure this is even half
752+
// // supported any more. Here we're trying to:
753+
// //
754+
// // * Build LLVM on MSVC
755+
// // * Build LLVM with `clang-cl` instead of `cl.exe`
756+
// // * Build a project with `sccache`
757+
// // * Build for 32-bit as well
758+
// // * Build with Ninja
759+
// //
760+
// // For `cl.exe` there are different binaries to compile 32/64 bit which
761+
// // we use but for `clang-cl` there's only one which internally
762+
// // multiplexes via flags. As a result it appears that CMake's detection
763+
// // of a compiler's architecture and such on MSVC **doesn't** pass any
764+
// // custom flags we pass in CMAKE_CXX_FLAGS below. This means that if we
765+
// // use `clang-cl.exe` it's always diagnosed as a 64-bit compiler which
766+
// // definitely causes problems since all the env vars are pointing to
767+
// // 32-bit libraries.
768+
// //
769+
// // To hack around this... again... we pass an argument that's
770+
// // unconditionally passed in the sccache shim. This'll get CMake to
771+
// // correctly diagnose it's doing a 32-bit compilation and LLVM will
772+
// // internally configure itself appropriately.
773+
// if builder.config.llvm_clang_cl.is_some() && target.contains("i686") {
774+
// cfg.env("SCCACHE_EXTRA_ARGS", "-m32");
775+
// }
776+
// } else {
777+
// If ccache is configured we inform the build a little differently how
778+
// to invoke ccache while also invoking our compilers.
779+
if use_compiler_launcher {
780+
if let Some(ref ccache) = builder.config.ccache {
781+
cfg.define("CMAKE_C_COMPILER_LAUNCHER", ccache)
782+
.define("CMAKE_CXX_COMPILER_LAUNCHER", ccache);
784783
}
785-
cfg.define("CMAKE_C_COMPILER", sanitize_cc(&cc))
786-
.define("CMAKE_CXX_COMPILER", sanitize_cc(&cxx))
787-
.define("CMAKE_ASM_COMPILER", sanitize_cc(&cc));
788784
}
785+
cfg.define("CMAKE_C_COMPILER", sanitize_cc(&cc))
786+
.define("CMAKE_CXX_COMPILER", sanitize_cc(&cxx))
787+
.define("CMAKE_ASM_COMPILER", sanitize_cc(&cc));
788+
// }
789789

790790
cfg.build_arg("-j").build_arg(builder.jobs().to_string());
791791
// FIXME(madsmtm): Allow `cmake-rs` to select flags by itself by passing

0 commit comments

Comments
 (0)