Clang-cl on Microsoft Windows without MSVC? (original) (raw)

I understand that clang-cl is geared for MSVC (Visual Studio). However, I don’t want to use MSVC and I don’t have it installed.

When I run clang-cl, this is the result:

C:\Utility> clang-cl Main.c

clang-cl: warning: unable to find a Visual Studio installation; try running Clang from a developer command prompt [-Wmsvc-not-found]
Main.c(1,10): fatal error: 'stdio.h' file not found
    1 | #include <stdio.h>
      |          ^~~~~~~~~
1 error generated.

clang-cl info:

C:\Utility> clang-cl --version

clang version 20.1.5
Target: x86_64-pc-windows-msvc
Thread model: posix

Could I supply headers and libraries myself and gradually bring up a working system? Nothing in the LLVM for Windows/MSVC license requires MSVC, true? It’s simply technical issues, true?
Does LLVM now include a linker? (I do see lld.exe and lld-link.exe).

Thank You!

Endill June 1, 2025, 7:36pm 2

Yes, clang-cl doesn’t require MSVC, but you need Windows SDK at the very least.

Yes, lld supports COFF. lld-link is a “flavor” of lld that understands link.exe-style arguments.

CC @mstorsjo

Excellent, thank you!

Windows SDK? E.g. for Windows API and Windows dlls? That would be understandable.

How about for C headers/libs, could I put that together myself, e.g. as needed, depending upon what I need/use? Open-source options exist also.

Basically, I’m ensuring that we have a green light (without license restrictions) to leverage the LLVM Windows target and clang-cl as needed, as long as we understand that technical hurdles exist. I think that you have confirmed that! A clang-cl system without MSVC could probably benefit others.

In practice, the Windows SDK isn’t enough for using clang-cl - you also do need headers and libraries that ship with MSVC, even if you don’t need the MSVC compiler/linker itself.

In theory you could of course reimplement the bits you need there, but I’m not aware of any preexisting setup for doing that.

If you don’t strictly need clang-cl and MSVC mode, you could also use Clang in mingw mode, together with mingw-w64 headers/libraries. Those are freely redistributable, standalone reimplementations of Windows/MSVC headers/interfaces. With e.g. llvm-mingw you get a prepackaged toolchain, usable as such out of the box, with Clang and mingw-w64 headers/libraries all in one.

In practice, the Windows SDK isn’t enough for using clang-cl

Understood.


In theory you could of course reimplement the bits you need

That and/or gather from open-source options (e.g. musl). It’s a project in itself and that’s fine.


mingw-w64 headers/libraries.

Aware of that option also.


Thanks kindly for the help!

Absolutely; it’d be interesting to see if you get something like that set up!

FWIW, you don’t really need so much of what musl has got to offer - the Windows SDK does contain headers and libraries for UCRT, the Windows provided C runtime DLLs.

What you’d be missing is mainly glue/startup code and similar; static objects that within MSVC is provided within the msvcrt.lib glue library (which pulls in ucrt.lib for linking the UCRT, but also vcruntime140.dll).

For trivial applications you can probably get by with only very very little on top of the Windows SDK.