Skip to content

Commit efcb560

Browse files
committed
ci(llvm): disable Windows LLVM tools except llvm-config
Retry of the Windows LLVM tool-disable that landed+reverted in #360 (commits 3106d1e / 90df14b). The first attempt broke `Run tests` because `llvm-sys` (pulled in via inkwell) runs `${LLVM_SYS_211_PREFIX}/bin/llvm-config` at Rust crate-build time to discover include/lib paths, and `llvm-config` is itself an LLVM tool that got disabled along with the rest. This version keeps `llvm-config` alive while disabling the other ~200 tool binaries: -DLLVM_BUILD_TOOLS=Off # tools are no longer in the ALL target -DLLVM_INCLUDE_TOOLS=On # tools/ subdirectory still configured, # so individual tool targets exist -DLLVM_TOOL_LLVM_CONFIG_BUILD=On # per-tool override forces llvm-config # specifically into the ALL target LLVM's cmake uses the `LLVM_TOOL_<name>_BUILD` pattern to let individual tools opt back in when LLVM_BUILD_TOOLS is off. Expected effect: only `llvm-config.exe` builds (small link), the ~200 heavy tool links are skipped. Run 24771100328 confirmed the validation target: with all tools disabled the Windows Build LLVM step went from 42 min → 9:44 (4.3×). This PR aims to preserve that win while keeping `llvm-sys` happy. Cache-key hardening (required for correctness) Extracts the cmake `--extra-args` construction into a new `Compute LLVM build config` step and hashes the flag list into the artifact cache key (`...-args<sha8>-<solx-llvm-sha>`). Without this, the existing key only reflects the solx-dev action inputs + the solx-llvm submodule SHA — not the cmake flags — so entries built with `LLVM_BUILD_TOOLS=Off` on Windows would share a key with entries built with tools `On` and silently serve the wrong install tree. Side-benefit: the hash catches any future output-affecting flag added to `--extra-args` without requiring reviewer discipline to update the key. Non-output-affecting flag tweaks (e.g. LLVM_PARALLEL_LINK_JOBS scheduling) also rotate the key, costing one cold build per tweak — acceptable with ccache as fallback and much more robust than manual key maintenance. The Build LLVM step now reads `${RUNNER_TEMP}/llvm-extra-args` produced by the new step, so EXTRA_ARGS is constructed once and consumed twice (once for the hash, once for the build). Acceptance: - Windows Build LLVM step < 15 min on a warm-ccache run. - Windows `Run tests` succeeds (llvm-sys finds llvm-config). - No regression on Linux/macOS (no flag change; just the new args-hash key component, which triggers a one-time cold build on first run). - `Show ccache stats` still reports near-100% hit rate. See #364 for the full design rationale and alternatives considered.
1 parent bf8cf2c commit efcb560

1 file changed

Lines changed: 48 additions & 12 deletions

File tree

.github/actions/build-llvm/action.yml

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,49 @@ runs:
5252
using: "composite"
5353
steps:
5454

55+
# Compute the cmake --extra-args list once, then (a) persist to a file for
56+
# the Build LLVM step to re-use verbatim, and (b) hash into the artifact
57+
# cache key so flag changes invalidate stale entries. Without hashing,
58+
# changing output-affecting flags (e.g. LLVM_BUILD_TOOLS) while reusing
59+
# the old cache key would let a pre-change entry satisfy a post-change
60+
# restore — confusing or wrong installs. Non-output-affecting flag tweaks
61+
# also rotate the key here; the one-time cache miss is cheap with ccache
62+
# as fallback and the alternative (remembering to update the key when
63+
# adding an output-affecting flag) doesn't hold up to reviewer discipline.
64+
- name: Compute LLVM build config
65+
id: build-config
66+
shell: bash
67+
run: |
68+
# macos-15 ARM runner is 3 vCPU / 7 GB RAM; two parallel RelWithDebInfo
69+
# links exceed RAM and push into swap. 2 fits 14-16 GB runners fine.
70+
LINK_JOBS=2
71+
if [ "${{ runner.os }}" = "macOS" ] && [ "${{ runner.arch }}" = "ARM64" ]; then
72+
LINK_JOBS=1
73+
fi
74+
75+
EXTRA_ARGS=(
76+
"-DCMAKE_EXPORT_COMPILE_COMMANDS='Off'"
77+
"-DLLVM_PARALLEL_LINK_JOBS='${LINK_JOBS}'"
78+
"-DLLVM_OPTIMIZED_TABLEGEN='On'"
79+
)
80+
81+
# Windows: skip LLVM tool binaries to cut lld-link wall-clock, but keep
82+
# llvm-config (llvm-sys needs it at Rust build time) via the per-tool
83+
# LLVM_TOOL_<name>_BUILD override. See #364 for background.
84+
if [ "${{ runner.os }}" = "Windows" ]; then
85+
EXTRA_ARGS+=(
86+
"-DLLVM_BUILD_TOOLS='Off'"
87+
"-DLLVM_INCLUDE_TOOLS='On'"
88+
"-DLLVM_TOOL_LLVM_CONFIG_BUILD='On'"
89+
)
90+
fi
91+
92+
# Step outputs can't round-trip bash array semantics cleanly with
93+
# special chars; write to a file instead.
94+
printf '%s\n' "${EXTRA_ARGS[@]}" > "${RUNNER_TEMP}/llvm-extra-args"
95+
ARGS_HASH=$(sha256sum "${RUNNER_TEMP}/llvm-extra-args" | head -c 8)
96+
echo "args-hash=${ARGS_HASH}" | tee -a "${GITHUB_OUTPUT}"
97+
5598
- name: Compute LLVM cache key
5699
id: llvm-cache
57100
shell: bash
@@ -64,7 +107,7 @@ runs:
64107
[ -n '${{ inputs.sanitizer }}' ] && KEY="${KEY}-${{ inputs.sanitizer }}"
65108
[ '${{ inputs.enable-coverage }}' = 'true' ] && KEY="${KEY}-coverage"
66109
[ '${{ inputs.enable-assertions }}' != 'true' ] && KEY="${KEY}-no-assertions"
67-
KEY="${KEY}-${SHA}"
110+
KEY="${KEY}-args${{ steps.build-config.outputs.args-hash }}-${SHA}"
68111
echo "key=${KEY}" | tee -a "${GITHUB_OUTPUT}"
69112
70113
- name: Restore LLVM artifact cache
@@ -162,20 +205,13 @@ runs:
162205
fi
163206
fi
164207
165-
# With ccache at 99%+ hit rate, link time dominates. Each LLVM tool link
166-
# peaks at 2-4 GB RSS on RelWithDebInfo. The hosted macos-15 ARM runner
167-
# has 3 vCPU / 7 GB RAM — two parallel links alone can exceed RAM and
168-
# push into swap, which is net slower than serialized links. The intel
169-
# macos-15 has 14 GB and handles 2 parallel links fine, as do Linux and
170-
# Windows hosted (16 GB).
171-
LINK_JOBS=2
172-
if [ "${{ runner.os }}" = "macOS" ] && [ "${{ runner.arch }}" = "ARM64" ]; then
173-
LINK_JOBS=1
174-
fi
208+
# Load the cmake --extra-args computed in the Compute LLVM build config
209+
# step (also hashed into the cache key).
210+
readarray -t EXTRA_ARGS < "${RUNNER_TEMP}/llvm-extra-args"
175211
176212
./target/release/solx-dev llvm build --build-type ${{ inputs.build-type }} \
177213
--ccache-variant=ccache ${ENABLE_TESTS} ${ENABLE_VALGRIND} ${VALGRIND_OPTIONS} ${ENABLE_ASSERTIONS} ${ENABLE_COVERAGE} ${ENABLE_MLIR} ${SANITIZER} \
178-
--extra-args "-DCMAKE_EXPORT_COMPILE_COMMANDS='Off'" "-DLLVM_PARALLEL_LINK_JOBS='${LINK_JOBS}'" "-DLLVM_OPTIMIZED_TABLEGEN='On'"
214+
--extra-args "${EXTRA_ARGS[@]}"
179215
180216
# `continue-on-error` keeps a failing ccache install (→ ccache not on PATH)
181217
# from masking the real Build LLVM failure in the step summary.

0 commit comments

Comments
 (0)