[DRAFT] Add WASIp2 build and test support#3147
Draft
Conversation
…ENSSL_NO_TTY Add compile-time guards to tests and source files for platforms that lack sockets, threads, or terminal I/O. These guards use the existing OPENSSL_NO_SOCK and OPENSSL_THREADS feature flags, and introduce a new OPENSSL_NO_TTY flag. - Guard BIO_new_ssl_connect declaration and implementation behind OPENSSL_NO_SOCK, matching the existing pattern for SSL_set_fd et al. - Add OPENSSL_NO_TTY stub implementations in crypto/console/console.c. - Guard socket-dependent tests with OPENSSL_NO_SOCK. - Guard thread-dependent tests with OPENSSL_THREADS. - Fix GTEST_HAS_DEATH_TEST checks to use value (not defined) so that defining it to 0 correctly disables death tests.
Add support for building and testing AWS-LC on the wasm32-wasip2 target using the WASI SDK. WASI Preview 2 does not support pthreads, BSD sockets, or terminal I/O. Platform detection (target.h): - Define OPENSSL_WASM_WASI and OPENSSL_WASM_EMSCRIPTEN sub-macros under OPENSSL_WASM. - WASI sets OPENSSL_NO_SOCK, OPENSSL_NO_TTY, and OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED. New files: - util/wasi-sdk-toolchain.cmake: CMake toolchain file for cross-compiling to wasm32-wasip2 via the WASI SDK. - tests/ci/run_wasi_tests.sh: CI script that builds AWS-LC and runs crypto_test, ssl_test, and urandom_test under wasmtime. - .github/workflows/wasi.yml: CI workflow for WASI builds. Build system changes: - Skip pthread linking on Generic systems (WASI). - Skip rwlock_static_init, OCSP integration test, and bssl_shim on Generic systems. - Build boringssl_gtest_main as OBJECT library on WASI to work around wasm-ld not pulling main from static archives. Source changes: - Guard iovec redefinition in ssl/bio_ssl.cc for WASI. - Guard fork-dependent tests and sys/wait.h includes. - Add WASI-compatible temp file/dir utilities in test helpers.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3147 +/- ##
==========================================
- Coverage 78.13% 77.95% -0.18%
==========================================
Files 689 689
Lines 122510 122510
Branches 17074 17094 +20
==========================================
- Hits 95722 95507 -215
- Misses 25889 26105 +216
+ Partials 899 898 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Description of changes:
Depends on #3146 (portability guards).
Add support for building and testing AWS-LC on the
wasm32-wasip2target using the WASI SDK. WASI Preview 2 does not support pthreads, BSD sockets, or terminal I/O, so the corresponding capability flags intarget.hare set whenOPENSSL_WASM_WASIis defined.This PR contains the WASI platform definitions, build infrastructure, and CI — the general-purpose portability guards it depends on are in #3146.
Platform detection (
target.h):OPENSSL_WASM_WASIandOPENSSL_WASM_EMSCRIPTENsub-macros underOPENSSL_WASM.OPENSSL_NO_SOCK,OPENSSL_NO_TTY, andOPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED.New files:
util/wasi-sdk-toolchain.cmake— CMake toolchain file for cross-compiling towasm32-wasip2.tests/ci/run_wasi_tests.sh— CI script that builds AWS-LC and runscrypto_test,ssl_test, andurandom_testunder wasmtime..github/workflows/wasi.yml— CI workflow for WASI builds.Call-outs:
boringssl_gtest_mainis built as anOBJECTlibrary (instead ofSTATIC) on WASI to work around wasm-ld not pullingmainfrom static archives.iovecredefinition guard inssl/bio_ssl.ccis scoped toOPENSSL_WASM_WASI; WASI's libc providesiovecthrough standard headers so the redefinition would be a conflict.emscripten.yml.Testing:
The
wasi.ymlCI workflow builds with WASI SDK 25 and runs tests under wasmtime 29.0.1.crypto_test,ssl_test, andurandom_testare executed with a gtest filter excluding tests that require fork, sockets, threads, or unsupported file operations.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.