Skip to content

Commit cb49601

Browse files
committed
fix(compile): force crypto feature in auto-optimized stdlib (v0.5.871)
perry-stdlib unconditionally re-bundles perry-updater (so user code calling `perry/updater` resolves at link time). perry-updater's `perry_updater_verify_signature_v2` references the extern symbol `js_crypto_ed25519_verify`, which only exists when perry-stdlib is built with `feature = "crypto"`. The auto-optimize path passes `--no-default-features` and only adds features inferred from user imports, so `crypto` is off for any user binary that doesn't explicitly import a crypto API — and the link fails on `undefined reference to js_crypto_ed25519_verify` from the bundled updater object. Surfaced when v0.5.868 re-enabled the gtk4 doc-tests entry; the gtk4 link path triggers the auto-optimize rebuild, the rebuilt stdlib didn't include crypto, and every doc-test failed to link. Forces `crypto` on always (mirrors how `async-runtime` is forced when `ctx.needs_ui` for the same reason — bundled object code that needs a symbol gated behind a feature).
1 parent c39541d commit cb49601

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

crates/perry-codegen/src/stmt.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,7 @@ pub(crate) fn lower_stmt(ctx: &mut FnCtx<'_>, stmt: &Stmt) -> Result<()> {
972972
let val = lower_expr(ctx, expr)?;
973973
if ctx.is_async_fn && ctx.try_depth == 0 {
974974
let blk = ctx.block();
975-
let handle =
976-
blk.call(crate::types::I64, "js_promise_rejected", &[(DOUBLE, &val)]);
975+
let handle = blk.call(crate::types::I64, "js_promise_rejected", &[(DOUBLE, &val)]);
977976
let boxed = crate::expr::nanbox_pointer_inline_pub(blk, &handle);
978977
blk.ret(DOUBLE, &boxed);
979978
} else {

crates/perry/src/commands/compile/optimized_libs.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,16 @@ pub(super) fn build_optimized_libs(
342342
if ctx.needs_ui {
343343
features.insert("async-runtime");
344344
}
345+
// perry-stdlib unconditionally re-bundles perry-updater (so user code
346+
// calling `perry/updater` resolves at link time without extra wiring).
347+
// perry-updater's `perry_updater_verify_signature_v2` references the
348+
// extern `js_crypto_ed25519_verify`, which lives in perry-stdlib's
349+
// crypto module — gated by `#[cfg(feature = "crypto")]`. With
350+
// --no-default-features the symbol is absent and the link fails on
351+
// every program (regardless of whether the user touched crypto APIs).
352+
// Force `crypto` on whenever the auto-optimize path rebuilds stdlib
353+
// so the bundled updater always has a resolvable target.
354+
features.insert("crypto");
345355
let feature_arg = features_to_cargo_arg(&features);
346356

347357
// panic = "abort" is safe whenever no `catch_unwind` callers are

0 commit comments

Comments
 (0)