Skip to content

fix(c-api): handle newer Cargo build-script directory layout in shared_object_dir - #6852

Closed
Arshia001 wants to merge 1 commit into
chore/bump-napi-funcref-cachefrom
fix/capi-build-rs-out-dir-layout
Closed

fix(c-api): handle newer Cargo build-script directory layout in shared_object_dir#6852
Arshia001 wants to merge 1 commit into
chore/bump-napi-funcref-cachefrom
fix/capi-build-rs-out-dir-layout

Conversation

@Arshia001

Copy link
Copy Markdown
Member

Summary

  • Fixes the Build docs.rs CI job, which has been failing since chore: bump napi: make GuestHeap the only V8 allocation path #6844 with a panic in lib/c-api/build.rs: assertion failed: shared_object_dir.file_name()...starts_with("wasmer-c-api").
  • Root cause: shared_object_dir() assumed OUT_DIR always nests as build/<pkg>-<hash>/out (package name and hash combined into one hyphenated directory component). Newer Cargo/nightly toolchains instead lay out the build-script fingerprint directory as build/<pkg>/<hash>/out — package name and hash as two separate nested directories. Under that layout the hardcoded assertion fails because the component right after out is just the hash, which doesn't start with "wasmer-c-api".
  • This surfaced now (not caused by any of the preceding commits in this stack) because the CI job's pinned nightly (nightly-2025-09-27) is below the MSRV several dependencies now require (rustc 1.94), so cargo +nightly (a separate, unpinned toolchain reference used by make test-build-docs-rs-ci) ends up resolving to whatever nightly is currently available — new enough to build the project, but also new enough to hit this directory-layout change.
  • Fix: detect which layout is in play by checking whether the directory popped after "out" already starts with "wasmer-c-api"; if not, pop once more to reach it, matching either layout.

Test plan

  • RUSTDOCFLAGS="--cfg=docsrs" cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --locked — passes on both the repo's default (stable) toolchain (old directory layout) and a newer nightly (new directory layout, previously reproduced the panic before this fix, confirmed clean after).
  • cargo build -p wasmer-c-api --features wat,sys-default,compiler,wasi,middlewares,webc_runner — normal (non-doc) build still succeeds.

Stacked on #6850.

…d_object_dir

shared_object_dir() assumed OUT_DIR always nests as
build/<pkg>-<hash>/out (package name and hash in one hyphenated
directory). Newer Cargo/nightly toolchains instead lay it out as
build/<pkg>/<hash>/out (package name and hash as separate nested
directories), which broke the hardcoded assertion and failed the
build script outright.

Detect which layout is in play by checking whether the directory
popped after "out" already starts with "wasmer-c-api"; if not, pop
once more to reach it. Verified against both layouts: the default
toolchain (old layout) and a newer nightly (new layout) both build
wasmer-c-api successfully now.
@marxin

marxin commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Already part of existing PR: #6839.

@marxin marxin closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants