Skip to content

Commit 40d2f1d

Browse files
committed
Make cr-sqlite work on stable rust
1 parent a524fc0 commit 40d2f1d

File tree

18 files changed

+98
-88
lines changed

18 files changed

+98
-88
lines changed

.github/workflows/c-tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
if: runner.os == 'Windows'
2626
run: |
2727
rm core/rs/integration_check/rust-toolchain.toml
28-
rustup component add rust-src --toolchain nightly-2023-10-05-x86_64-pc-windows-gnu
29-
rustup default nightly-2023-10-05-x86_64-pc-windows-gnu
28+
rustup component add rust-src --toolchain 1.93.0-x86_64-pc-windows-gnu
29+
rustup default 1.93.0-x86_64-pc-windows-gnu
3030
3131
- name: Test
3232
run: |

.github/workflows/publish.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ jobs:
6969

7070
- name: Rust Nightly
7171
run: |
72-
rustup toolchain install nightly-2023-10-05
73-
rustup target add aarch64-apple-darwin --toolchain nightly-2023-10-05
72+
rustup toolchain install 1.93.0
73+
rustup target add aarch64-apple-darwin --toolchain 1.93.0
7474
7575
- name: Build MacOS Arm dylib
7676
run: |
@@ -121,9 +121,9 @@ jobs:
121121

122122
- name: Rust Nightly
123123
run: |
124-
rustup toolchain install nightly-2023-10-05
125-
rustup target add aarch64-unknown-linux-gnu --toolchain nightly-2023-10-05
126-
rustup component add rust-src --toolchain nightly-2023-10-05-x86_64-unknown-linux-gnu
124+
rustup toolchain install 1.93.0
125+
rustup target add aarch64-unknown-linux-gnu --toolchain 1.93.0
126+
rustup component add rust-src --toolchain 1.93.0-x86_64-unknown-linux-gnu
127127
128128
- name: Build
129129
run: |
@@ -157,9 +157,9 @@ jobs:
157157

158158
- name: Rust Nightly
159159
run: |
160-
rustup toolchain install nightly-2023-10-05
161-
rustup target add x86_64-pc-windows-gnu --toolchain nightly-2023-10-05
162-
rustup component add rust-src --toolchain nightly-2023-10-05-x86_64-unknown-linux-gnu
160+
rustup toolchain install 1.93.0
161+
rustup target add x86_64-pc-windows-gnu --toolchain 1.93.0
162+
rustup component add rust-src --toolchain 1.93.0-x86_64-unknown-linux-gnu
163163
164164
- name: mingw-w64
165165
run: |
@@ -197,9 +197,9 @@ jobs:
197197

198198
- name: Rust Nightly
199199
run: |
200-
rustup toolchain install nightly-2023-10-05
201-
rustup target add i686-pc-windows-gnu --toolchain nightly-2023-10-05
202-
rustup component add rust-src --toolchain nightly-2023-10-05-x86_64-unknown-linux-gnu
200+
rustup toolchain install 1.93.0
201+
rustup target add i686-pc-windows-gnu --toolchain 1.93.0
202+
rustup component add rust-src --toolchain 1.93.0-x86_64-unknown-linux-gnu
203203
204204
- name: mingw-w64
205205
run: |
@@ -237,9 +237,9 @@ jobs:
237237

238238
- name: Rust Nightly
239239
run: |
240-
rustup toolchain install nightly-2023-10-05
241-
rustup target add aarch64-linux-android --toolchain nightly-2023-10-05
242-
rustup component add rust-src --toolchain nightly-2023-10-05-x86_64-unknown-linux-gnu
240+
rustup toolchain install 1.93.0
241+
rustup target add aarch64-linux-android --toolchain 1.93.0
242+
rustup component add rust-src --toolchain 1.93.0-x86_64-unknown-linux-gnu
243243
244244
- uses: nttld/setup-ndk@v1
245245
id: setup-ndk

.github/workflows/rs-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
if: runner.os == 'Windows'
2626
run: |
2727
find . -name rust-toolchain.toml -exec echo rm {} \;
28-
rustup component add rust-src --toolchain nightly-2023-10-05-x86_64-pc-windows-gnu
29-
rustup default nightly-2023-10-05-x86_64-pc-windows-gnu
28+
rustup component add rust-src --toolchain 1.93.0-x86_64-pc-windows-gnu
29+
rustup default 1.93.0-x86_64-pc-windows-gnu
3030
3131
- name: Test Fractindex
3232
run: |

.github/workflows/rs-valgrind.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@ jobs:
2929
- name: Test Fractindex
3030
run: |
3131
cd core/rs/fractindex-core
32-
cargo valgrind test --features=loadable_extension
32+
# Uncomment if u need to generate valgrind suppressions
33+
# cargo test --features=loadable_extension
34+
# find target/debug/deps/ -type f -executable -name "crsql*" -exec valgrind --leak-check=full --gen-suppressions=all {} \;
35+
VALGRINDFLAGS="--suppressions=$GITHUB_WORKSPACE/core/valgrind.supp" cargo valgrind test --features=loadable_extension
3336
3437
- name: Test Core
3538
run: |
3639
cd core/rs/core
37-
cargo valgrind test --features=loadable_extension
40+
# Uncomment if u need to generate valgrind suppressions
41+
# cargo test --features=loadable_extension
42+
# find target/debug/deps/ -type f -executable -name "crsql*" -exec valgrind --leak-check=full --gen-suppressions=all {} \;
43+
VALGRINDFLAGS="--suppressions=$GITHUB_WORKSPACE/core/valgrind.supp" cargo valgrind test --features=loadable_extension

core/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ $(TARGET_DBG_LOADABLE): $(dbg_prefix) $(ext_files) $(sqlite3.c) $(rs_lib_dbg_loa
211211

212212
# Build a SQLite CLI that pre-loads cr-sqlite.
213213
# Useful for debugging.
214+
# With DSQLITE_THREADSAFE!=0, The tests will crash on windows.
214215
$(TARGET_SQLITE3): $(prefix) $(TARGET_SQLITE3_EXTRA_C) $(rs_lib_dbg_static_cpy) $(shell.c) $(ext_files)
215216
$(CC) -g \
216217
-DSQLITE_THREADSAFE=0 \
@@ -238,6 +239,7 @@ $(TARGET_STATIC): $(prefix) $(ext_files) $(sqlite3.c) $(rs_lib_static_cpy)
238239
# Build a normal SQLite CLI that does not include cr-sqlite.
239240
# cr-sqlite can be laoded in via the `.load` pragma.
240241
# Useful for debugging.
242+
# With DSQLITE_THREADSAFE!=0, The tests will crash on windows.
241243
$(TARGET_SQLITE3_VANILLA): $(prefix) $(shell.c) $(sqlite3.c)
242244
$(CC) -g \
243245
$(DEFINE_SQLITE_PATH) \
@@ -250,6 +252,7 @@ $(TARGET_SQLITE3_EXTRA_C): $(prefix) $(sqlite3.c) src/core_init.c
250252
cat $(sqlite3.c) src/core_init.c > $@
251253

252254
# run tests
255+
# With DSQLITE_THREADSAFE!=0, The tests will crash on windows.
253256
$(TARGET_TEST): $(prefix) $(TARGET_SQLITE3_EXTRA_C) src/tests.c src/*.test.c $(ext_files) $(rs_lib_dbg_static_cpy)
254257
$(CC) -g -Wall \
255258
-DSQLITE_THREADSAFE=0 \
@@ -260,6 +263,7 @@ $(TARGET_TEST): $(prefix) $(TARGET_SQLITE3_EXTRA_C) src/tests.c src/*.test.c $(e
260263
$(TARGET_SQLITE3_EXTRA_C) src/tests.c src/*.test.c $(ext_files) $(rs_lib_dbg_static_cpy) \
261264
$(LDLIBS) -o $@
262265

266+
# With DSQLITE_THREADSAFE!=0, The tests will crash on windows.
263267
$(TARGET_TEST_ASAN): $(prefix) $(TARGET_SQLITE3_EXTRA_C) src/tests.c src/*.test.c $(ext_files) $(rs_lib_dbg_static_cpy)
264268
$(CC) -fsanitize=address -g -fno-omit-frame-pointer -Wall \
265269
-DSQLITE_THREADSAFE=0 \
@@ -270,6 +274,7 @@ $(TARGET_TEST_ASAN): $(prefix) $(TARGET_SQLITE3_EXTRA_C) src/tests.c src/*.test.
270274
$(TARGET_SQLITE3_EXTRA_C) src/tests.c src/*.test.c $(ext_files) $(rs_lib_dbg_static_cpy) \
271275
$(LDLIBS) -o $@
272276

277+
# With DSQLITE_THREADSAFE!=0, The tests will crash on windows.
273278
$(TARGET_FUZZ): $(prefix) $(TARGET_SQLITE3_EXTRA_C) src/fuzzer.cc $(ext_files)
274279
clang -fsanitize=fuzzer \
275280
-DSQLITE_THREADSAFE=0 \

core/rs/bundle/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ crate-type = ["rlib"]
1616
crsql_fractindex_core = {path="../fractindex-core"}
1717
crsql_core = { path="../core" }
1818
sqlite_nostd = { path="../sqlite-rs-embedded/sqlite_nostd" }
19+
stable_trap = { path="../sqlite-rs-embedded/stable_trap" }
1920
libc-print = "*"
2021

2122
[profile.dev]

core/rs/bundle/rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-10-05"
2+
channel = "1.93.0"
33
components = [ "rust-src", "rustfmt", "clippy" ]

core/rs/bundle/src/lib.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#![no_std]
2-
#![feature(core_intrinsics)]
3-
#![feature(lang_items)]
42

53
extern crate alloc;
64

@@ -26,25 +24,29 @@ static ALLOCATOR: SQLite3Allocator = SQLite3Allocator {};
2624
#[cfg(not(feature = "test"))]
2725
#[panic_handler]
2826
fn panic(_info: &PanicInfo) -> ! {
29-
core::intrinsics::abort()
27+
stable_trap::abort()
3028
}
3129

3230
// Print panic info for tests
3331
#[cfg(feature = "test")]
3432
#[panic_handler]
3533
fn panic(info: &PanicInfo) -> ! {
3634
println!("PANIC!: {}", info);
37-
core::intrinsics::abort();
35+
stable_trap::abort()
3836
}
3937

38+
// Otherwise we would need to use nightly features
4039
#[cfg(not(target_family = "wasm"))]
41-
#[lang = "eh_personality"]
42-
extern "C" fn eh_personality() {}
40+
#[no_mangle]
41+
extern "C" fn rust_eh_personality() {}
42+
#[cfg(target_arch = "arm")]
43+
#[no_mangle]
44+
extern "C" fn _rust_eh_personality() {}
4345

4446
#[cfg(target_family = "wasm")]
4547
#[no_mangle]
4648
pub fn __rust_alloc_error_handler(_: Layout) -> ! {
47-
core::intrinsics::abort()
49+
stable_trap::abort()
4850
}
4951

5052
#[no_mangle]

core/rs/bundle_static/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ crate-type = ["staticlib"]
1313
[dependencies]
1414
crsql_bundle = {path="../bundle"}
1515

16+
1617
[profile.dev]
1718
panic = "abort"
1819

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-10-05"
2+
channel = "1.93.0"
33

0 commit comments

Comments
 (0)