-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
LLVM Upgrade Process
Andrew Kelley edited this page Sep 19, 2023
·
41 revisions
This page documents how to update the Zig source code to a new LLVM version.
master branch is always the latest LLVM release. The llvmX branch is kept up to date with the next LLVM release. The day that LLVM is released, we merge the llvmX branch into master, and start the next llvmX branch, following this upgrade process.
- Start the
llvmXbranch. - Update the version numbers in:
cmake/Findllvm.cmakecmake/Findclang.cmakecmake/Findlld.cmake
- Build LLVM, Clang, and LLD in Release mode with assertions on.
- Update
src/zig_clang_*.cppto the new versions. Before updating, replace each file with the original file from the old LLVM version and do agit diffto see what patches have been applied by Zig. Then update each file to the versions from the new LLVM, and re-apply the patches as necessary.-
src/zig_clang_driver.cppcorresponds tollvm-project/clang/tools/driver/driver.cpp- Be sure not to accidentally regress #3292.
-
src/zig_clang_cc1_main.cppcorresponds tollvm-project/clang/tools/driver/cc1_main.cpp -
src/zig_clang_cc1as_main.cppcorresponds tollvm-project/clang/tools/driver/cc1as_main.cpp -
src/zig_llvm-ar.cppcorresponds tollvm-project/llvm/tools/llvm-ar/llvm-ar.cpp
-
- Update
lib/include/to the latestclang_install_prefix/lib/clang/X.Y.Z/include/. - Update
lib/libcxx/,lib/libcxxabi, andlib/libunwindto the latestllvm-project/respective directory. Only theinclude/directory,src/directory, andLICENSE.txtare copied. CMake, README, shell scripts files are not copied. Updatesrc/libunwind.zigandsrc/libcxx.zigto have a correct list of files. - Update
tsanto the latestllvm-project/compiler-rt/tsandirectory. Only the necessary files are copied. Updatesrc/libtsan.zigto have a correct list of files. - Run
tools/update_cpu_features.zigwith the new LLVM version. Unless you have a beefy machine, you'll probably want--single-threadedto limit the CPU & memory resource usage of this script. After running the tool, inspect the git diff. Think carefully about deletions, since this could represent breaking changes. Modifications to the script might be needed in order to clean up the output. - Update the CI scripts to the new version.
- Update the static asserts at the bottom of
src/zig_llvm.cpp - Run
tools/update_clang_options.zigand use it to update the filesrc-self-hosted/clang_options_data.zig. - Build zig in debug mode with asserts-enabled llvm, clang, lld, and run the full Zig test suite.
- Merge the
llvmXbranch intomaster. - Update How to build LLVM, libclang, and liblld from source.
- Update Building Zig on Windows.