Skip to content

Commit bc4d683

Browse files
lum1n0usclaude
andauthored
disable ccache by default when building llvm libraries (#4885)
* feat: add --use-ccache CLI argument to build_llvm.py Add a new --use-ccache flag that will allow developers to opt-in to using ccache for LLVM builds. This is part of a larger effort to disable ccache by default to reduce CI storage consumption while still allowing local developers to benefit from faster incremental builds. Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent f0aa4e8 commit bc4d683

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

build-scripts/build_llvm.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def query_llvm_version(llvm_info):
4848
return response['sha']
4949

5050

51-
def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_flags=''):
51+
def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_flags='', use_ccache=False):
5252
LLVM_COMPILE_OPTIONS = [
5353
'-DCMAKE_BUILD_TYPE:STRING="Release"',
5454
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
@@ -68,8 +68,8 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
6868
"-DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON",
6969
]
7070

71-
# ccache is not available on Windows
72-
if not "windows" == platform:
71+
# ccache is opt-in via --use-ccache flag
72+
if not "windows" == platform and use_ccache:
7373
LLVM_COMPILE_OPTIONS.append("-DLLVM_CCACHE_BUILD:BOOL=ON")
7474
# perf support is available on Linux only
7575
if "linux" == platform:
@@ -270,6 +270,11 @@ def main():
270270
action="store_true",
271271
help="use clang instead of gcc",
272272
)
273+
parser.add_argument(
274+
"--use-ccache",
275+
action="store_true",
276+
help="enable ccache for faster incremental LLVM builds (disabled by default to reduce CI storage consumption, recommended for local development)",
277+
)
273278
parser.add_argument(
274279
"--extra-cmake-flags",
275280
type=str,
@@ -334,7 +339,7 @@ def main():
334339
if (
335340
build_llvm(
336341
llvm_dir, platform, options.arch, options.project, options.use_clang,
337-
options.extra_cmake_flags
342+
options.extra_cmake_flags, options.use_ccache
338343
)
339344
is not None
340345
):

product-mini/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ cd product-mini/platforms/linux/
7979
./build_llvm.sh (The llvm source code is cloned under <wamr_root_dir>/core/deps/llvm and auto built)
8080
```
8181

82+
Note: By default, ccache is disabled to reduce CI storage consumption. For local development with frequent LLVM rebuilds, you can enable ccache for faster incremental builds by using the `--use-ccache` flag:
83+
``` Bash
84+
cd <wamr_root_dir>/build-scripts
85+
python3 build_llvm.py --arch X86 --use-ccache
86+
```
87+
8288
Then pass argument `-DWAMR_BUILD_JIT=1` to cmake to enable LLVM JIT:
8389
``` Bash
8490
mkdir build && cd build

tests/benchmarks/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,5 @@ cmake ../llvm \
6565
ninja -j 8
6666
# tool `llvm-profdata` is generated under this folder.
6767
```
68+
69+
> **Note**: The example above shows `-DLLVM_CCACHE_BUILD:BOOL=ON` for enabling ccache in the cmake configuration. When using the `build_llvm.py` script, ccache is disabled by default to reduce CI storage consumption. To enable it with the script, use: `python3 build_llvm.py --use-ccache --arch X86`

0 commit comments

Comments
 (0)