Building llvm-mos on Windows

From llvm-mos
Jump to navigation Jump to search

Generally speaking, builds of llvm-mos on Windows are finicky and opinionated, because LLVM itself is finicky and opinionated to build on Windows. I use a stable release of LLVM to compile LLVM.

When checking out from git, it's important to make sure that core.autocrlf is set to False. Windows installations strongly encourage you to set this to true, but if you do, then LLVM acceptance tests will fail.

To set up a Windows development and testing machine, I install Chocolatey first, at an administrator PowerShell prompt:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(''))

Then, I run the following commands to install all prerequisites:

choco install git.install --params "/NoAutoCrlf"
choco install cmake python llvm vscode ninja visualstudio2019community visualstudio2019-workload-nativedesktop 

The LLVM documentation suggests that you need the GnuWin32 utilities, but I don't think that's necessary; you can simply use the ones that the Windows version of git installs at C:/Program Files/git/usr/bin . You can point the LLVM_LIT_TOOLS_DIR build variable at that directory, and llvm-lit will use all the tools in that directory for building the check-all target.

As of this writing, my Windows build batch file looks like this:

set LLVM_BIN=C:/Progra~1/LLVM/bin
cmake --build . --config Release --target check-all
cmake --build . --config Release --target install