Skip to content

Commit 2e2b1c1

Browse files
committed
ci: Download and cache LLVM for the fuzz build
1 parent c7231fc commit 2e2b1c1

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

.github/workflows/main.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,18 @@ jobs:
2222
os: ubuntu-24.04
2323
steps:
2424
- uses: actions/checkout@v6
25-
- name: Install Rust
26-
run: rustup update nightly --no-self-update && rustup default nightly
25+
- name: Install Dependencies
26+
run: |
27+
rustup update nightly --no-self-update
28+
rustup default nightly
29+
sudo apt-get install -y llvm # Needed to build the C++ APFloat
30+
- name: Download llvm source
31+
run: ./etc/download-llvm.sh
32+
# This should also cache LLVM since it downloads to `target/llvm-downloads`
2733
- uses: Swatinem/rust-cache@v2
34+
with:
35+
key: ${{ matrix.target }}
36+
2837
- name: Build and run tests
2938
run: cargo test --workspace
3039

@@ -48,7 +57,7 @@ jobs:
4857
- uses: Swatinem/rust-cache@v2
4958
- run: |
5059
# strip the fuzz crate that uses a newer edition
51-
sed '/members =/d' Cargo.toml
60+
sed -i '/members =/d' Cargo.toml
5261
cargo build --package rustc_apfloat
5362
5463
rustfmt:

etc/download-llvm.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ version="$(
1212
llvm_hash="${version##*-}"
1313

1414
target_dir="${CARGO_TARGET_DIR:-target}"
15-
out_dir="$target_dir/llvm-downloads/"
15+
out_dir="$target_dir/llvm-downloads"
1616
mkdir -p "$out_dir"
1717

18+
if [ -d "$out_dir/llvm-project-$llvm_hash" ] && [ "${1:-}" != "-f" ]; then
19+
echo Download already exists. Pass '-f' to overwrite.
20+
exit
21+
fi
22+
1823
tgz_url="https://codeload.github.com/llvm/llvm-project/tar.gz/$llvm_hash"
1924
curl -sS "$tgz_url" | tar -C "$out_dir" -xz

fuzz/src/apf_fuzz.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class FloatEval {
127127
rm = APFloat::rmNearestTiesToAway;
128128
break;
129129
default:
130-
printf("unsupported rounding mode %d\n", rm);
130+
printf("unsupported rounding mode %d\n", static_cast<int8_t>(rm));
131131
exit(1);
132132
}
133133

@@ -175,7 +175,7 @@ class FloatEval {
175175
a.convert(sem, rm, &cvt_exact);
176176
break;
177177
default:
178-
printf("unrecognized op tag %d", tag);
178+
printf("unrecognized op tag %d", static_cast<int8_t>(tag));
179179
exit(1);
180180
}
181181

0 commit comments

Comments
 (0)