I’ve been trying to compile Rust on MSVC/Windows without having MinGW at all.
Turns out the only real problem with this (AFAIK the rest of the source tree does not depend on gcc at all) is that LLVM’s compiler-rt builtins don’t build on MSVC.
There is a comment in rt.mk from the person who did MSVC support at first (I presume, didn’t git blame) about how he couldn’t get CMake to build compiler-rt.
# Note that on MSVC-targeting builds we hardwire CC/AR to gcc/ar even though
# we're targeting MSVC. This is because although compiler-rt has a CMake build
# config I can't actually figure out how to use it, so I'm not sure how to use
# cl.exe to build the objects. Additionally, the compiler-rt library when built
# with gcc has the same ABI as cl.exe, so they're largely compatible
If the person didn’t (smartly) just force GCC to build it he would’ve realised that builtins won’t build on MSVC.
The CMakeLists.txt for builtins leaves builtins with no source files to build on MSVC:
add_custom_target(builtins)
if (APPLE)
<snip>
elseif (NOT WIN32 OR MINGW)
<snip>
add_compiler_rt_runtime(clang_rt.builtins
STATIC
ARCHS ${arch}
SOURCES ${${arch}_SOURCES}
CFLAGS "-std=c99"
PARENT_TARGET builtins)
<snip>
endif ()
add_dependencies(compiler-rt builtins)
Builtins uses C syntax that MSVC doesn’t support (seems like mainly __attributes__). You could probably get it to compile but then we’d diverge from LLVM …
I’ve been trying to find out what clang does when compiled with MSVC but I can’t find it at all.
Would be nice to build rust without MinGW (and eventually, without MSYS2) for MSVC but someone has to figure out this first.
(The alternative is to disable builtins/intrinsics for MSVC, which is bad)