-
Notifications
You must be signed in to change notification settings - Fork 0
Build LLVM with the Repo Compiler
This page shows how to build the llvm-project-prepo project from source then use the resulting compiler to re-build LLVM on Linux.
-
Clone llvm-project-prepo repository:
$ git clone https://github.com/SNSystems/llvm-project-prepo.git -
(Temporary) Checkout temporary branch named 'build_llvm_project_repo_using_built_repo_compiler':
$ cd llvm-project-prepo $ git checkout build_llvm_project_repo_using_built_repo_compiler -
Clone pstore:
$ git clone https://github.com/SNSystems/pstore.git -
Build LLVM enabling the clang and pstore subprojects:
$ mkdir build && cd build $ cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;pstore" -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF ../llvm $ ninja
This task invokes:
- compile the llvm-project-prepo project targeting the program repository using the initial repo compiler
- convert the Repo ticket files to ELF object files using repo2obj
- link the ELF object files to generate an executable ELF file
- repeat the above steps once to verity database (i.e. all fragments are in the database)
-
Copy the repo.json to a parent directory of your llvm-project-prepo build directory, for example, your local llvm-project-prepo repository.
$ cd llvm-project-prepo $ cp ./llvm/utils/repo/repo.json . $ less repo.json { "ar": "/usr/bin/ar", "link": "/usr/bin/clang++", "repo2obj": "/point/to/the/repo2obj/tool/in/llvm-pstore/build/directory" } -
Continue to use the standard ar and clang++ for the archiving and linking because the repo toolchain currently only supports the compilation. Modify the repo2obj option to point to the repo2obj tool in your build directory. Note: it must be an absolute path. e.g.
"repo2obj": "/home/username/llvm-project-prepo/build/bin/repo2obj" -
Generate a release build using the repo.cmake toolchain file.
$ cd llvm-project-prepo $ mkdir build_repo_release && cd build_repo_release $ cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS="clang;pstore" -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF -DPSTORE_ENABLE_BROKER=OFF -DLLVM_DISABLE_DYNAMIC_LIBRARY_UNITTEST=ON -DCMAKE_TOOLCHAIN_FILE=/home/username/github/llvm-project-prepo/llvm/utils/repo/repo.cmake -DCMAKE_CXX_COMPILER=/home/username/github/llvm-project-prepo/build/bin/clang++ -DCMAKE_C_COMPILER=/home/username/github/llvm-project-prepo/build/bin/clang -Dutils_dir=/home/username/github/llvm-project-prepo/llvm/utils/repo ../llvm You must specify for cmake: 1. -DPSTORE_ENABLE_BROKER=OFF Disable the pstore broker projects since the repo compiler currently does not support exception handling 2. -DLLVM_DISABLE_DYNAMIC_LIBRARY_UNITTEST=ON Disable the dynamic library unittests [issue12](https://github.com/SNSystems/llvm-project-prepo/issues/12) 3. -DCMAKE_TOOLCHAIN_FILE=/home/username/github/llvm-project-prepo/llvm/utils/repo/repo.cmake 4. -DCMAKE_CXX_COMPILER=/home/username/github/llvm-project-prepo/build/bin/clang++ 5. -DCMAKE_C_COMPILER=/home/username/github/llvm-project-prepo/build/bin/clang Both CMAKE_CXX_COMPILER and DCMAKE_C_COMPILER are pointing to the initial repo compiler. 6. -Dutils_dir=/home/username/github/llvm-project-prepo/llvm/utils/repo Specify the repo utilities directory, which contains additional scripts requied for the build. $ ninja -
clean/delete all ticket files (retain the clang.db database) and build the project again (for the second time build: all fragments will be in the database.)
$ ninja clean $ ninja
Run the LLVM and Clang tests for build. For a debug build, currently there are 30552 tests passed out of 30567 tests (99.95%). Currently for the release build, there are 30583 tests passed out of 30717 tests (99.56%).
$ ninja check-all
The llvm-project-prepo has been built and run with the tests twice in debug and release configurations.
Debug build with compiler switches: -O0 -fno-exceptions -fno-rtti.
Release build with compiler switches: -O3 -fno-exceptions -fno-rtti.
| Configuration | 1st build | 1st run test | 2nd build | 2nd run test |
|---|---|---|---|---|
| Debug | ✔ | 99.95% tests passed | ✔ | 99.95% tests passed |
| Release | ✔ | 99.56% tests passed | ✔ | 99.56% tests passed |