Skip to content

Commit acb3799

Browse files
committed
Properly fix and test _Unwind_Resume issues.
1 parent 643d134 commit acb3799

File tree

14 files changed

+79
-19
lines changed

14 files changed

+79
-19
lines changed

.cargo/config

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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.
5+
6+
[target.x86_64-unknown-linux-gnu]
7+
rustflags = [
8+
"-C", "link-arg=-lgcc_eh",
9+
]
10+
11+
[target.i686-linux-unknown-linux-gnu]
12+
rustflags = [
13+
"-C", "link-arg=-lgcc_eh",
14+
]
15+
16+
[target.aarch64-linux-unknown-linux-gnu]
17+
rustflags = [
18+
"-C", "link-arg=-lgcc_eh",
19+
]

.github/workflows/tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,5 @@ jobs:
3333
./target/release/powersync_sqlite ":memory:" "select powersync_rs_version()"
3434
3535
- name: Check loadable extension
36-
# This should actually be using a plain sqlite build, but this does seem to expose typical build issues at least.
3736
run: |
38-
./target/release/powersync_sqlite ":memory:" ".load ./target/release/libpowersync" "select powersync_rs_version()"
37+
./target/release/sqlite3 ":memory:" ".load ./target/release/libpowersync" "select powersync_rs_version()"

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ members = [
55
]
66
resolver = "2"
77
# We cannot build shell and lodable and the same time
8-
default-members = ["crates/shell"]
8+
default-members = ["crates/shell", "crates/sqlite"]
99

1010
[profile.dev]
1111
panic = "abort"

crates/shell/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ fn main() {
33
let mut cfg = cc::Build::new();
44

55
// Compile the SQLite source
6-
cfg.file("./sqlite/sqlite3.c");
7-
cfg.file("./sqlite/shell.c");
8-
cfg.include("./sqlite");
6+
cfg.file("../sqlite/sqlite/sqlite3.c");
7+
cfg.file("../sqlite/sqlite/shell.c");
8+
cfg.include("../sqlite/sqlite");
99

1010
// General SQLite options
1111
cfg.define("SQLITE_THREADSAFE", Some("0"));

crates/shell/src/main.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,6 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {
2828
#[lang = "eh_personality"]
2929
extern "C" fn eh_personality() {}
3030

31-
#[cfg(target_family = "wasm")]
32-
#[no_mangle]
33-
pub fn __rust_alloc_error_handler(_: core::alloc::Layout) -> ! {
34-
core::intrinsics::abort()
35-
}
36-
37-
38-
// Not used, but must be defined in some cases. Most notably when using native sqlite3 and loading
39-
// the extension.
40-
#[allow(non_upper_case_globals)]
41-
#[no_mangle]
42-
pub static mut _Unwind_Resume: *mut core::ffi::c_void = core::ptr::null_mut();
43-
4431

4532
#[no_mangle]
4633
pub extern "C" fn core_init(_dummy: *mut c_char) -> c_int {

crates/sqlite/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "sqlite3"
3+
edition.workspace = true
4+
version.workspace = true
5+
homepage.workspace = true
6+
repository.workspace = true
7+
license.workspace = true
8+
authors.workspace = true
9+
keywords.workspace = true
10+
11+
[dependencies]
12+
13+
[features]
14+
15+
[build-dependencies]
16+
cc = "1.0.46"

crates/sqlite/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# sqlite
2+
3+
This builds a plain sqlite3 shell.
4+
5+
We could build this with plain gcc/clang, or download a pre-built binary, but it's simple enough with Rust tooling.

crates/sqlite/build.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
fn main() {
3+
let mut cfg = cc::Build::new();
4+
5+
// Compile the SQLite source
6+
cfg.file("./sqlite/sqlite3.c");
7+
cfg.file("./sqlite/shell.c");
8+
cfg.include("./sqlite");
9+
10+
// General SQLite options
11+
cfg.define("SQLITE_THREADSAFE", Some("0"));
12+
cfg.define("SQLITE_ENABLE_BYTECODE_VTAB", Some("1"));
13+
14+
// Compile with readline support (also requires -lreadline / cargo:rustc-link-lib=readline below)
15+
cfg.define("HAVE_READLINE", Some("1"));
16+
17+
// Silence warnings generated for SQLite
18+
cfg.flag("-Wno-implicit-fallthrough");
19+
cfg.flag("-Wno-unused-parameter");
20+
cfg.flag("-Wno-null-pointer-subtraction");
21+
22+
cfg.compile("sqlite");
23+
24+
println!("cargo:rustc-link-lib=readline");
25+
}
File renamed without changes.

0 commit comments

Comments
 (0)