Skip to content

Commit

Permalink
Reproducible builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Nov 28, 2023
1 parent fcd6cc9 commit 8a18243
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ echo darwin-flock ; GOOS=darwin GOARCH=amd64 go build -tags sqlite3_flock .
echo darwin-nosys ; GOOS=darwin GOARCH=amd64 go build -tags sqlite3_nosys .
echo linux-nosys ; GOOS=linux GOARCH=amd64 go build -tags sqlite3_nosys .
echo windows-nosys ; GOOS=windows GOARCH=amd64 go build -tags sqlite3_nosys .
echo freebsd-nosys ; GOOS=freebsd GOARCH=amd64 go build -tags sqlite3_nosys .
echo freebsd-nosys ; GOOS=freebsd GOARCH=amd64 go build -tags sqlite3_nosys .
23 changes: 23 additions & 0 deletions .github/workflows/repro.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ "$OSTYPE" == "linux"* ]]; then
WASI_SDK="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz"
BINARYEN="https://github.com/WebAssembly/binaryen/releases/download/version_116/binaryen-version_116-x86_64-linux.tar.gz"
elif [[ "$OSTYPE" == "darwin"* ]]; then
WASI_SDK="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz"
BINARYEN="https://github.com/WebAssembly/binaryen/releases/download/version_116/binaryen-version_116-x86_64-macos.tar.gz"
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
WASI_SDK="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0.m-mingw.tar.gz"
BINARYEN="https://github.com/WebAssembly/binaryen/releases/download/version_116/binaryen-version_116-x86_64-windows.tar.gz"
fi

# Download tools
mkdir -p tools
[ -d "tools/wasi-sdk"* ] || curl -#L "$WASI_SDK" | tar xzC tools &
[ -d "tools/binaryen-version"* ] || curl -#L "$BINARYEN" | tar xzC tools &
wait

sqlite3/download.sh # Download SQLite
embed/build.sh # Build WASM
git diff --exit-code # Check diffs
21 changes: 21 additions & 0 deletions .github/workflows/repro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Reproducible build

on:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
lfs: 'true'

- name: Set up
uses: actions/setup-go@v4
with:
go-version: stable

- name: Build
run: .github/workflows/repro.sh
2 changes: 1 addition & 1 deletion embed/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ WASI_SDK="$ROOT/tools/wasi-sdk-20.0/bin"

trap 'rm -f sqlite3.tmp' EXIT
"$BINARYEN/wasm-ctor-eval" -g -c _initialize sqlite3.wasm -o sqlite3.tmp
"$BINARYEN/wasm-opt" -g --strip -c -O3 \
"$BINARYEN/wasm-opt" -g --strip --strip-producers -c -O3 \
sqlite3.tmp -o sqlite3.wasm \
--enable-simd --enable-mutable-globals --enable-multivalue \
--enable-bulk-memory --enable-reference-types \
Expand Down
Binary file modified embed/sqlite3.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion sqlite3/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ unzip -d . sqlite-amalgamation-*.zip
mv sqlite-amalgamation-*/sqlite3* .
rm -rf sqlite-amalgamation-*

cat *.patch | patch --posix
cat *.patch | patch --no-backup-if-mismatch

mkdir -p ext/
cd ext/
Expand Down
2 changes: 1 addition & 1 deletion vfs/tests/mptest/testdata/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ WASI_SDK="$ROOT/tools/wasi-sdk-20.0/bin"
-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
-D_WASI_EMULATED_GETPID -lwasi-emulated-getpid

"$BINARYEN/wasm-opt" -g --strip -c -O3 \
"$BINARYEN/wasm-opt" -g --strip --strip-producers -c -O3 \
mptest.wasm -o mptest.tmp \
--enable-simd --enable-mutable-globals --enable-multivalue \
--enable-bulk-memory --enable-reference-types \
Expand Down
4 changes: 2 additions & 2 deletions vfs/tests/mptest/testdata/mptest.wasm.bz2
Git LFS file not shown
2 changes: 1 addition & 1 deletion vfs/tests/speedtest1/testdata/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WASI_SDK="$ROOT/tools/wasi-sdk-20.0/bin"
-Wl,--import-undefined \
-D_HAVE_SQLITE_CONFIG_H

"$BINARYEN/wasm-opt" -g --strip -c -O3 \
"$BINARYEN/wasm-opt" -g --strip --strip-producers -c -O3 \
speedtest1.wasm -o speedtest1.tmp \
--enable-simd --enable-mutable-globals --enable-multivalue \
--enable-bulk-memory --enable-reference-types \
Expand Down
4 changes: 2 additions & 2 deletions vfs/tests/speedtest1/testdata/speedtest1.wasm.bz2
Git LFS file not shown

0 comments on commit 8a18243

Please sign in to comment.