Skip to content

Commit 76c0d72

Browse files
committed
ci: compile WASM binaries to different machine code targets
1 parent dbaf1f7 commit 76c0d72

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

.github/workflows/prebuild.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,30 @@ jobs:
7575
mv target/wasm32-wasip2/debug/datafusion_udf_wasm_python.wasm out/datafusion_udf_wasm_python.debug.wasm
7676
mv target/wasm32-wasip2/release/datafusion_udf_wasm_python.wasm out/datafusion_udf_wasm_python.release.wasm
7777
78+
- name: compile WASM to machine code
79+
run: |
80+
targets=(
81+
"aarch64-apple-darwin"
82+
"aarch64-pc-windows-msvc"
83+
"aarch64-unknown-linux-gnu"
84+
"x86_64-pc-windows-msvc"
85+
"x86_64-unknown-linux-gnu"
86+
)
87+
88+
for wasm_file in out/*.wasm; do
89+
wasm_file="$(basename "$wasm_file" .wasm)"
90+
for target in "${targets[@]}"; do
91+
out_file="${wasm_file}.${target}.so"
92+
echo "$out_file"
93+
cargo run --bin=compile --features="all-arch" -- "out/${wasm_file}.wasm" "out/${out_file}" "$target"
94+
done
95+
done
96+
97+
- name: calculate checksums
98+
run: |
99+
sha256sum * > sha256sum.txt
100+
working-directory: ./out
101+
78102
- name: read wasmtime version
79103
id: wasmtime
80104
run: |
@@ -86,20 +110,38 @@ jobs:
86110
id: attestation
87111
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3
88112
with:
89-
subject-path: out/*.wasm
113+
subject-path: out/*
90114

91115
- name: publish release
92116
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2
93117
with:
94118
body: |
95119
WASM guest binaries.
96120
121+
# Build Metadata
122+
97123
**Commit:** [`${{ github.sha }}`](${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }})
98124
**Wasmtime:** `${{ steps.wasmtime.outputs.VERSION }}`
99125
**Build Timestamp:** `${{ steps.timestamp.outputs.TIMESTAMP_ISO }}`
100126
**Build Attestation:** <${{ steps.attestation.outputs.attestation-url }}>
127+
128+
# WASM Binaries
129+
We build the following targets:
130+
131+
- `example_add_one`: "add one" Rust example UDF
132+
- `datafusion_udf_wasm_python`: Guest for Python-based UDFs, bundles CPython.
133+
134+
Each of them is provided `debug` and `release` build. The artifacts have the file extension `.wasm`.
135+
136+
# Machine-Code Binaries
137+
In addition to the WASM binary blobs, we also provide pre-compiled guests for various targets to be used with `wasmtime`. The artifacts have the file extension `.so`.
138+
139+
**⚠️ Using pre-build binaries requires you to validate the source and trust the binary. Using a binary blindly can lead to remote code execution, memory and data corruption, and all kinds of bad things. You can use the provided build attestation. ⚠️**
140+
141+
# Checksums & Attestation
142+
We provide sha256 checksums for all artifacts in `sha256sum.txt`. You can use that file -- either directly or indirectly via its own checksum -- to safely pin all artifacts of this release. We also provide [build attestation]({{ steps.attestation.outputs.attestation-url }}).
101143
preserve_order: true
102-
files: out/*.wasm
144+
files: out/*
103145
name: "WASM Binaries ${{ steps.timestamp.outputs.TIMESTAMP_ISO }}"
104146
tag_name: "wasm-binaries/${{ steps.timestamp.outputs.TIMESTAMP_TAG }}/${{ github.sha }}"
105147
fail_on_unmatched_files: true

0 commit comments

Comments
 (0)