Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions build-scripts/build_llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def query_llvm_version(llvm_info):
return response['sha']


def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_flags=''):
def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_flags='', use_ccache=False):
LLVM_COMPILE_OPTIONS = [
'-DCMAKE_BUILD_TYPE:STRING="Release"',
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
Expand All @@ -68,8 +68,8 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
"-DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON",
]

# ccache is not available on Windows
if not "windows" == platform:
# ccache is opt-in via --use-ccache flag
if not "windows" == platform and use_ccache:
LLVM_COMPILE_OPTIONS.append("-DLLVM_CCACHE_BUILD:BOOL=ON")
# perf support is available on Linux only
if "linux" == platform:
Expand Down Expand Up @@ -270,6 +270,11 @@ def main():
action="store_true",
help="use clang instead of gcc",
)
parser.add_argument(
"--use-ccache",
action="store_true",
help="enable ccache for faster incremental LLVM builds (disabled by default to reduce CI storage consumption, recommended for local development)",
)
parser.add_argument(
"--extra-cmake-flags",
type=str,
Expand Down Expand Up @@ -334,7 +339,7 @@ def main():
if (
build_llvm(
llvm_dir, platform, options.arch, options.project, options.use_clang,
options.extra_cmake_flags
options.extra_cmake_flags, options.use_ccache
)
is not None
):
Expand Down
6 changes: 6 additions & 0 deletions product-mini/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ cd product-mini/platforms/linux/
./build_llvm.sh (The llvm source code is cloned under <wamr_root_dir>/core/deps/llvm and auto built)
```

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:
``` Bash
cd <wamr_root_dir>/build-scripts
python3 build_llvm.py --arch X86 --use-ccache
```

Then pass argument `-DWAMR_BUILD_JIT=1` to cmake to enable LLVM JIT:
``` Bash
mkdir build && cd build
Expand Down
2 changes: 2 additions & 0 deletions tests/benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ cmake ../llvm \
ninja -j 8
# tool `llvm-profdata` is generated under this folder.
```

> **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`
Loading