Skip to content

auto-opt: ext-zlib provider link failure on cold object cache (undefined js_zlib_deflate_raw_sync + panic_unwind symbols) #6847

Description

@proggeramlug

Cold-cache reproduction (any tree, main @ 21a3d00):

rm -rf target/perry-auto-* && rm -rf /private/tmp/node_modules/.cache/perry
target/release/perry test-files/test_gap_zlib_4917_level.ts -o /tmp/zl

Link fails with:

Undefined symbols for architecture arm64:
  "__RNvCs4SDFJOLwvtW_7___rustc17___rust_drop_panic", referenced from:
      panic_unwind ... in __libperry_ext_zlib.a_nosharedeps.lib_trimmed.lib
  "_js_zlib_deflate_raw_sync", referenced from: _main

The auto-optimize pipeline pairs the ext-zlib provider archive with an auto-opt stdlib rebuild that lacks the zlib native symbols, and the provider archive carries panic_unwind runtime objects the panic=abort link cannot satisfy. PERRY_NO_AUTO_OPTIMIZE=1 compiles and links the same test fine.

Why this went unnoticed: the compile-object cache under /private/tmp/node_modules/.cache/perry held pre-breakage objects with the old routing baked in; any machine with a warm cache (dev boxes, CI with restored caches) sails past the broken codegen path. A reboot (cleared /tmp) exposed it — six gap tests now compile_fail cold: test_gap_zlib_4917_level, test_gap_zlib_3285_params, test_gap_zlib_fs_assert_2935_2752_2971, test_gap_3662_node_argvalidation, test_gap_constants_tail_3683plus, test_gap_handle_band_object_ops.

Related fragility worth fixing while in here: the compile-object cache living under /private/tmp makes every reboot a cold start and couples cache identity to a world-writable path.

Activity

  1. added a commit that references this issue on Jul 26, 2026
  2. proggeramlug commented on Jul 30, 2026

    @proggeramlug
    ContributorAuthor

    Verified against current with a fresh object cache and a genuinely cold profile rebuild: rebuilt runtime/stdlib, linked, wrote the executable, and ran successfully. PR #7021 fixed the zlib surface plus the panic-runtime dedup holes that caused this report. Closing as resolved.

  3. proggeramlug commented on Aug 7, 2026

    @proggeramlug
    ContributorAuthor

    Reopening for macOS: #7599's audit of known_failures.json caught this reproducing — test_gap_zlib_4917_level fails 3/3 on macOS with the exact original signature (Undefined symbols: _js_zlib_deflate_raw_sync, _js_zlib_inflate_raw_sync) while its zlib siblings pass and Linux passes it. The entry is now platform-scoped macos in known_failures.json rather than unscoped, so it no longer suppresses the passing Linux run. The fix that closed this issue evidently did not cover the macOS link path.

  4. proggeramlug commented on Aug 10, 2026

    @proggeramlug
    ContributorAuthor

    Re-tested the cold-cache reproduction on main @ db44b31b7. The link failure no longer happens, and the remaining half — the auto-optimize rebuild itself failing — is fixed by the open PR #7772.

    The reported failure does not reproduce

    Full cold start, exactly as this issue specifies (rm -rf target/perry-auto-* — 872 MB + 417 MB of state removed — plus /private/tmp/node_modules/.cache/perry and the local object cache):

    perry test-files/test_gap_zlib_4917_level.ts -o /tmp/zl2
    → exit 0, binary written, and it RUNS:
        deflateRawSync level1 >= level9: true
        deflateRawSync levels differ: true
        deflateRawSync roundtrip l1: true
    

    No undefined _js_zlib_deflate_raw_sync, no panic_unwind symbols. What saves it is a fallback that now exists on the auto-optimize path:

    auto-optimize: cargo build failed (exit status: 101), using prebuilt libraries. The prebuilt archives may lack the feature-gated js_* entrypoints this compile routed to ext crates; if the link fails with undefined symbols, fix the cargo error above …

    So the pipeline no longer hands the linker a half-built pair — it declines and uses the prebuilt archives, which link.

    The underlying cause, still live on main

    That fallback is firing because perry-stdlib does not compile under the feature set auto-optimize selects (panic=abort, features=async-runtime,external-zlib-pump):

    error[E0433]: cannot find `events` in `crate`
      --> crates/perry-stdlib/src/common/dispatch/init.rs:668:57
          perry_runtime::js_set_native_events_dispatch(crate::events::js_events_native_dispatch);
    note: found an item that was configured out — gated behind the `bundled-events` feature
    

    Reproduced directly: cargo check -p perry-stdlib --no-default-features --features async-runtime,external-zlib-pump fails on main with that one error, and is clean on #7772's branch, which adds the missing #[cfg(feature = "bundled-events")] to exactly that line. That PR is open for #7764 and closes this half too.

    So this issue is resolved by two independent changes

    1. the prebuilt-archive fallback (already on main) means a broken rebuild can no longer produce an undefined-symbol link;
    2. fix(stdlib): build with --no-default-features again, unbreaking the auto-optimize relink (#7764) #7772 makes the rebuild succeed rather than fall back, so the auto-optimized artifact is actually produced.

    Leaving open until #7772 merges, since without it every auto-optimize build on this configuration silently ships the un-optimized prebuilt archives — correct, but not what the pipeline is for, and the only signal is one warning line.

    The secondary point in the issue body still stands and is untouched: the object cache under /private/tmp makes every reboot a cold start and couples cache identity to a world-writable path. Worth its own issue if it is to be fixed.

  5. proggeramlug commented on Aug 12, 2026

    @proggeramlug
    ContributorAuthor

    Validated on current origin/main at 8260a9e from a fresh worktree.

    The condition called out in the last investigation is now satisfied: #7772 merged as 021c721 and that commit is an ancestor of origin/main. The exact auto-opt stdlib configuration that previously failed now succeeds:

    cargo check -p perry-stdlib --no-default-features --features async-runtime,external-zlib-pump
    Finished dev profile (exit 0)
    

    The prior cold-cache macOS retest already established that the reported undefined js_zlib_deflate_raw_sync / js_zlib_inflate_raw_sync and panic_unwind link failure no longer reproduces; #7772 fixes the remaining stripped-feature rebuild failure instead of relying on the prebuilt-library fallback. Its auto-opt-app-patterns check also passed.

    I attempted an additional cold-cache compile on this Windows host, but this particular fixture is stopped before linking by the separately tracked #7354 WinEH/RS4GC try/catch guard, so it provides no contrary signal about the macOS linker path.

    Closing as completed. The separate /private/tmp cache-location concern remains out of scope for this linker defect and can be tracked independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regression

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions