Skip to content

Fix cached runtime embedding across feature builds - #551

Open
ludfjig wants to merge 1 commit into
mainfrom
fix_build_bug
Open

ludfjig wants to merge 1 commit into
mainfrom
fix_build_bug

Conversation

@ludfjig

@ludfjig ludfjig commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Copy the built runtime into OUT_DIR and use that copy for embedding and build metadata.

Native and Pulley builds share one runtime output path. Pulley can overwrite that file while Cargo retains the native build script’s cached output. A later native library compilation then embeds Pulley.

Each configuration’s OUT_DIR copy preserves its runtime. The nested Cargo target directory remains shared to reuse compiled dependencies.

Original Reproduction

cargo build --release -p hyperlight-wasm
cargo build --release -p hyperlight-wasm --features pulley
cargo build --release -p hyperlight-wasm

Before this fix, the third build can embed Pulley despite requesting native.

Why File Tracking Is Insufficient

Adding cargo::rerun-if-changed for the shared binary can miss changes. Nested Cargo can restore a cached binary whose modification time predates the native build script’s last run.

With that directive present, first warm both runtime caches:

cargo build --release -p hyperlight-wasm
cargo build --release -p hyperlight-wasm --features pulley

Then clear only the outer package’s artifacts and reproduce:

cargo clean --release -p hyperlight-wasm
cargo build --release -p hyperlight-wasm
cargo build --release -p hyperlight-wasm --features pulley
touch src/hyperlight_wasm/src/lib.rs
cargo build --release -p hyperlight-wasm

The final build recompiles the native library but reuses its cached build-script output. It embeds the shared Pulley binary. touch changes only the source timestamp.

Fixes #547

Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy the generated guest runtime into OUT_DIR

2 participants