Build and run all tests as shared libraries #780
Merged
alexcrichton merged 5 commits intoWebAssembly:mainfrom Apr 3, 2026
Merged
Build and run all tests as shared libraries #780alexcrichton merged 5 commits intoWebAssembly:mainfrom
alexcrichton merged 5 commits intoWebAssembly:mainfrom
Conversation
See WebAssembly#778 for details.
This refactors the test building infrastructure to build all tests as shared libraries in addition to the previous binaries which are all statically linked. This required a number of changes and fixes to get this working: * `wit-bindgen`-generated code is compiled with `-fvisibility=hidden` to avoid exposing all of their symbols form shared libraries, notably which breaks wasip3 targets currently. These are all private implementation details anyway and don't need to be exported. * Source files in the `wasi-emulated-process-clocks` library are reimplemented in terms of libc-like APIs instead of raw WASI APIs since the raw APIs are no longer visible across a shared library boundary. * The `libc_test_support` library is deleted in favor of just adding the source files to all tests. This avoids needing to wrangle multiple libraries for both shared/static and is just easier to manage. * Support for disabling warnings in third-party code is now per-file instead of per-target and some warnings for third-party executables have been moved around to help consolidate helper functions here. * Dynamically-linked tests are compiled with `-Wl,--skip-wit-component,-shared` to manually run `wasm-tools component link` while still generating dynamic imports with `wasm-ld`. * One instance of undefined behavior in the `preadwrite.c` test was fixed to account for stack data being undefined.
dicej
approved these changes
Apr 2, 2026
Collaborator
dicej
left a comment
There was a problem hiding this comment.
Thanks so much for doing this!
| add_libc_test(functional/argv.c CFLAGS -Wno-sign-compare) | ||
| add_libc_test(functional/basename.c) | ||
| add_libc_test(functional/clocale_mbfuncs.c) | ||
| add_libc_test(functional/clocale_mbfuncs.c CFLAGS -Wno-unused-variable -Wno-sign-compare) |
Collaborator
There was a problem hiding this comment.
Out of curiosity, why does each test have its own set of warning flags? Is the goal to incrementally add more flags for more tests and eventually use e.g. -Wall for all the tests?
Collaborator
Author
There was a problem hiding this comment.
These are third-party tests from an external repo so we can't control the source code, but they're compiled with the default flags of -Wall -Wextra`, so this is used to get them. So hopefully just a one-time thing, and this is shuffling around where the flags are specified.
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.
This PR is derived from #779 to build and run dynamically-linked tests in wasi-libc to help exercise shared-library-related support. This requires the fix from #779, for example, to get tests passing. This takes a different approach to testing, however, to build and run all tests as dynamically linked instead of only some particular tests. This avoids the need for a one-off test and additionally helps reuse all existing infrastructure for tests. This expands the test coverage more and documents a few cases where dynamic libraries don't work (long-float intrinsics and setjmp)