- Add command line option `num-to-skip-size` to parameterize the size of `NumToSkip` bytes in the decoder table. Default value will be 2, and targets that need larger size can use 3. - Keep all existing targets, except AArch64, to use size 2, and change AArch64 to use size 3 since it run into the "disassembler decoding table too large" error with size 2. - Additional fixes on top of earlier revert: mark `decodeNumToSkip` as static (not necessary anymore as the generated code is now in anonymous namespace, but doing it for consistency) and incorporate Bazel build changes from https://github.com/llvm/llvm-project/pull/136212 - Following is a rough reduction in size for the decoder tables by switching to size 2. ``` Target Old Size New Size % Reduction ================================================ AArch64 153254 153254 0.00 AMDGPU 471566 412805 12.46 ARC 5724 5061 11.58 ARM 84936 73831 13.07 AVR 1497 1306 12.76 BPF 2172 1927 11.28 CSKY 10064 8692 13.63 Hexagon 47967 41965 12.51 Lanai 1108 982 11.37 LoongArch 24446 21621 11.56 MSP430 4200 3716 11.52 Mips 36330 31415 13.53 PPC 31897 28098 11.91 RISCV 37979 32790 13.66 Sparc 8331 7252 12.95 SystemZ 36722 32248 12.18 VE 48296 42873 11.23 XCore 2590 2316 10.58 Xtensa 3827 3316 13.35 ```
Introduction
Warning The Bazel build is experimental and best-effort, supported in line with the policy for LLVM's peripheral support tier. LLVM's official build system is CMake. If in doubt use that. If you make changes to LLVM, you're expected to update the CMake build but you don't need to update Bazel build files. Reviewers should not ask authors to update Bazel build files unless the author has opted in to support Bazel. Keeping the Bazel build files up-to-date is on the people who use the Bazel build.
Bazel is a multi-language build system focused on reproducible builds to enable dependency analysis and caching for fast incremental builds.
The main motivation behind the existence of an LLVM Bazel build is that a number of projects that depend on LLVM use Bazel, and Bazel works best when it knows about the whole source tree (as opposed to installing artifacts coming from another build system). Community members are also welcome to use Bazel for their own development as long as they continue to maintain the official CMake build system. See also, the proposal for adding this configuration.
Quick Start
git clone https://github.com/llvm/llvm-project.git; cd llvm-projectif you don't have a checkout yet.- Install Bazel at the version indicated by .bazelversion,
following the official instructions, if you don't have it installed yet:
https://docs.bazel.build/versions/main/install.html.
- You can also install and use bazelisk which automates downloading the proper bazel version
cd utils/bazel- The
bazel buildcommand depends on the local compiler you want to use.- For clang, go to step 5.
- For gcc or MSVC, go to step 6
- If you are using clang, it is expected that lld is also available.
The
--config=generic_clangflag by default sets the compiler to beclangbinary on thePATH.To provide a specific path to yourbazel build --config=generic_clang @llvm-project//...clang, use the--repo_envBazel flag. For example:bazel build --config=generic_clang --repo_env=CC=/usr/bin/clang --repo_env=CXX=/usr/bin/clang++ @llvm-project//... - If you are using gcc or MSVC, instead of
--config=generic_clang, pass--config=generic_gccor--config=generic_msvc, which sets the compiler to begccbinary on thePATH.To provide a specific path to yourbazel build --config=generic_gcc @llvm-project//...gcc, use the--repo_envBazel flag. For example:bazel build --config=generic_gcc --repo_env=CC=/usr/bin/gcc --repo_env=CXX=/usr/bin/g++ @llvm-project//...
Configuration
The repository .bazelrc will import user-specific settings from a
user.bazelrc file (in addition to the standard locations). Adding your typical
config setting is recommended.
build --config=generic_clang
You can enable disk caching, which will cache build results
build --disk_cache=~/.cache/bazel-disk-cache
You can instruct Bazel to use a ramdisk for its sandboxing operations via --sandbox_base, which can help avoid IO bottlenecks for the symlink strategy used for sandboxing. This is especially important with many inputs and many cores (see https://github.com/bazelbuild/bazel/issues/11868):
build --sandbox_base=/dev/shm
Bear in mind that this requires that your ramdisk is of sufficient size to hold any temporary files. Anecdotally, 1GB should be sufficient.
Coverage
The LLVM, MLIR, and Clang subprojects have configurations for Linux (Clang and GCC), Mac (Clang and GCC), and Windows (MSVC). Configuration options that are platform-specific are selected for in defines. Many are also hardcoded to the values currently used by all supported configurations. If there is a configuration you'd like to use that isn't supported, please send a patch.
Continuous Testing
A Buildkite pipeline runs the full Bazel build on every commit to the main branch. Notifications of failures are sent to the llvm-bazel-alerts google group, which anyone is free to join. Currently, the behavior is just to send an email on each failure using Buildkite's built-in notification system, so if you subscribe, it is highly recommended that you set up email filters or some other mechanism to not flood your inbox. More sophisticated notifications, e.g. only on status change or routed based on blamelist are TODO (contributions welcome).
Usage in Downstream Projects
To use in dependent projects using Bazel, you can import LLVM and then use the
provided configuration rule. See example usage in the examples/ directory.