Skip to content

Add WASI_SDK_BUILD_SHARED option#632

Merged
alexcrichton merged 1 commit into
WebAssembly:mainfrom
rvandermeulen:add-build-shared-option
May 16, 2026
Merged

Add WASI_SDK_BUILD_SHARED option#632
alexcrichton merged 1 commit into
WebAssembly:mainfrom
rvandermeulen:add-build-shared-option

Conversation

@rvandermeulen
Copy link
Copy Markdown
Contributor

@rvandermeulen rvandermeulen commented May 15, 2026

Adds a new CMake option, defaulting to ON so existing builds are unaffected. When set to OFF, wasi-libc is built with -DBUILD_SHARED=OFF (its existing if (NOT BUILD_SHARED) block then short-circuits the per-target set(SHARED ON) for wasm32-wasi/wasm32-wasip1), and the libcxx/libcxxabi/libunwind invocations no longer use ${pic} directly for their *_ENABLE_SHARED flags — they go through a new local shared variable that AND's WASI_SDK_BUILD_SHARED with ${pic}.

Motivation: downstream consumers that build wasi-sdk from source as part of a larger toolchain pipeline (in our case, Firefox's build system) don't ship or link against shared sysroot artifacts. The current code path provides no way to opt out, so we've been patching locally. The existing comment in wasi-sdk-sysroot.cmake notes shared libraries aren't supported with LTO; this doesn't change that default, it just exposes the same toggle for non-LTO builds too.

A static entry is added to the build-only-sysroot CI matrix to exercise the OFF path.

@rvandermeulen rvandermeulen force-pushed the add-build-shared-option branch from e358ce9 to 10801a8 Compare May 15, 2026 20:01
Adds a new top-level CMake option, defaulting to ON to preserve existing behavior. When set to OFF:

* wasi-libc is built with -DBUILD_SHARED=OFF regardless of LTO state.
* libcxx/libcxxabi/libunwind ExternalProject_Add invocations no longer use ${pic} directly for
  their *_ENABLE_SHARED flags; they go through a local `shared` variable that AND's
  WASI_SDK_BUILD_SHARED with ${pic}.

This lets downstream consumers that build wasi-sdk from source as part of a larger toolchain
pipeline produce a static-only sysroot without patching locally.

A 'static' entry is added to the build-only-sysroot CI matrix to exercise the OFF path.
@rvandermeulen rvandermeulen force-pushed the add-build-shared-option branch from 10801a8 to dc47eac Compare May 15, 2026 20:25
@rvandermeulen rvandermeulen marked this pull request as draft May 15, 2026 20:27
@rvandermeulen rvandermeulen marked this pull request as ready for review May 15, 2026 23:20
Copy link
Copy Markdown
Collaborator

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@alexcrichton alexcrichton enabled auto-merge (squash) May 15, 2026 23:26
@alexcrichton alexcrichton merged commit d05f757 into WebAssembly:main May 16, 2026
12 checks passed
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