mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
Build using wasi-sdk.
This commit is contained in:
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
@@ -55,7 +55,7 @@ jobs:
|
||||
if: matrix.os == 'macos-latest'
|
||||
|
||||
- name: Coverage report
|
||||
uses: ncruces/go-coverage-report@main
|
||||
uses: ncruces/go-coverage-report@v0
|
||||
with:
|
||||
chart: 'true'
|
||||
amend: 'true'
|
||||
|
||||
@@ -19,4 +19,5 @@ The following optional features are compiled in:
|
||||
|
||||
See the [configuration options](../sqlite3/sqlite_cfg.h).
|
||||
|
||||
Built using [`zig`](https://ziglang.org/) version 0.10.1.
|
||||
Built using [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk),
|
||||
and [`binaryen`](https://github.com/WebAssembly/binaryen).
|
||||
@@ -1,18 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
set -euo pipefail
|
||||
|
||||
cd -P -- "$(dirname -- "$0")"
|
||||
|
||||
zig cc --target=wasm32-wasi -flto -g0 -O2 \
|
||||
-o sqlite3.wasm ../sqlite3/main.c \
|
||||
-I../sqlite3/ \
|
||||
ROOT=../
|
||||
BINARYEN="$ROOT/tools/binaryen-version_112/bin"
|
||||
WASI_SDK="$ROOT/tools/wasi-sdk-20.0/bin"
|
||||
|
||||
"$WASI_SDK/clang" --target=wasm32-wasi -flto -g0 -O2 \
|
||||
-o sqlite3.wasm "$ROOT/sqlite3/main.c" \
|
||||
-I"$ROOT/sqlite3" \
|
||||
-mexec-model=reactor \
|
||||
-mmutable-globals \
|
||||
-mbulk-memory -mreference-types \
|
||||
-mnontrapping-fptoint -msign-ext \
|
||||
-mexec-model=reactor \
|
||||
-Wl,--initial-memory=327680 \
|
||||
-Wl,--stack-first \
|
||||
-Wl,--import-undefined \
|
||||
-D_HAVE_SQLITE_CONFIG_H \
|
||||
$(awk '{print "-Wl,--export="$0}' exports.txt)
|
||||
|
||||
trap 'rm -f sqlite3.tmp' EXIT
|
||||
wasm-ctor-eval -g -c _initialize sqlite3.wasm -o sqlite3.tmp
|
||||
wasm-opt -g -O2 sqlite3.tmp -o sqlite3.wasm
|
||||
"$BINARYEN/wasm-ctor-eval" -g -c _initialize sqlite3.wasm -o sqlite3.tmp
|
||||
"$BINARYEN/wasm-opt" -g -O2 sqlite3.tmp -o sqlite3.wasm \
|
||||
--enable-multivalue --enable-mutable-globals \
|
||||
--enable-bulk-memory --enable-reference-types \
|
||||
--enable-nontrapping-float-to-int --enable-sign-ext
|
||||
Binary file not shown.
20
internal/vfs/tests/mptest/testdata/build.sh
vendored
20
internal/vfs/tests/mptest/testdata/build.sh
vendored
@@ -1,17 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
set -euo pipefail
|
||||
|
||||
cd -P -- "$(dirname -- "$0")"
|
||||
|
||||
zig cc --target=wasm32-wasi -flto -g0 -O2 \
|
||||
ROOT=../../../../../
|
||||
BINARYEN="$ROOT/tools/binaryen-version_112/bin"
|
||||
WASI_SDK="$ROOT/tools/wasi-sdk-20.0/bin"
|
||||
|
||||
"$WASI_SDK/clang" --target=wasm32-wasi -flto -g0 -O2 \
|
||||
-o mptest.wasm main.c \
|
||||
-I../../../../../sqlite3/ \
|
||||
-I"$ROOT/sqlite3" \
|
||||
-mmutable-globals \
|
||||
-mbulk-memory -mreference-types \
|
||||
-mnontrapping-fptoint -msign-ext \
|
||||
-Wl,--stack-first \
|
||||
-Wl,--import-undefined \
|
||||
-D_HAVE_SQLITE_CONFIG_H \
|
||||
-DSQLITE_DEFAULT_SYNCHRONOUS=0 \
|
||||
-DSQLITE_DEFAULT_LOCKING_MODE=0 \
|
||||
-DHAVE_USLEEP -DSQLITE_NO_SYNC \
|
||||
-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
|
||||
-D_WASI_EMULATED_GETPID -lwasi-emulated-getpid
|
||||
-D_WASI_EMULATED_GETPID -lwasi-emulated-getpid
|
||||
|
||||
"$BINARYEN/wasm-opt" -g -O2 mptest.wasm -o mptest.tmp \
|
||||
--enable-multivalue --enable-mutable-globals \
|
||||
--enable-bulk-memory --enable-reference-types \
|
||||
--enable-nontrapping-float-to-int --enable-sign-ext
|
||||
mv mptest.tmp mptest.wasm
|
||||
1
internal/vfs/tests/mptest/testdata/main.c
vendored
1
internal/vfs/tests/mptest/testdata/main.c
vendored
@@ -4,7 +4,6 @@
|
||||
#include "sqlite3.c"
|
||||
//
|
||||
#include "os.c"
|
||||
#include "qsort.c"
|
||||
|
||||
sqlite3_destructor_type malloc_destructor = &free;
|
||||
size_t sqlite3_interrupt_offset = offsetof(sqlite3, u1.isInterrupted);
|
||||
|
||||
4
internal/vfs/tests/mptest/testdata/mptest.wasm
vendored
Executable file → Normal file
4
internal/vfs/tests/mptest/testdata/mptest.wasm
vendored
Executable file → Normal file
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:21efc4fb06ac7a3316634f438c51b66c93b1e75b70a850eb3acd6ff8c1c64b3d
|
||||
size 1630624
|
||||
oid sha256:37ceeed293b9f09e9770b40eda3f625447f5a3a74208709886d4411d12f93414
|
||||
size 1486113
|
||||
|
||||
22
internal/vfs/tests/speedtest1/testdata/build.sh
vendored
22
internal/vfs/tests/speedtest1/testdata/build.sh
vendored
@@ -1,12 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
set -euo pipefail
|
||||
|
||||
cd -P -- "$(dirname -- "$0")"
|
||||
|
||||
zig cc --target=wasm32-wasi -flto -g0 -O2 \
|
||||
-o speedtest1.wasm main.c \
|
||||
-I../../../../../sqlite3/ \
|
||||
ROOT=../../../../../
|
||||
BINARYEN="$ROOT/tools/binaryen-version_112/bin"
|
||||
WASI_SDK="$ROOT/tools/wasi-sdk-20.0/bin"
|
||||
|
||||
"$WASI_SDK/clang" --target=wasm32-wasi -flto -g0 -O2 \
|
||||
-o speedtest1.wasm main.c \
|
||||
-I"$ROOT/sqlite3" \
|
||||
-mmutable-globals \
|
||||
-mbulk-memory -mreference-types \
|
||||
-mnontrapping-fptoint -msign-ext \
|
||||
-D_HAVE_SQLITE_CONFIG_H
|
||||
-Wl,--stack-first \
|
||||
-Wl,--import-undefined \
|
||||
-D_HAVE_SQLITE_CONFIG_H
|
||||
|
||||
"$BINARYEN/wasm-opt" -g -O2 speedtest1.wasm -o speedtest1.tmp \
|
||||
--enable-multivalue --enable-mutable-globals \
|
||||
--enable-bulk-memory --enable-reference-types \
|
||||
--enable-nontrapping-float-to-int --enable-sign-ext
|
||||
mv speedtest1.tmp speedtest1.wasm
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "sqlite3.c"
|
||||
//
|
||||
#include "os.c"
|
||||
#include "qsort.c"
|
||||
|
||||
sqlite3_destructor_type malloc_destructor = &free;
|
||||
size_t sqlite3_interrupt_offset = offsetof(sqlite3, u1.isInterrupted);
|
||||
|
||||
4
internal/vfs/tests/speedtest1/testdata/speedtest1.wasm
vendored
Executable file → Normal file
4
internal/vfs/tests/speedtest1/testdata/speedtest1.wasm
vendored
Executable file → Normal file
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b3ce4ed200234ac50126a5562fd95a84843898e73e0724687153f9ae458b8a3b
|
||||
size 1675943
|
||||
oid sha256:8167119c344a68217b0301e2e8c288f2e75611d296d7822f841b65911da0275c
|
||||
size 1520569
|
||||
|
||||
@@ -49,14 +49,18 @@ func TestConn_new(t *testing.T) {
|
||||
}
|
||||
defer m.close()
|
||||
|
||||
testOOM := func(size uint64) {
|
||||
t.Run("MaxUint32", func(t *testing.T) {
|
||||
defer func() { _ = recover() }()
|
||||
m.new(size)
|
||||
m.new(math.MaxUint32)
|
||||
t.Error("want panic")
|
||||
}
|
||||
})
|
||||
|
||||
testOOM(math.MaxUint32)
|
||||
testOOM(_MAX_ALLOCATION_SIZE)
|
||||
t.Run("_MAX_ALLOCATION_SIZE", func(t *testing.T) {
|
||||
defer func() { _ = recover() }()
|
||||
m.new(_MAX_ALLOCATION_SIZE)
|
||||
m.new(_MAX_ALLOCATION_SIZE)
|
||||
t.Error("want panic")
|
||||
})
|
||||
}
|
||||
|
||||
func TestConn_newArena(t *testing.T) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
set -euo pipefail
|
||||
|
||||
cd -P -- "$(dirname -- "$0")"
|
||||
|
||||
@@ -17,7 +17,7 @@ curl -#OL "https://github.com/sqlite/sqlite/raw/version-3.41.2/ext/misc/regexp.c
|
||||
curl -#OL "https://github.com/sqlite/sqlite/raw/version-3.41.2/ext/misc/series.c"
|
||||
cd ~-
|
||||
|
||||
cd ../tests/mptest/testdata/
|
||||
cd ../internal/vfs/tests/mptest/testdata/
|
||||
curl -#OL "https://github.com/sqlite/sqlite/raw/version-3.41.2/mptest/mptest.c"
|
||||
curl -#OL "https://github.com/sqlite/sqlite/raw/version-3.41.2/mptest/config01.test"
|
||||
curl -#OL "https://github.com/sqlite/sqlite/raw/version-3.41.2/mptest/config02.test"
|
||||
@@ -26,6 +26,6 @@ curl -#OL "https://github.com/sqlite/sqlite/raw/version-3.41.2/mptest/crash02.su
|
||||
curl -#OL "https://github.com/sqlite/sqlite/raw/version-3.41.2/mptest/multiwrite01.test"
|
||||
cd ~-
|
||||
|
||||
cd ../tests/speedtest1/testdata/
|
||||
cd ../internal/vfs/tests/speedtest1/testdata/
|
||||
curl -#OL "https://github.com/sqlite/sqlite/raw/version-3.41.2/test/speedtest1.c"
|
||||
cd ~-
|
||||
@@ -1,4 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd -P -- "$(dirname -- "$0")"
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "sqlite3.c"
|
||||
//
|
||||
#include "os.c"
|
||||
#include "qsort.c"
|
||||
//
|
||||
#include "ext/base64.c"
|
||||
#include "ext/decimal.c"
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#include <stddef.h>
|
||||
|
||||
void qsort_r(void *, size_t, size_t,
|
||||
int (*)(const void *, const void *, void *), void *);
|
||||
|
||||
typedef int (*cmpfun)(const void *, const void *);
|
||||
|
||||
static int wrapper_cmp(const void *v1, const void *v2, void *cmp) {
|
||||
return ((cmpfun)cmp)(v1, v2);
|
||||
}
|
||||
|
||||
void qsort(void *base, size_t nel, size_t width, cmpfun cmp) {
|
||||
qsort_r(base, nel, width, wrapper_cmp, cmp);
|
||||
}
|
||||
Reference in New Issue
Block a user