-
Notifications
You must be signed in to change notification settings - Fork 15
Build From Source
LLVM uses CMake to build, but CMake currently has issues with the nested LLD project, so build instructions are still provided on a per-platform basis. The version of LLVM used in this project is a fork with additions to LLD, so attempting to compile inNative with a different build of LLVM will not work.
All build steps start with git submodule update --init --recursive
. This is mandatory because of nested git submodules that the project relies on. If you get errors, be sure to double check that you have acquired llvm
, llvm/tools/lld
, spec
, and spec/document/core/util/katex
.
Regardless of whether you are using Visual Studio 2017 or 2019, make sure you have the v141_xp toolkit installed, first. Run build-llvm.ps1
if you have Visual Studio 2019, or run build-llvm.ps1 2017
if you have Visual Studio 2017, and wait for it to complete. If the script was successful, open innative.sln
in Visual Studio and build the project, or run msbuild innative.sln
. Visual Studio 2019 broke MSBuild outside the developer prompt, so you'll have to open the .sln file and manually compile Debug and MinSizeRel yourself, or run build-llvm.ps1
inside a developer prompt.
The script downloads a portable cmake and python3 into the bin
directory. If you would rather run the commands yourself, have existing installations of cmake/python, or want to modify the LLVM compilation flags, you can run the commands for your version of Visual Studio yourself:
git submodule update --init --recursive
mkdir -p bin/llvm
cd bin/llvm
# Visual Studio 2017
..\cmake-3.14.1-win32-x86\bin\cmake.exe -G "Visual Studio 15 Win64" -DLLVM_TARGETS_TO_BUILD="X86;WebAssembly" -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_UTILS=OFF -DLLVM_BUILD_TOOLS=ON -DCMAKE_CXX_FLAGS_RELEASE="/MT" -DCMAKE_CXX_FLAGS_MINSIZEREL="/MT" -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="/MT" -DCMAKE_CXX_FLAGS_DEBUG="/MTd" -D PYTHON_EXECUTABLE="../python3/python.exe" ../../llvm
# Visual Studio 2019
..\cmake-3.14.1-win32-x86\bin\cmake.exe -G "Visual Studio 16" "-Tv141_xp,host=x64" -DCMAKE_GENERATOR_PLATFORM="x64" -DLLVM_TARGETS_TO_BUILD="X86;WebAssembly" -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_UTILS=OFF -DLLVM_BUILD_TOOLS=ON -DCMAKE_CXX_FLAGS_RELEASE="/MT" -DCMAKE_CXX_FLAGS_MINSIZEREL="/MT" -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="/MT" -DCMAKE_CXX_FLAGS_DEBUG="/MTd" -D PYTHON_EXECUTABLE="../python3/python.exe" ../../llvm
msbuild llvm.sln /p:Configuration=MinSizeRel
msbuild llvm.sln /p:Configuration=Debug
Ensure that you have cmake
and python
installed, as the script can't do this for you. Run build-llvm.sh
if you want to use make
, or you can run build-llvm.sh ninja
if you have ninja
installed to compile LLVM with ninja. If it was successful, run cmake
on inNative's root directory to create project files for either make
or ninja
. The existing Makefile is deprecated and will be removed in a future release! If you would rather run the commands yourself or want to adjust the LLVM compilation flags, you can run the steps manually below:
#!/bin/bash
git submodule update --init --recursive
mkdir -p bin/llvm
cd bin/llvm
# Makefiles
cmake ../../llvm -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE:STRING="MinSizeRel" -DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" -DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF -DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF -DLLVM_INCLUDE_TESTS:BOOL=OFF -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF -DLLVM_APPEND_VC_REV:BOOL=OFF
make
# Ninja
cmake -GNinja ../../llvm -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE:STRING="MinSizeRel" -DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" -DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF -DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF -DLLVM_INCLUDE_TESTS:BOOL=OFF -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF -DLLVM_APPEND_VC_REV:BOOL=OFF
ninja
The benchmarks are already compiled to webassembly, but if you want to recompile them yourself, you can run make benchmarks
from the root directory, assuming you have a webassembly-enabled compiler available. Unfortunately the benchmark compilation hasn't been ported to cmake
yet. If you are on windows, it is recommended you simply use WSL to build the benchmarks.
A Dockerfile
is included in the source that uses a two-stage build process to create an alpine docker image. When assembling a docker image, it is recommended you make a shallow clone of the repository (without any submodules) and then run docker build .
from the root directory, without building anything. Docker will copy the repository and clone the submodules itself, before building both LLVM and inNative, which can take quite some time. Once compiled, inNative will be copied into a fresh alpine image and installed so it is usable from the command line, while the LLVM compilation result will be discarded.
A prebuilt version of this image is available here