Skip to content

Commit b109f16

Browse files
committed
Remove feature gates
1 parent 4f4354f commit b109f16

File tree

13 files changed

+59
-39
lines changed

13 files changed

+59
-39
lines changed

.cargo/config.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# It was to fix this error when loading the loadable extension:
44
# undefined symbol: _Unwind_Resume
55
# Now, we instead build using:
6-
# -Z build-std=panic_abort,core,alloc
6+
# -Z build-std=panic_immediate_abort,core,alloc
77
# This fixes the same issue. We still keep -lgcc_eh,
88
# to support manual builds without -Z build-std.
99

@@ -17,6 +17,13 @@
1717
# 173K, loading works
1818
# Conclusion: -lgcc_eh has no effect when using -Z build-std.
1919

20+
[profile.release]
21+
panic = "immediate-abort"
22+
23+
[unstable]
24+
panic-immediate-abort = true
25+
build-std = ["core", "alloc", "panic_abort"]
26+
2027
[target.'cfg(target_os = "linux")']
2128
rustflags = [
2229
"-C", "link-arg=-lgcc_eh",

crates/core/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#![no_std]
2-
#![feature(btree_set_entry)]
3-
#![feature(vec_into_raw_parts)]
4-
52
extern crate alloc;
63

74
use core::ffi::{c_char, c_int};

crates/core/src/state.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ impl DatabaseState {
6363

6464
pub fn track_update(&self, tbl: &str) {
6565
let mut set = self.pending_updates.borrow_mut();
66-
set.get_or_insert_with(tbl, str::to_string);
66+
// TODO: Use set.get_or_insert_with(tbl, str::to_string) after btree_set_entry is stable,
67+
// https://github.com/rust-lang/rust/issues/133549
68+
if !set.contains(tbl) {
69+
// Check whether the set contains the entry first to avoid an unconditional allocation.
70+
set.insert(tbl.to_string());
71+
}
6772
}
6873

6974
pub fn track_rollback(&self) {

crates/core/src/sync/sync_status.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,11 @@ impl ActiveStreamSubscription {
427427
}
428428

429429
pub fn mark_associated_with_bucket(&mut self, bucket: &OwnedBucketChecksum) {
430-
self.associated_buckets
431-
.get_or_insert_with(&bucket.bucket, |key| key.clone());
430+
// This avoids an allocation if the bucket is already tracked. TODO: Use get_or_insert_with
431+
// after https://github.com/rust-lang/rust/issues/133549 is stable.
432+
if !self.associated_buckets.contains(&bucket.bucket) {
433+
self.associated_buckets.insert(bucket.bucket.clone());
434+
}
432435

433436
self.priority = Some(match self.priority {
434437
None => bucket.priority,

crates/loadable/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ default-features = false
2121
features = []
2222

2323
[features]
24+
nightly = []
2425
default = ["powersync_core/loadable_extension", "sqlite_nostd/loadable_extension", "powersync_core/getrandom"]

crates/loadable/src/lib.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#![no_std]
2-
#![feature(vec_into_raw_parts)]
3-
#![feature(core_intrinsics)]
42
#![allow(internal_features)]
5-
#![feature(lang_items)]
3+
#![cfg_attr(feature = "nightly", feature(core_intrinsics))]
64

75
extern crate alloc;
86

@@ -20,12 +18,16 @@ static ALLOCATOR: SQLite3Allocator = SQLite3Allocator {};
2018

2119
// Custom Panic handler for WASM and other no_std builds
2220
#[cfg(not(test))]
23-
#[panic_handler]
24-
fn panic(_info: &core::panic::PanicInfo) -> ! {
25-
core::intrinsics::abort()
26-
}
21+
mod panic_handler {
22+
#[cfg(feature = "nightly")]
23+
#[panic_handler]
24+
fn panic(_info: &core::panic::PanicInfo) -> ! {
25+
core::intrinsics::abort()
26+
}
2727

28-
#[cfg(not(target_family = "wasm"))]
29-
#[cfg(not(test))]
30-
#[lang = "eh_personality"]
31-
extern "C" fn eh_personality() {}
28+
#[cfg(not(feature = "nightly"))]
29+
#[panic_handler]
30+
fn panic(_info: &core::panic::PanicInfo) -> ! {
31+
loop {}
32+
}
33+
}

crates/static/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ default-features = false
2121
features = []
2222

2323
[features]
24+
nightly = []
2425
default = ["powersync_core/static", "powersync_core/omit_load_extension", "sqlite_nostd/omit_load_extension"]

crates/static/src/lib.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#![no_std]
2-
#![feature(vec_into_raw_parts)]
3-
#![feature(core_intrinsics)]
42
#![allow(internal_features)]
5-
#![feature(lang_items)]
3+
#![cfg_attr(feature = "nightly", feature(core_intrinsics))]
64

75
extern crate alloc;
86

@@ -20,7 +18,16 @@ static ALLOCATOR: SQLite3Allocator = SQLite3Allocator {};
2018

2119
// Custom Panic handler for WASM and other no_std builds
2220
#[cfg(not(test))]
23-
#[panic_handler]
24-
fn panic(_info: &core::panic::PanicInfo) -> ! {
25-
core::intrinsics::abort()
21+
mod panic_handler {
22+
#[cfg(feature = "nightly")]
23+
#[panic_handler]
24+
fn panic(_info: &core::panic::PanicInfo) -> ! {
25+
core::intrinsics::abort()
26+
}
27+
28+
#[cfg(not(feature = "nightly"))]
29+
#[panic_handler]
30+
fn panic(_info: &core::panic::PanicInfo) -> ! {
31+
loop {}
32+
}
2633
}

tool/build_linux.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ function compile() {
55
local triple=$1
66
local suffix=$2
77

8-
cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target $triple
9-
cargo build -p powersync_static -Z build-std=panic_abort,core,alloc --release --target $triple
8+
cargo build -p powersync_loadable --features nightly,default --release --target $triple
9+
cargo build -p powersync_static --features nightly,default --release --target $triple
1010

1111
mv "target/$triple/release/libpowersync.so" "libpowersync_$suffix.linux.so"
1212
mv "target/$triple/release/libpowersync.a" "libpowersync_$suffix.linux.a"

tool/build_macos.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ function compile() {
66
local suffix=$2
77
local os=$3
88

9-
cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target $triple
10-
cargo build -p powersync_static -Z build-std=panic_abort,core,alloc --release --target $triple
9+
cargo build -p powersync_loadable --features nightly,default --release --target $triple
10+
cargo build -p powersync_static --features nightly,default --release --target $triple
1111

1212
mv "target/$triple/release/libpowersync.dylib" "libpowersync_$suffix.$os.dylib"
1313
mv "target/$triple/release/libpowersync.a" "libpowersync_$suffix.$os.a"

0 commit comments

Comments
 (0)