Skip to content

Commit f1a8346

Browse files
committed
update build
1 parent ede4b4a commit f1a8346

File tree

1 file changed

+174
-55
lines changed

1 file changed

+174
-55
lines changed

.github/workflows/build-llvm-artifacts.yml

Lines changed: 174 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@ env:
1313

1414
jobs:
1515
build-llvm:
16-
name: Build LLVM Static Libraries
17-
runs-on: ubuntu-latest
16+
name: Build LLVM Static Libraries (${{ matrix.os }})
17+
runs-on: ${{ matrix.os }}
1818
strategy:
1919
matrix:
20-
os: [ubuntu-latest]
21-
# Add macos-latest if needed for cross-platform builds
20+
include:
21+
- os: ubuntu-latest
22+
platform: Linux
23+
arch: x64
24+
- os: macos-latest
25+
platform: macOS
26+
arch: x64
27+
- os: windows-latest
28+
platform: Windows
29+
arch: x64
2230

2331
steps:
2432
- name: Checkout Repository
@@ -28,41 +36,73 @@ jobs:
2836

2937
- name: Setup Build Environment
3038
run: |
31-
sudo apt-get update
32-
sudo apt-get install -y \
33-
ninja-build \
34-
cmake \
35-
build-essential \
36-
libzstd-dev \
37-
zlib1g-dev
39+
if [ "$RUNNER_OS" == "Linux" ]; then
40+
sudo apt-get update
41+
sudo apt-get install -y \
42+
ninja-build \
43+
cmake \
44+
build-essential \
45+
libzstd-dev \
46+
zlib1g-dev
47+
elif [ "$RUNNER_OS" == "macOS" ]; then
48+
brew install ninja cmake
49+
elif [ "$RUNNER_OS" == "Windows" ]; then
50+
choco install ninja cmake
51+
fi
52+
shell: bash
3853

3954
- name: Configure LLVM for Static Linking
4055
run: |
4156
mkdir -p build-static
4257
cd build-static
4358
44-
cmake -G Ninja \
45-
-DCMAKE_BUILD_TYPE=Release \
46-
-DLLVM_TARGETS_TO_BUILD="WebAssembly;X86" \
47-
-DLLVM_BUILD_LLVM_DYLIB=OFF \
48-
-DLLVM_LINK_LLVM_DYLIB=OFF \
49-
-DLLVM_BUILD_STATIC=ON \
50-
-DLLVM_ENABLE_PIC=OFF \
51-
-DLLVM_ENABLE_TERMINFO=OFF \
52-
-DLLVM_ENABLE_ZLIB=OFF \
53-
-DLLVM_ENABLE_ZSTD=OFF \
54-
-DLLVM_INCLUDE_TESTS=OFF \
55-
-DLLVM_INCLUDE_BENCHMARKS=OFF \
56-
-DLLVM_INCLUDE_EXAMPLES=OFF \
57-
-DLLVM_BUILD_TOOLS=ON \
58-
-DLLVM_TOOL_LLVM_CONFIG_BUILD=ON \
59-
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/llvm-install" \
60-
../llvm
59+
if [ "$RUNNER_OS" == "Windows" ]; then
60+
cmake -G Ninja \
61+
-DCMAKE_BUILD_TYPE=Release \
62+
-DLLVM_TARGETS_TO_BUILD="WebAssembly;X86" \
63+
-DLLVM_BUILD_LLVM_DYLIB=OFF \
64+
-DLLVM_LINK_LLVM_DYLIB=OFF \
65+
-DLLVM_BUILD_STATIC=ON \
66+
-DLLVM_ENABLE_TERMINFO=OFF \
67+
-DLLVM_ENABLE_ZLIB=OFF \
68+
-DLLVM_ENABLE_ZSTD=OFF \
69+
-DLLVM_INCLUDE_TESTS=OFF \
70+
-DLLVM_INCLUDE_BENCHMARKS=OFF \
71+
-DLLVM_INCLUDE_EXAMPLES=OFF \
72+
-DLLVM_BUILD_TOOLS=ON \
73+
-DLLVM_TOOL_LLVM_CONFIG_BUILD=ON \
74+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/llvm-install" \
75+
../llvm
76+
else
77+
cmake -G Ninja \
78+
-DCMAKE_BUILD_TYPE=Release \
79+
-DLLVM_TARGETS_TO_BUILD="WebAssembly;X86" \
80+
-DLLVM_BUILD_LLVM_DYLIB=OFF \
81+
-DLLVM_LINK_LLVM_DYLIB=OFF \
82+
-DLLVM_BUILD_STATIC=ON \
83+
-DLLVM_ENABLE_PIC=OFF \
84+
-DLLVM_ENABLE_TERMINFO=OFF \
85+
-DLLVM_ENABLE_ZLIB=OFF \
86+
-DLLVM_ENABLE_ZSTD=OFF \
87+
-DLLVM_INCLUDE_TESTS=OFF \
88+
-DLLVM_INCLUDE_BENCHMARKS=OFF \
89+
-DLLVM_INCLUDE_EXAMPLES=OFF \
90+
-DLLVM_BUILD_TOOLS=ON \
91+
-DLLVM_TOOL_LLVM_CONFIG_BUILD=ON \
92+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/llvm-install" \
93+
../llvm
94+
fi
95+
shell: bash
6196

6297
- name: Build LLVM
6398
run: |
6499
cd build-static
65-
ninja -j$(nproc)
100+
if [ "$RUNNER_OS" == "Windows" ]; then
101+
ninja -j4 # Limit parallelism on Windows to avoid memory issues
102+
else
103+
ninja -j$(nproc)
104+
fi
105+
shell: bash
66106

67107
- name: Install LLVM
68108
run: |
@@ -72,6 +112,7 @@ jobs:
72112
# Verify installation
73113
ls -la "${{ github.workspace }}/llvm-install/bin/" || echo "Install directory not found"
74114
ls -la "${{ github.workspace }}/llvm-install/lib/" || echo "Lib directory not found"
115+
shell: bash
75116

76117
- name: Prepare Artifact Package
77118
run: |
@@ -97,8 +138,13 @@ jobs:
97138
# Copy all static libraries
98139
if [ -d "$SRC_DIR/lib" ]; then
99140
echo "Copying static libraries..."
100-
find "$SRC_DIR/lib" -name "*.a" -exec cp -v {} artifact-package/lib/ \;
101-
echo "✓ Libraries copied: $(ls artifact-package/lib/*.a 2>/dev/null | wc -l) files"
141+
if [ "$RUNNER_OS" == "Windows" ]; then
142+
find "$SRC_DIR/lib" -name "*.lib" -exec cp -v {} artifact-package/lib/ \;
143+
find "$SRC_DIR/lib" -name "*.a" -exec cp -v {} artifact-package/lib/ \;
144+
else
145+
find "$SRC_DIR/lib" -name "*.a" -exec cp -v {} artifact-package/lib/ \;
146+
fi
147+
echo "✓ Libraries copied: $(ls artifact-package/lib/*.a artifact-package/lib/*.lib 2>/dev/null | wc -l) files"
102148
fi
103149
104150
# Copy headers from both install and source
@@ -114,8 +160,14 @@ jobs:
114160
# Copy essential LLVM tools
115161
echo "Copying LLVM tools..."
116162
for tool in llvm-config llc llvm-as llvm-dis llvm-link opt llvm-ar llvm-nm; do
117-
if [ -f "$SRC_DIR/bin/$tool" ]; then
118-
cp -v "$SRC_DIR/bin/$tool" artifact-package/bin/
163+
TOOL_PATH="$SRC_DIR/bin/$tool"
164+
# Add .exe extension on Windows
165+
if [ "$RUNNER_OS" == "Windows" ] && [ -f "$TOOL_PATH.exe" ]; then
166+
cp -v "$TOOL_PATH.exe" artifact-package/bin/
167+
chmod +x artifact-package/bin/$tool.exe
168+
echo "✓ Copied $tool.exe"
169+
elif [ -f "$TOOL_PATH" ]; then
170+
cp -v "$TOOL_PATH" artifact-package/bin/
119171
chmod +x artifact-package/bin/$tool
120172
echo "✓ Copied $tool"
121173
else
@@ -128,8 +180,11 @@ jobs:
128180
echo "📋 Final artifact contents:"
129181
ls -lh artifact-package/bin/ || echo "No binaries found"
130182
echo ""
131-
echo "Library count: $(ls artifact-package/lib/*.a 2>/dev/null | wc -l)"
132-
183+
echo "Library count: $(ls artifact-package/lib/*.a artifact-package/lib/*.lib 2>/dev/null | wc -l)"
184+
shell: bash
185+
186+
- name: Create Setup Scripts
187+
run: |
133188
# Create a config script for Rust builds
134189
cat > artifact-package/setup-env.sh << 'EOF'
135190
#!/bin/bash
@@ -141,7 +196,10 @@ jobs:
141196
echo " LLVM_SYS_211_PREFIX: $LLVM_SYS_211_PREFIX"
142197
EOF
143198
chmod +x artifact-package/setup-env.sh
199+
shell: bash
144200

201+
- name: Create Documentation
202+
run: |
145203
# Create a README
146204
cat > artifact-package/README.md << 'EOF'
147205
# LLVM Uzumaki Static Build
@@ -182,6 +240,7 @@ jobs:
182240
183241
Built from: ${{ github.repository }}@${{ github.sha }}
184242
EOF
243+
shell: bash
185244

186245
- name: Create Build Info
187246
run: |
@@ -198,36 +257,61 @@ jobs:
198257
"static": true
199258
}
200259
EOF
260+
shell: bash
201261

202262
- name: Package Artifact
203263
run: |
204-
tar -czf ${{ env.ARTIFACT_NAME }}-${{ runner.os }}.tar.gz artifact-package/
205-
206-
# Create checksums
207-
sha256sum ${{ env.ARTIFACT_NAME }}-${{ runner.os }}.tar.gz > ${{ env.ARTIFACT_NAME }}-${{ runner.os }}.tar.gz.sha256
264+
if [ "$RUNNER_OS" == "Windows" ]; then
265+
# Use zip for Windows
266+
7z a -tzip ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.zip artifact-package/
267+
268+
# Create checksum
269+
certutil -hashfile ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.zip SHA256 > ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.zip.sha256
270+
else
271+
# Use tar.gz for Unix-like systems
272+
tar -czf ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.tar.gz artifact-package/
273+
274+
# Create checksums
275+
if [ "$RUNNER_OS" == "macOS" ]; then
276+
shasum -a 256 ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.tar.gz > ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.tar.gz.sha256
277+
else
278+
sha256sum ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.tar.gz > ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.tar.gz.sha256
279+
fi
280+
fi
281+
shell: bash
208282

209283
- name: Upload Build Artifacts
210284
uses: actions/upload-artifact@v4
211285
with:
212-
name: ${{ env.ARTIFACT_NAME }}-${{ runner.os }}
286+
name: ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64
213287
path: |
214-
${{ env.ARTIFACT_NAME }}-${{ runner.os }}.tar.gz
215-
${{ env.ARTIFACT_NAME }}-${{ runner.os }}.tar.gz.sha256
288+
${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.*
216289
retention-days: 90
217290
compression-level: 0 # Already compressed
218291

219292
- name: Display Package Info
220293
run: |
221294
echo "📦 Artifact Package Created"
222295
echo "=========================="
223-
ls -lh ${{ env.ARTIFACT_NAME }}-${{ runner.os }}.tar.gz
224-
echo ""
225-
echo "📋 Checksum:"
226-
cat ${{ env.ARTIFACT_NAME }}-${{ runner.os }}.tar.gz.sha256
227-
echo ""
228-
echo "📊 Package Contents:"
229-
tar -tzf ${{ env.ARTIFACT_NAME }}-${{ runner.os }}.tar.gz | head -20
296+
if [ "$RUNNER_OS" == "Windows" ]; then
297+
ls -lh ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.zip
298+
echo ""
299+
echo "📋 Checksum:"
300+
cat ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.zip.sha256
301+
echo ""
302+
echo "📊 Package Contents:"
303+
7z l ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.zip | head -30
304+
else
305+
ls -lh ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.tar.gz
306+
echo ""
307+
echo "📋 Checksum:"
308+
cat ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.tar.gz.sha256
309+
echo ""
310+
echo "📊 Package Contents:"
311+
tar -tzf ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.tar.gz | head -20
312+
fi
230313
echo "... (showing first 20 files)"
314+
shell: bash
231315

232316
create-release:
233317
name: Create Release (on merge to main)
@@ -273,12 +357,21 @@ jobs:
273357
### Usage
274358
275359
Download the artifact for your platform and extract:
360+
361+
**Linux/macOS:**
276362
```bash
277-
tar -xzf llvm-uzumaki-static-Linux.tar.gz
363+
tar -xzf llvm-uzumaki-static-<Platform>-x64.tar.gz
278364
cd artifact-package
279365
source setup-env.sh
280366
```
281367
368+
**Windows:**
369+
```powershell
370+
7z x llvm-uzumaki-static-Windows-x64.zip
371+
cd artifact-package
372+
# Set environment variables manually or use setup-env.sh in Git Bash
373+
```
374+
282375
Then build your Rust project:
283376
```bash
284377
cargo build --release
@@ -287,8 +380,20 @@ jobs:
287380
### Verification
288381
289382
Verify the download with SHA256:
383+
384+
**Linux:**
290385
```bash
291-
sha256sum -c llvm-uzumaki-static-Linux.tar.gz.sha256
386+
sha256sum -c llvm-uzumaki-static-Linux-x64.tar.gz.sha256
387+
```
388+
389+
**macOS:**
390+
```bash
391+
shasum -a 256 -c llvm-uzumaki-static-macOS-x64.tar.gz.sha256
392+
```
393+
394+
**Windows:**
395+
```powershell
396+
certutil -hashfile llvm-uzumaki-static-Windows-x64.zip SHA256
292397
```
293398
294399
**Commit:** ${{ github.sha }}
@@ -300,9 +405,18 @@ jobs:
300405
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
301406

302407
test-artifact:
303-
name: Test Artifact with Sample Rust Project
408+
name: Test Artifact with Sample Rust Project (${{ matrix.platform }})
304409
needs: build-llvm
305-
runs-on: ubuntu-latest
410+
runs-on: ${{ matrix.os }}
411+
strategy:
412+
matrix:
413+
include:
414+
- os: ubuntu-latest
415+
platform: Linux
416+
- os: macos-latest
417+
platform: macOS
418+
- os: windows-latest
419+
platform: Windows
306420

307421
steps:
308422
- name: Checkout
@@ -316,20 +430,25 @@ jobs:
316430
- name: Download LLVM Artifact
317431
uses: actions/download-artifact@v4
318432
with:
319-
name: ${{ env.ARTIFACT_NAME }}-Linux
433+
name: ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64
320434
path: llvm-artifact
321435

322436
- name: Extract and Setup LLVM
323437
run: |
324438
cd llvm-artifact
325-
tar -xzf ${{ env.ARTIFACT_NAME }}-Linux.tar.gz
439+
if [ "$RUNNER_OS" == "Windows" ]; then
440+
7z x ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.zip
441+
else
442+
tar -xzf ${{ env.ARTIFACT_NAME }}-${{ matrix.platform }}-x64.tar.gz
443+
fi
326444
source artifact-package/setup-env.sh
327445
328446
# Verify llvm-config works
329447
$LLVM_CONFIG_PATH --version
330448
331449
echo "LLVM_SYS_211_PREFIX=$LLVM_SYS_211_PREFIX" >> $GITHUB_ENV
332450
echo "LLVM_CONFIG_PATH=$LLVM_CONFIG_PATH" >> $GITHUB_ENV
451+
shell: bash
333452

334453
- name: Create Test Rust Project
335454
run: |

0 commit comments

Comments
 (0)