2.8 KiB
2.8 KiB
LLVM Build Infrastructure
package.py script automates downloading, building and packing of LLVM distribution used by Kotlin/Native.
Requirements
- Check LLVM requirements. Note that:
- Visual Studio 2017 is required on Windows
- Xcode is required on macOS
- Python 3
- ninja
- git
- CMake
Usage
Just run
python3 package.py
It will create a llvm-distribution folder which contains LLVM distribution.
Note that build will take a lot of time and all your machine cores. 😈
See HACKING.md
on how to use freshly built distribution.
Building distribution for end-users
By default, package.py installs a lot of LLVM components that is not really required to use Kotlin/Native compiler.
To build only essential parts, run the following command:
python3 package.py --build-targets install-distribution --distribution-components $DISTRIBUTION_COMPONENTS
Set of required $DISTRIBUTION_COMPONENTS depends on OS:
| OS | Distribution components |
|---|---|
| Windows | clang libclang lld llvm-cov llvm-profdata llvm-ar clang-resource-headers |
| macOS | clang libclang lld llvm-cov llvm-profdata llvm-ar clang-resource-headers |
| Linux | clang libclang lld llvm-cov llvm-profdata llvm-ar clang-resource-headers compiler_rt |
Tuning
Run python3 package.py -h to check how one can tune script's behavior.
Some examples:
--packcreates an archive (zipon Windows,tar.gzon macOS and Linux) with distribution alongside with its SHA256.--install-pathallows overriding distribution's output directory.--num-stagesspecifies number of steps in build. Passing 2 or more makes bootstrap build which means that LLVM will build itself by using distribution from the previous step.--stage0allows using existing LLVM toolchain for bootstrapping.--build-targetsspecifies what targets will be passed to Ninja.--distribution-componentsis a list of components that will be installed withinstall-distributionbuild target.
Docker
You can use Docker to build LLVM for Linux:
docker build -t kotlin-llvm-builder .
docker run --rm -it -v <HOST_PATH>:/output kotlin-llvm-builder --install-path /output/llvm-11.1.0-linux-x64 --pack
Known problems
libcxxandcompiler-rtare built as projects, not runtimes.- No way to run LLVM tests out of the box.