fix(sdk): preserve intrinsic stubs under LTO#1107
Merged
Conversation
9533fd7 to
ba5a819
Compare
Closed
Collaborator
|
@greenhat If you rebase this on |
ba5a819 to
915000a
Compare
LTO can see through the Rust unreachable stubs used to carry Miden intrinsic signatures and rewrite callers as if those stubs were the real implementations. That breaks frontend lowering because the final wasm no longer reliably preserves the call ABI the linker-stub recognizer expects. Mark SDK intrinsic declarations as weak externs, keep stub bodies uninlined and unoptimized, and force the tiny stub archives into linked wasm with whole-archive. This keeps the stubs available for signature recognition without letting LTO propagate their unreachable bodies into callers.
915000a to
9b7579d
Compare
Contributor
Author
Rebased. |
bitwalker
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #1089
LTO can see through the Rust unreachable stubs used to carry Miden intrinsic signatures and rewrite callers as if those stubs were the real implementations. That breaks frontend lowering because the final wasm no longer reliably preserves the call ABI the linker-stub recognizer expects.
Mark SDK intrinsic declarations as weak externs, keep stub bodies uninlined and unoptimized, and force the tiny stub archives into linked wasm with whole-archive. This keeps the stubs available for signature recognition without letting LTO propagate their unreachable bodies into callers.
MAST Sizes
Values are from
tests/integration/src/rust_masm_tests/examples.rs.examples/basic-walletexamples/basic-wallet-tx-scriptexamples/p2id-noteexamples/p2ide-noteMockchain Cycle Counts
Values are from the
tests/integration-network/src/mockchainexpectations.basic_wallet::test_basic_wallet_p2idmint note cyclesbasic_wallet::test_basic_wallet_p2idtx script processing cyclesbasic_wallet::test_basic_wallet_p2idBob note cyclesbasic_wallet::test_basic_wallet_p2ideBob note cyclesbasic_wallet::test_basic_wallet_p2ide_reclaimreclaim note cyclescounter_contract::test_counter_contractnote cyclescounter_contract_no_auth::test_counter_contract_no_authauth procedure cyclescounter_contract_no_auth::test_counter_contract_no_authnote cyclescounter_contract_rust_auth::test_counter_contract_rust_auth_blocks_unauthorized_note_creationauth procedure cycles