Skip to content

Commit 2dfa46c

Browse files
committed
Try to prevent mangling for symbol names
1 parent 635ab30 commit 2dfa46c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

‎src/rust/Cargo.toml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ lazy_static = "1.5"
1818
[profile.release]
1919
lto = true
2020
codegen-units = 1
21+
strip = "symbols"
22+
panic = "abort"
23+
24+
# Specific profile for WASM builds
25+
[profile.release.package."*"]
26+
opt-level = "s"

‎src/rust/src/lib.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ fn first_is_month(date_vec: &[String]) -> bool {
279279
/// Validate day imputation value range
280280
/// @noRd
281281
#[extendr]
282+
#[no_mangle]
282283
fn checkday(day_impute: Robj) -> Result<()> {
283284
if day_impute.is_null() || day_impute.len() == 0 {
284285
return Ok(()); // nothing to check
@@ -721,6 +722,7 @@ fn fix_date_native(
721722
/// Analyze and fix date strings in a whole column of a DataFrame
722723
/// @noRd
723724
#[extendr]
725+
#[no_mangle]
724726
fn fix_date_column(
725727
dates: Vec<String>,
726728
day_impute: i32,
@@ -753,6 +755,7 @@ fn fix_date_column(
753755
/// Main date fixing function - Rust implementation of .fix_date
754756
/// @noRd
755757
#[extendr]
758+
#[no_mangle]
756759
fn fix_date(
757760
date: Robj,
758761
day_impute: Option<i32>,

‎tools/config.R‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ cfg <- if (is_debug) "debug" else "release"
6363
# there may be use cases later where this can be adapted or expanded
6464
.target <- ifelse(is_wasm, paste0("--target=", webr_target), "")
6565

66-
# add panic exports only for WASM builds via RUSTFLAGS
66+
# add panic exports and symbol optimization flags only for WASM builds via RUSTFLAGS
6767
.panic_exports <- ifelse(
6868
is_wasm,
69-
"RUSTFLAGS=\"$RUSTFLAGS -C panic=abort\" ",
69+
"RUSTFLAGS=\"$RUSTFLAGS -C panic=abort -C opt-level=s -C lto=fat -C codegen-units=1 -C strip=symbols\" ",
7070
""
7171
)
7272

0 commit comments

Comments
 (0)