@@ -18,6 +18,7 @@ import mcpp.modgraph.validate;
1818import mcpp.toolchain.clang;
1919import mcpp.toolchain.detect;
2020import mcpp.toolchain.fingerprint;
21+ import mcpp.toolchain.msvc;
2122import mcpp.toolchain.registry;
2223import mcpp.toolchain.stdmod;
2324import mcpp.toolchain.post_install;
@@ -682,7 +683,28 @@ prepare_build(bool print_fingerprint,
682683 }
683684 }
684685
685- if (tcSpec.has_value () && *tcSpec != " system" ) {
686+ // msvc@system: a *system* toolchain — located on the machine, never
687+ // resolved through xim packages. mcpp does not install MSVC.
688+ bool tcSpecIsMsvc = false ;
689+ if (tcSpec.has_value ()) {
690+ if (auto s = mcpp::toolchain::parse_toolchain_spec (*tcSpec);
691+ s && mcpp::toolchain::is_system_toolchain (*s))
692+ tcSpecIsMsvc = true ;
693+ }
694+ if (tcSpecIsMsvc) {
695+ if (!mcpp::platform::is_windows) {
696+ return std::unexpected (std::format (
697+ " toolchain '{}' is only available on Windows hosts" , *tcSpec));
698+ }
699+ auto inst = mcpp::toolchain::msvc::detect_installation ();
700+ if (!inst) {
701+ return std::unexpected (mcpp::toolchain::msvc::install_guidance ());
702+ }
703+ explicit_compiler = inst->clPath ;
704+ mcpp::ui::info (" Resolved" , std::format (
705+ " msvc@system → msvc {} ({})" ,
706+ inst->display_version (), inst->clPath .string ()));
707+ } else if (tcSpec.has_value () && *tcSpec != " system" ) {
686708 auto spec = mcpp::toolchain::parse_toolchain_spec (*tcSpec);
687709 if (!spec || spec->version .empty ()) {
688710 return std::unexpected (std::format (
@@ -841,6 +863,19 @@ prepare_build(bool print_fingerprint,
841863 auto tc = mcpp::toolchain::detect (explicit_compiler);
842864 if (!tc) return std::unexpected (tc.error ().message );
843865
866+ // Native MSVC builds are gated off until the cl.exe/.ifc pipeline lands.
867+ // Selection & detection (`mcpp toolchain default msvc`, `list`, `doctor`)
868+ // work; the build must fail here with one owned message rather than an
869+ // incidental error deep in the GCC/Clang-shaped flag machinery.
870+ if (tc->compiler == mcpp::toolchain::CompilerId::MSVC ) {
871+ return std::unexpected (std::format (
872+ " native MSVC (cl.exe) builds are not yet supported by mcpp.\n "
873+ " detected: msvc {} at {} (selection & detection work today)\n "
874+ " for building on Windows use the MSVC-ABI Clang toolchain instead:\n "
875+ " mcpp toolchain default llvm@20.1.7" ,
876+ tc->version , tc->binaryPath .string ()));
877+ }
878+
844879 // For musl-gcc the toolchain is fully self-contained
845880 // (`<root>/x86_64-linux-musl/{include,lib}` is its own sysroot).
846881 // musl-gcc's `-dumpmachine` reports `x86_64-linux-musl`.
0 commit comments