This page describes how to build the Vale compiler.
Note that the below instructions don't build LLVM from source, but we highly recommend it. Building LLVM from source will enable its debug-only checks, which help immensely when modifying the compiler.
sudo apt install -y git
git clone --single-branch --branch master https://github.com/ValeLang/Vale
Vale/install-compiler-prereqs-linux.sh ~/LLVMForVale ~/BootstrappingValeCompiler
cd Vale
./scripts/ubuntu/build-compiler.sh ~/LLVMForVale/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04 ~/BootstrappingValeCompiler --test=all ./scripts/VERSION
git clone --single-branch --branch master https://github.com/ValeLang/Vale
Vale/install-compiler-prereqs-mac.sh ~/BootstrappingValeCompiler
source ~/.zshrc
cd Vale
./scripts/mac/build-compiler.sh ~/BootstrappingValeCompiler --test=all ./scripts/VERSION
One must build LLVM from source, because the Windows LLVM release is broken.
- Install Visual Studio
- Install python 3, remember to check the box to add it to the path
- Install git: https://git-scm.com/download/win
- Install sbt: https://github.com/sbt/sbt/releases (look for the .msi on that page)
- Install java: https://adoptopenjdk.net/
- Install 7-zip: https://www.7-zip.org/download.html
- Install the previous version of the vale compiler: https://vale.dev/download
- Build LLVM, see next section.
- Build the compiler, which is the section after next.
If you want to skip this, you can download and extract this file to C:\llvm
. Disclaimer: Download at your own risk; we made this .zip file by building it, stripping it down, and merging the include files to fix the problems with the regular LLVM windows release.
Ensure your machine (or VM) has sufficient resources: 5 cores, 10gb ram, 200gb disk. You'll be building all of LLVM, which is quite resource intensive.
Download LLVM sources.
Unzip to e.g. C:\llvm-project-llvmorg-11.0.1
.
Depending on where visual studio is:
- If in Program Files (x86), use the program "x86_64 Cross Tools Command Prompt for VS 2019"
- If in Program Files, use the program "Developer Command Prompt for VS 2019"
cd C:\llvm-project-llvmorg-13.0.1
mkdir build
cd build
For when building a distributable (such as for CI) LLVM release: the built LLVM (in the build
directory here) will reference things in the original source directory (the C:\llvm-project-llvmorg-13.0.1
here). This is why we make a build
subdirectory under the source directory; we can then package it all up together and distribute it as one archive.
cmake "C:\llvm-project-llvmorg-13.0.1\llvm" -D "CMAKE_INSTALL_PREFIX=C:\llvm-project-llvmorg-13.0.1\build" -D CMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -Thost=x64 -A x64
cmake --build .
cmake --build . --target install
Once youve done the above steps and installed LLVM, run the below commands:
git clone https://github.com/ValeLang/Vale --single-branch --branch master
cd Vale
.\scripts\windows\build-compiler.bat C:\llvm\llvm-project-llvmorg-13.0.1 C:\OldValeCompiler --test=all ./scripts/VERSION
If you get an error "fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'" and you're running in the shell "x64_x86 Cross Tools Command Prompt for VS 2022", try instead running in the shell "x64 Native Tools Command Prompt for VS 2022".
If working on the Vale compiler, it's best to:
- Build LLVM from scratch, in debug mode.
- Use CLion.
- Build with a profile, with an environment variable
LLVM_DIR=(llvm build dir)
. Verify in the CMake log looking for "Using LLVMConfig.make in (llvm build dir)".
- Build with a profile, with an environment variable