Skip to content

Commit d1465a8

Browse files
committed
Use build-std.
1 parent 46f957e commit d1465a8

File tree

6 files changed

+46
-33
lines changed

6 files changed

+46
-33
lines changed

.cargo/config.toml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
1-
# On Linux, if we don't link to gcc_eh, we get can get this error when loading the loadable extension:
2-
# undefined symbol: _Unwind_Resume
3-
# This adds around 29KB to the loadable extension.
4-
# It may also be an option to just define _Unwind_Resume, but it causes crashes on errors on e.g. iOS, so rather avoid it.
51

6-
[target.x86_64-unknown-linux-gnu]
7-
rustflags = [
8-
"-C", "link-arg=-lgcc_eh",
9-
]
2+
# Previously we added this to rustflags for all linux builds:
3+
# "-C", "link-arg=-lgcc_eh"
4+
# It was to fix this error when loading the loadable extension:
5+
# undefined symbol: _Unwind_Resume
6+
# Now, we instead build using:
7+
# -Z build-std=panic_abort,core,alloc
8+
# This fixes the same issue. We still keep -lgcc_eh,
9+
# to support manual builds without -Z build-std.
10+
11+
# Without -Z build-std, with -lgcc_eh:
12+
# 241KB, loading works
13+
# Without -Z build-std, without -lgcc_eh:
14+
# 207KB, undefined symbol: _Unwind_Resume
15+
# With -Z build-std, without -lgcc_eh:
16+
# 173K, loading works
17+
# With -Z build-std, with -lgcc_eh:
18+
# 173K, loading works
19+
# Conclusion: -lgcc_eh has no effect when using -Z build-std.
1020

11-
[target.i686-linux-unknown-linux-gnu]
21+
[target.x86_64-unknown-linux-gnu]
1222
rustflags = [
1323
"-C", "link-arg=-lgcc_eh",
1424
]
1525

16-
[target.aarch64-linux-unknown-linux-gnu]
26+
[target.i686-unknown-linux-gnu]
1727
rustflags = [
1828
"-C", "link-arg=-lgcc_eh",
1929
]
2030

2131
[target.aarch64-unknown-linux-gnu]
32+
linker = "aarch64-linux-gnu-gcc"
2233
rustflags = [
2334
"-C", "link-arg=-lgcc_eh",
2435
]

.github/workflows/linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
components: rust-src
1919

2020
- name: Build binaries
21-
run: bash tool/build_linux.sh x64
21+
run: ./tool/build_linux.sh x64
2222

2323
- name: Upload binary
2424
if: github.event_name == 'workflow_dispatch'
@@ -43,7 +43,7 @@ jobs:
4343
components: rust-src
4444

4545
- name: Build binaries
46-
run: bash tool/build_linux.sh aarch64
46+
run: ./tool/build_linux.sh aarch64
4747

4848
- name: Upload binary
4949
if: github.event_name == 'workflow_dispatch'

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020
- name: Ubuntu setup
2121
if: matrix.os == 'ubuntu-24.04'
2222
run: |
23-
sudo apt install libreadline-dev
23+
sudo apt install libreadline-dev gcc-aarch64-linux-gnu
2424
2525
- name: Build
2626
run: |
2727
# Need a debug build for the dart tests
28-
cargo build -p powersync_loadable
28+
cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target x86_64-unknown-linux-gnu
2929
3030
cargo build -p powersync_loadable --release
3131
cargo build -p powersync_core --release --features static

tool/build_linux.sh

100644100755
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
#!/bin/sh
2+
set -e
3+
14
if [ "$1" = "x64" ]; then
2-
rustup target add target x86_64-unknown-linux-gnu
3-
cargo build -p powersync_loadable --release
4-
mv "target/release/libpowersync.so" "libpowersync_x64.so"
5+
cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target x86_64-unknown-linux-gnu
6+
mv "target/x86_64-unknown-linux-gnu/release/libpowersync.so" "libpowersync_x64.so"
57
else
6-
rustup target add aarch64-unknown-linux-gnu
7-
cargo build -p powersync_loadable --release
8-
mv "target/release/libpowersync.so" "libpowersync_aarch64.so"
8+
cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target aarch64-unknown-linux-gnu
9+
mv "target/aarch64-unknown-linux-gnu/release/libpowersync.so" "libpowersync_aarch64.so"
910
fi

tool/build_macos.sh

100644100755
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
#!/bin/sh
2+
set -e
3+
14
if [ "$1" = "x64" ]; then
2-
#Note: x86_64-apple-darwin has not been tested.
3-
rustup target add target x86_64-apple-darwin
4-
cargo build -p powersync_loadable --release
5-
mv "target/release/libpowersync.dylib" "libpowersync_x64.dylib"
5+
cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target x86_64-apple-darwin
6+
mv "target/x86_64-apple-darwin/release/libpowersync.dylib" "libpowersync_x64.dylib"
67
else
7-
rustup target add aarch64-apple-darwin
8-
cargo build -p powersync_loadable --release
9-
mv "target/release/libpowersync.dylib" "libpowersync_aarch64.dylib"
8+
cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target aarch64-apple-darwin
9+
mv "target/aarch64-apple-darwin/release/libpowersync.dylib" "libpowersync_aarch64.dylib"
1010
fi

tool/build_windows.sh

100644100755
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#!/bin/sh
2+
set -e
3+
14
if [ "$1" = "x64" ]; then
2-
rustup target add x86_64-pc-windows-msvc
3-
cargo build -p powersync_loadable --release
4-
mv "target/release/powersync.dll" "powersync_x64.dll"
5+
cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target x86_64-pc-windows-msvc
6+
mv "target/x86_64-pc-windows-msvc/release/powersync.dll" "powersync_x64.dll"
57
else
68
#Note: aarch64-pc-windows-msvc has not been tested.
7-
rustup target add aarch64-pc-windows-msvc
8-
cargo build -p powersync_loadable --release
9-
mv "target/release/powersync.dll" "powersync_aarch64.dll"
9+
cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target aarch64-pc-windows-msvc
10+
mv "target/aarch64-pc-windows-msvc/release/powersync.dll" "powersync_aarch64.dll"
1011
fi

0 commit comments

Comments
 (0)