...
For all the steps below you’ll need to put things on the PATH, if an installer doesn’t do it for you. To do that open the start menu, type “environment” and open the link to “System Properties”. There click “Environment Variables” to see a GUI for editing them.
Note that we configure RunAsRob (the RunAsRob service that runs buildbot) to run as “tcwg”, not “System” user, so environment changes will also apply to the buildbot.
Note: just Just like in Unix, adding to the path doesn’t refresh active terminals. You’ll , and there is no way to refresh an active terminal. So you need to open a fresh one/google the “source ~/.bashrc” equivalent for Windows.terminal after changing environment variables.
After following this guide your PATH should have these extra entries:
...
For building release packages we also install 7-Zip https://www.7-zip.org/download.html and NSIS https://nsis.sourceforge.io/Download
C:\Program Files (x86)\7-Zip
C:\Program Files (x86)\NSIS
...
Note: Microsoft Visual Studio 2022 has been released but the installer is a 64-bit application requiring ARM64 emulation support. Arm64 emulation is generally available for Windows 11 but only a preview build is available for windows 10.
This Build tools is the command line portion of visual studio, download it from https://visualstudio.microsoft.com/downloads/ . (“Tools for Visual Studio 2019” → “Build Tools for Visual Studio 2019”)
The Visual Studio installer has many options but generally, you want various things to do with C++ desktop development for ARM64. (there are some we do not need ARM components, these are ARM means Arm 32 bit , we don’t need those).in this context)
If you have build issues later, come back to the installer and add anything that seems relevant. Here’s the list of what is minimally needed, check this against “Individual Components” in your “Installation Details” panel:
MSVC v142 - VS 2019 C++ x64/x86 build tools (latest)
This is needed to make vsdevcmd.bat correctly setup LIB/LIBPATH/INCLUDE variables for x86->arm64 cross-compilation. All the lib/header files are actually present, but vsdevcmd.bat doesn’t add them without x86-hosted tools.
Installing this may become optional in the future.
MSVC v142 - VS 2019 C++ ARM64 build tools (latest)
Without these vsdevcmd.bat doesn’t setup x86->arm64 cross-compilation.
C++ ATL for latest v142 build tools (ARM64)
LLVM needs ATL libraries for processing debug info.
Windows 10 SDK
Versions 18362 and 19041 are known to work.
Version 20348 is known to cause LLVM build failure.
error: use of undeclared identifier '__umulh'
This is required for correct cross-compilation setup. Not (not sure if SDK libraries are actually used)
Note: there’s probably a choice in the installer for where to install to. If you do that modify any instructions as needed. The default that I got was “C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\”.
...
Install these libraries to get msvcp140.dll, vcruntime140.dll, concrt140.dll and other libraries. Without these DLLs MSVC-built application will not run; in LLVM build this manifests itself as llvm-tblgen.exe failing.
Why For reasons unknown, these libraries aren’t are not installed by default in the OS or, at the very least, as part of VS installation – escapes meWindows or Visual Studio.
Install latest llvm for Windows on Arm
Go to https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0 and download the Windows on Arm (“woa64”) installer. Run it and if it asks to add llvm to the path say yes. If it doesn’t or you forget that you can always add …/LLVM/bin the install directory to PATH
yourself.
Install CMake
Recent versions of VS ship cmake as x86_64 binary (in VS circa-2020.08 cmake was x86_32 binary). Instead install the i386 build from https://cmake.org/files/ and add that to user’s the PATH
. The following CMake + LLVM configurations are known
...
LLVM 12 or 13,
...
with CMake 3.17
...
is known to
...
work.
LLVM 13
...
with CMake 3.21
...
or 3.22 is known not to work.
Install Python
If you run “python” it takes you to the Windows Store which allegedly will give you a (native?) copy of Python3. As per usual with the Windows Store, it didn’t do anything when I clicked install.
So instead, you can go to Python.org and get a 32 bit x86 build of the latest Python3. Remember to:
...
Tell the installer to add python variables to environment (so that cmake can find python3)
...
.
Note: lldb’s Python integration requires a native Python install, see the section below about lldb dependencies.
Install Git
Usual thing, go Go to https://git-scm.com/download/win and get the latest 32 bit x86 installer. Again there’s probably a git in the build tools install, so if you can use that more power to you, however -Installing git also gives you a bunch of command line tools that lit needs for testing:There is likely a copy of git the VS Build Tools install, but we reccomend installing a separate copy so that you also get the tools git for Windows is packaged with. These tools are used for testing llvm.
Code Block |
---|
llvm-lit.py: C:\Work\david.spickett<...>\llvm-project\llvm\utils\lit\lit\llvm\config.py:46: note: using lit tools: C:\Program Files (x86)\Git\usr\bin |
(you can get these tools by installing MSYS2 instead, but git for windows Windows is based on anyway that I thinkthat so the result is the same)
Build Ninja
Again build tools can/VS Build Tools does come with a ninja but the default one doesn’t run on WoA. I built ninja You should build from source (https://github.com/ninja-build/ninja ) using the cmake build method.
...
(https://github.com/ninja-build/ninja/releases does provide prebuilt releases but at this time the Windows variant is x86_64 only)
Check out LLVM
The git for windows Windows install will default to converting line endings to windows style. This applies to any file git thinks is ASCII, which includes some archive files used for llvm tests. As stated in https://llvm.org/docs/GettingStarted.html#checkout-llvm-from-git , use the following to override this behaviour:
...
First, open a plain terminal “Command Prompt” . Ignore (ignore the cross prompts shortcuts you might find in the start menu).
Then run VsDevCmd.bat to setup the environment.
...
If the second test command fails, your build probably won’t work. If figuring out why it failed is trickydifficult, just go ahead and do a build and the anyway. The compiler’s errors will probably be more informative.
...
Code Block |
---|
ninja --version cmake --version |
Doing a Build
(in In the same command prompt from above)
Set as the previous step, set your compiler(s) to be the clang-cl.exe we installed earlier.
...
https://reviews.llvm.org/D92515 bumped llvm’s required MSVC version, ironically meaning that clang-cl version 12 and earlier can’t build it. That’s why we need the “
-fms-compatibility-version
" flag to have clang-cl pretend to be a newer MSVC. You don’t need to add-fms-compatibility-version
flag for clang-cl version 13 and later.Known issue with cmake 3.21.1, it builds all try_compile/try_run as debug even if you select release mode. This is why we set “-DCMAKE_TRY_COMPILE_CONFIGURATION=Release”. Not doing so causes a try_run to fail to get error message strings, so lit defaults to Linux strings and a bunch of many tests will fail.
We set LLVM_DEFAULT_TARGET_TRIPLE manually because the prompt we use is an x86 32 bit host prompt. There is no arm64 to arm64 prompt, so cmake detects the host/default target triple “correctly” but it’s not what we really want.
...
If you’re doing a debug build and you see linker errors about missing libs, see if the file names end with “d”. E.g. “foo.lib” would be “food.lib” for a debug build. When I had this issue I think I did actually add those libs to Path, but I’m not sure that’s the way you’re supposed to do itTo solve this search for those files and add their location to PATH. They don’t appear to be automatically added by the installers.
Excluding the test folder from Windows Defender
Windows Defender likes to scan new files, including those that tests create. Which can change This changes their last accessed times . There’s at least and there’s one test known to fail because of this, “LLVM :: ThinLTO/X86/cache.ll”. To exclude the folder follow https://support.microsoft.com/en-us/windows/add-an-exclusion-to-windows-security-811816c0-4dfd-af4a-47e4-c301afe13b26 and add “<llvm-build-dir>/test”. (you shouldn’t need to restart defender or the machine, it takes effect automatically)
...