Skip to content

Commit 53a6b84

Browse files
committed
build: slim llvm build
simplify llvm build and build llvm on cache miss instead of website download. - Remove website download/publish steps for LLVM; cache misses now fetch sources and build locally before caching. - Simplifies CI by relying solely on GitHub Actions cache for LLVM artifacts and dropping the external website dependency. - Developers don't need help to update download binaries anymore. The local build became reasonable with the slim llvm build.
1 parent 6a85701 commit 53a6b84

File tree

4 files changed

+35
-106
lines changed

4 files changed

+35
-106
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ jobs:
7373
apple-clang: Release
7474
msvc: RelWithDebInfo
7575
install: |
76-
gcc: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev
77-
gcc Coverage: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev lcov
78-
clang: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev g++-14=14.2.0-4ubuntu2~24.04
76+
gcc: git build-essential pkg-config python3 curl unzip openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev
77+
gcc Coverage: git build-essential pkg-config python3 curl unzip openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev lcov
78+
clang: git build-essential pkg-config python3 curl unzip openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev g++-14=14.2.0-4ubuntu2~24.04
7979
msvc: ''
8080
extra-values: |
8181
use-libcxx: {{#if (and (ieq compiler 'clang') (ge major 19)) }}true{{else}}false{{/if}}
@@ -332,36 +332,6 @@ jobs:
332332
path: ${{ steps.rmatrix.outputs.llvm-path }}
333333
key: ${{ matrix.llvm-archive-basename }}
334334

335-
- name: Download LLVM Binaries
336-
id: llvm-download
337-
if: steps.llvm-cache.outputs.cache-hit != 'true'
338-
run: |
339-
set -x
340-
url=https://mrdocs.com/llvm+clang/${{ matrix.llvm-archive-filename }}
341-
http_status=$(curl -s -o /dev/null -w "%{http_code}" -I "$url")
342-
if [ "$http_status" -eq 200 ]; then
343-
found="true"
344-
echo "found=$found" >> $GITHUB_OUTPUT
345-
curl -L -o ${{ matrix.llvm-archive-filename }} "$url"
346-
install_prefix=${{ steps.rmatrix.outputs.llvm-path }}
347-
mkdir -p $install_prefix
348-
if [[ ${{ matrix.llvm-archive-extension }} == '7z' ]]; then
349-
7z x ${{ matrix.llvm-archive-filename }} -o$install_prefix
350-
else
351-
tar -xjf ${{ matrix.llvm-archive-filename }} -C $install_prefix
352-
fi
353-
if [[ $(ls -1 $install_prefix | wc -l) -eq 1 ]]; then
354-
single_dir=$(ls -1 $install_prefix)
355-
if [[ -d $install_prefix/$single_dir ]]; then
356-
mv $install_prefix/$single_dir/* $install_prefix/
357-
rmdir $install_prefix/$single_dir
358-
fi
359-
fi
360-
else
361-
found="false"
362-
echo "found=$found" >> $GITHUB_OUTPUT
363-
fi
364-
365335
# Installs libc++ separately, using the LLVM standalone runtimes build.
366336
# The libc++ built here will be built using the host compiler, so this is
367337
# limited by what libc++ at the current LLVM revision supports.
@@ -375,16 +345,27 @@ jobs:
375345
# FIXME: Build this for the GCC and MacOS sanitizer jobs.
376346
# Currently GCC fails linking it, and for MacOS there are compiler-rt
377347
# requirements not satisfied.
348+
- name: Fetch LLVM source archive
349+
if: steps.llvm-cache.outputs.cache-hit != 'true'
350+
run: |
351+
set -eux
352+
mkdir -p ../third-party
353+
cd ../third-party
354+
archive="llvm-${{ matrix.llvm-hash }}.zip"
355+
if [ ! -d llvm-project ]; then
356+
curl -L -o "$archive" "https://github.com/llvm/llvm-project/archive/${{ matrix.llvm-hash }}.zip"
357+
unzip -q "$archive"
358+
mv "llvm-project-${{ matrix.llvm-hash }}" llvm-project
359+
rm "$archive"
360+
fi
361+
378362
- name: Install libc++
379363
id: install_libcxx
380364
uses: alandefreitas/cpp-actions/[email protected]
381-
if: matrix.use-libcxx == 'true' && steps.llvm-cache.outputs.cache-hit != 'true' && steps.llvm-download.outputs.found != 'true'
365+
if: matrix.use-libcxx == 'true' && steps.llvm-cache.outputs.cache-hit != 'true'
382366
with:
383367
cmake-version: '>=3.26'
384368
source-dir: ../third-party/llvm-project/runtimes
385-
git-repository: https://github.com/llvm/llvm-project.git
386-
git-tag: ${{ matrix.llvm-hash }}
387-
download-dir: ../third-party/llvm-project
388369
build-dir: ${sourceDir}/build
389370
build-type: ${{ matrix.build-type }}
390371
extra-args: |
@@ -415,13 +396,10 @@ jobs:
415396
- name: Install LLVM
416397
id: install_llvm
417398
uses: alandefreitas/cpp-actions/[email protected]
418-
if: steps.llvm-cache.outputs.cache-hit != 'true' && steps.llvm-download.outputs.found != 'true'
399+
if: steps.llvm-cache.outputs.cache-hit != 'true'
419400
with:
420401
cmake-version: '>=3.26'
421402
source-dir: ../third-party/llvm-project/llvm
422-
git-repository: https://github.com/llvm/llvm-project.git
423-
git-tag: ${{ matrix.llvm-hash }}
424-
download-dir: ../third-party/llvm-project
425403
patches: |
426404
./third-party/patches/llvm/llvm/CMakePresets.json
427405
./third-party/patches/llvm/llvm/CMakeUserPresets.json
@@ -1246,69 +1224,9 @@ jobs:
12461224
with:
12471225
apt-get: ${{ matrix.install }}
12481226

1249-
- name: Check website releases
1250-
id: website-releases
1251-
run: |
1252-
set -x
1253-
archive_url="https://mrdocs.com/llvm+clang/${{ matrix.llvm-archive-filename }}"
1254-
http_status=$(curl -s -o /dev/null -w "%{http_code}" -I "$archive_url")
1255-
if [ "$http_status" -eq 200 ]; then
1256-
exists="true"
1257-
else
1258-
exists="false"
1259-
fi
1260-
echo "exists=$exists" >> $GITHUB_OUTPUT
1261-
12621227
- name: LLVM Binaries
12631228
id: llvm-cache
1264-
if: steps.website-releases.outputs.exists != 'true'
12651229
uses: actions/cache@v4
12661230
with:
12671231
path: ${{ steps.rmatrix.outputs.llvm-path }}
12681232
key: ${{ matrix.llvm-archive-basename }}
1269-
1270-
- name: Compress LLVM
1271-
id: llvm-upload
1272-
if: steps.llvm-cache.outputs.cache-hit == 'true'
1273-
shell: bash
1274-
run: |
1275-
# LLVM is be installed with the default compiler
1276-
set -x
1277-
1278-
# Use 7z on windows
1279-
if [[ ${{ runner.os }} == 'Windows' ]]; then
1280-
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on "${{ matrix.llvm-archive-filename }}" "${{ steps.rmatrix.outputs.llvm-path }}"
1281-
else
1282-
tar -cjf "${{ matrix.llvm-archive-filename }}" -C "${{ steps.rmatrix.outputs.llvm-path }}/.." llvm
1283-
fi
1284-
1285-
- name: Website LLVM Releases
1286-
if: steps.llvm-cache.outputs.cache-hit == 'true' && github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/'))
1287-
run: |
1288-
set -x
1289-
1290-
# Ensure required commands exist
1291-
for cmd in ssh-keyscan ssh-agent ssh-add scp; do
1292-
if ! command -v $cmd >/dev/null; then
1293-
echo "$cmd not found"
1294-
exit 1
1295-
fi
1296-
done
1297-
1298-
# Add SSH key
1299-
mkdir -p ~/.ssh
1300-
ssh-keyscan dev-websites.cpp.al >> ~/.ssh/known_hosts
1301-
chmod 600 ~/.ssh/known_hosts
1302-
echo "${{ secrets.DEV_WEBSITES_SSH_KEY }}" > ~/.ssh/github_actions
1303-
chmod 600 ~/.ssh/github_actions
1304-
1305-
# Start ssh-agent and add the key
1306-
SSH_AUTH_SOCK="$RUNNER_TEMP/ssh_agent.sock"
1307-
export SSH_AUTH_SOCK
1308-
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
1309-
ssh-add ~/.ssh/github_actions
1310-
1311-
# Copy llvm archive: This step will copy the archive to www.mrdocs.com/llvm+clang
1312-
llvm_dir="/var/www/mrdox.com/llvm+clang"
1313-
chmod 755 ${{ matrix.llvm-archive-filename }}
1314-
scp -o StrictHostKeyChecking=no $(pwd)/${{ matrix.llvm-archive-filename }} [email protected]:$llvm_dir/

.github/workflows/pr-target-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Install repo-check tools
3434
run: npm --prefix util/danger ci
3535

36-
- name: Repo checks (Danger)
36+
- name: Repo checks (Danger.js)
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3939
run: npx --prefix util/danger danger ci --dangerfile util/danger/dangerfile.ts

bootstrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3132,7 +3132,7 @@ def validate_cli_compatibility(self):
31323132

31333133
def collect_user_inputs(self):
31343134
"""
3135-
Phase 1: ask all questions up front to mirror bootstrap-other's two-phase flow.
3135+
Phase 1: ask all questions up front for a two-phase flow.
31363136
This keeps prompts grouped before any work begins.
31373137
"""
31383138
self.ui.section("MrDocs Bootstrap", icon="🚀")

third-party/patches/llvm/llvm/CMakePresets.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
"LLVM_ENABLE_RUNTIMES": "libcxx",
1919
"LLVM_TARGETS_TO_BUILD": "Native",
2020

21+
22+
"LLVM_ENABLE_ZLIB": false,
23+
"LLVM_ENABLE_ZSTD": false,
24+
"LLVM_ENABLE_LIBXML2": false,
25+
"LLVM_ENABLE_BACKTRACES": false,
26+
2127
"LLVM_UNREACHABLE_OPTIMIZE": false,
2228
"LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION": false,
2329
"LLVM_ENABLE_RTTI": true,
@@ -43,14 +49,19 @@
4349
"LLVM_BUILD_DOCS": false,
4450
"LLVM_BUILD_EXAMPLES": false,
4551
"LLVM_ENABLE_TERMINFO": false,
46-
"CLANG_ENABLE_ARCMT": true,
4752
"CLANG_ENABLE_HLSL": false,
4853
"CLANG_ENABLE_OBJC_REWRITER": false,
4954
"CLANG_ENABLE_PROTO_FUZZER": false,
50-
"CLANG_ENABLE_STATIC_ANALYZER": true,
55+
"CLANG_ENABLE_STATIC_ANALYZER": false,
56+
"CLANG_ENABLE_FORMAT": false,
5157
"CLANG_INCLUDE_TESTS": false,
5258
"CLANG_INCLUDE_DOCS": false,
53-
"CLANG_BUILD_EXAMPLES": false
59+
"CLANG_BUILD_EXAMPLES": false,
60+
61+
"LIBCXX_ENABLE_SHARED": false,
62+
"LIBCXX_ENABLE_STATIC": true,
63+
"LIBCXX_INCLUDE_TESTS": false,
64+
"LIBCXX_INCLUDE_BENCHMARKS": false
5465
},
5566
"warnings": {
5667
"unusedCli": false

0 commit comments

Comments
 (0)