From 4f60a3f5f83c27adbc198010748de3e341a6214f Mon Sep 17 00:00:00 2001 From: Josiah Parry Date: Fri, 15 Aug 2025 11:24:20 -0700 Subject: [PATCH 1/2] closes #463 --- NEWS.md | 1 + R/use_extendr.R | 11 +++++++++-- tests/testthat/_snaps/use_extendr.md | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 778ed67f..8912eb9b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # rextendr (development version) +* Sets the release profile to use `lto=true` and `codegen-units=1` to ensure compatible builds with WebR as well as reduce the overall compiled package size. * Fixes compatibility with WebR by adding `CARGO_PROFILE_DEV_PANIC="abort" CARGO_PROFILE_RELEASE_PANIC="abort"` when targeting `wasm32-unknown-emsacripten` target # rextendr 0.4.1 diff --git a/R/use_extendr.R b/R/use_extendr.R index 67f04ac0..b15a6589 100644 --- a/R/use_extendr.R +++ b/R/use_extendr.R @@ -135,8 +135,15 @@ use_extendr <- function( edition = edition, `rust-version` = "1.65" ), - lib = list(`crate-type` = array("staticlib", 1), name = lib_name), - dependencies = list(`extendr-api` = "*") + lib = list( + `crate-type` = array("staticlib", 1), + name = lib_name + ), + dependencies = list(`extendr-api` = "*"), + `profile.release` = list( + lto = TRUE, + `codegen-units` = 1L + ) ) use_rextendr_template( diff --git a/tests/testthat/_snaps/use_extendr.md b/tests/testthat/_snaps/use_extendr.md index 44dce8cf..137ff321 100644 --- a/tests/testthat/_snaps/use_extendr.md +++ b/tests/testthat/_snaps/use_extendr.md @@ -319,6 +319,10 @@ [dependencies] extendr-api = '*' + + [profile.release] + lto = true + codegen-units = 1 --- @@ -405,6 +409,10 @@ [dependencies] extendr-api = '*' + + [profile.release] + lto = true + codegen-units = 1 # use_rextendr_template() can overwrite existing files From dc5fc21164196a6fa3693e84a7bcbb2bea10f735 Mon Sep 17 00:00:00 2001 From: Josiah Parry Date: Fri, 15 Aug 2025 11:25:16 -0700 Subject: [PATCH 2/2] update news --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 8912eb9b..d92af23a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # rextendr (development version) -* Sets the release profile to use `lto=true` and `codegen-units=1` to ensure compatible builds with WebR as well as reduce the overall compiled package size. +* Sets the release profile to use `lto=true` and `codegen-units=1` to ensure compatible builds with WebR as well as reduce the overall compiled package size . * Fixes compatibility with WebR by adding `CARGO_PROFILE_DEV_PANIC="abort" CARGO_PROFILE_RELEASE_PANIC="abort"` when targeting `wasm32-unknown-emsacripten` target # rextendr 0.4.1