Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This describes how to setup a Windows 10 on Arm laptop to build llvm. Windows 10 on Arm supports emulation of 32-bit x86 programs. This allows us to use those 32-bit x86 version on Windows 10 on Arm but support for x64 versions of same executables is not available in Windows 10.

Adding to the PATH

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.

...

  • C:\Program Files (x86)\7-Zip

  • C:\Program Files (x86)\NSIS

Install Visual Studio Build Tools

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.

...

(worst case, you can always search C:\ for a file, it isn’t as slow as you’d expect)

Install MSVC Redist libraries

Search filesystem for vc_redist.arm64.exe, and you’ll most likely find it in C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Redist\MSVC\v142\ .

...

For reasons unknown, these libraries are not installed by default as part of Windows or Visual Studio.

Install latest llvm for Windows on Arm

Go to https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.6 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 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 the PATH.

...

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.

...

Note: lldb’s Python integration requires a native Python install, see the section below about lldb dependencies.

Install Git

Go to https://git-scm.com/download/win and get the latest 32 bit x86 installer. 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.

...

(you can get these tools by installing MSYS2 instead, but git for Windows is based on that so the result is the same)

Build Ninja

VS Build Tools does come with a ninja but the default one doesn’t run on WoA. 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 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:

Code Block
git clone --config core.autocrlf=false https://github.com/llvm/llvm-project.git

Testing the Install

First, open a plain terminal “Command Prompt” (ignore the cross prompts shortcuts you might find in the start menu).

...

Code Block
ninja --version
cmake --version

Doing a Build

In the same command prompt as the previous step, set your compiler(s) to be the clang-cl.exe we installed earlier.

...

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. To 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. This changes their last accessed times 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)

Install LLDB API and testsuite dependencies

  • Install GNUWin32 for make and coreutils. LLDB tests depend on make and some of the coreutils for running API tests. Install it using standard install as 32bit x86 emulated executable and add install location to PATH.

  • Install native Python. LLDB API requires native python library. Here is a link to a unofficial build of native python installer for WoA.

  • Install SWIG 3 or later. LLDB requires swig to generate Python bindings. Install SWIG via x86 emulated installer and add to PATH.

...