From 6911d9135dd3209083450d6a354e7e497e3a736e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 1 Jul 2026 12:30:36 -0500 Subject: [PATCH] More work towards a wasip3 target (#636) This is a work-in-progress to get things enabled. The main bulk of the change here is updating LLVM itself to tip-of-tree as of yesterday morning. This removes two `*.patch` files because they've landed, and adds another `*.patch` file to work around a new issue that's cropped up. I've also included a `*.patch` for https://github.com/llvm/llvm-project/pull/200855, too. This isn't ready yet to land as it's still failing to build/link/etc, and I'll comment some more below. --- .github/actions/install-deps/action.yml | 2 +- CMakeLists.txt | 2 +- cmake/wasi-sdk-sysroot.cmake | 4 +- cmake/wasi-sdk-toolchain.cmake | 10 +- src/llvm-pr-185770.patch | 105 ---------------- src/llvm-pr-185775.patch | 152 ------------------------ src/llvm-pr-186054.patch | 20 ++-- src/llvm-project | 2 +- src/llvm-undo-part-of-194317.patch | 15 +++ src/wasi-libc | 2 +- tests/CMakeLists.txt | 3 - version.py | 78 +++++++----- 12 files changed, 86 insertions(+), 309 deletions(-) delete mode 100644 src/llvm-pr-185770.patch delete mode 100644 src/llvm-pr-185775.patch create mode 100644 src/llvm-undo-part-of-194317.patch diff --git a/.github/actions/install-deps/action.yml b/.github/actions/install-deps/action.yml index da3cb0f..efb7dcf 100644 --- a/.github/actions/install-deps/action.yml +++ b/.github/actions/install-deps/action.yml @@ -7,7 +7,7 @@ runs: - name: Setup `wasmtime` for tests uses: bytecodealliance/actions/wasmtime/setup@v1 with: - version: "44.0.0" + version: "46.0.1" - name: Install ccache, ninja (macOS) run: brew install ccache ninja if: runner.os == 'macOS' diff --git a/CMakeLists.txt b/CMakeLists.txt index 78c95e5..8e448bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") project(wasi-sdk) include(ExternalProject) -set(WASI_SDK_TARGETS "wasm32-wasip1;wasm32-wasip2;wasm32-wasip1-threads" +set(WASI_SDK_TARGETS "wasm32-wasip1;wasm32-wasip2;wasm32-wasip3;wasm32-wasip1-threads" CACHE STRING "List of WASI targets to build") option(WASI_SDK_BUILD_TOOLCHAIN "Build a toolchain instead of the sysroot" OFF) diff --git a/cmake/wasi-sdk-sysroot.cmake b/cmake/wasi-sdk-sysroot.cmake index 613aaa7..2706ea1 100644 --- a/cmake/wasi-sdk-sysroot.cmake +++ b/cmake/wasi-sdk-sysroot.cmake @@ -186,6 +186,8 @@ function(define_wasi_libc_sub target target_suffix lto) if(${target} MATCHES threads) set(libcompiler_rt_a ${wasi_resource_dir}/lib/wasm32-unknown-wasip1-threads/libclang_rt.builtins.a) + elseif(${target} MATCHES wasip3) + set(libcompiler_rt_a ${wasi_resource_dir}/lib/wasm32-unknown-wasip3/libclang_rt.builtins.a) else() set(libcompiler_rt_a ${wasi_resource_dir}/lib/wasm32-unknown-wasip1/libclang_rt.builtins.a) endif() @@ -375,7 +377,7 @@ function(define_libcxx_sub target target_suffix extra_target_flags extra_libdir_ "git apply ${CMAKE_SOURCE_DIR}/src/llvm-pr-186054.patch || git apply ${CMAKE_SOURCE_DIR}/src/llvm-pr-186054.patch -R --check" COMMAND ${CMAKE_COMMAND} -E chdir .. bash -c - "git apply ${CMAKE_SOURCE_DIR}/src/llvm-pr-185770.patch || git apply ${CMAKE_SOURCE_DIR}/src/llvm-pr-185770.patch -R --check" + "git apply ${CMAKE_SOURCE_DIR}/src/llvm-undo-part-of-194317.patch || git apply ${CMAKE_SOURCE_DIR}/src/llvm-undo-part-of-194317.patch -R --check" ) add_dependencies(libcxx-${target} libcxx-${target}${target_suffix}-build) endfunction() diff --git a/cmake/wasi-sdk-toolchain.cmake b/cmake/wasi-sdk-toolchain.cmake index 6bc7c0a..ee1e627 100644 --- a/cmake/wasi-sdk-toolchain.cmake +++ b/cmake/wasi-sdk-toolchain.cmake @@ -229,6 +229,13 @@ ExternalProject_Add(llvm-build -DLLVM_DEFAULT_TARGET_TRIPLE=wasm32-wasip1 -DLLVM_INSTALL_BINUTILS_SYMLINKS=TRUE -DLLVM_ENABLE_LIBXML2=OFF + # LLDB's `FindLibXml2` module determines the libxml2 version solely via + # pkg-config (`PC_LIBXML_VERSION`) and rejects it if the version can't be + # found. The libxml2 we build above installs into `${wasi_tmp_install}`, + # which isn't on the default pkg-config search path, so point pkg-config at + # it via `CMAKE_PREFIX_PATH` to let LLVM's check succeed. + -DCMAKE_PREFIX_PATH=${wasi_tmp_install} + -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON # Pass `-s` to strip symbols by default and shrink the size of the # distribution -DCMAKE_EXE_LINKER_FLAGS=-s @@ -248,9 +255,6 @@ ExternalProject_Add(llvm-build USES_TERMINAL_CONFIGURE ON USES_TERMINAL_BUILD ON USES_TERMINAL_INSTALL ON - PATCH_COMMAND - ${CMAKE_COMMAND} -E chdir .. bash -c - "git apply ${CMAKE_SOURCE_DIR}/src/llvm-pr-185775.patch || git apply ${CMAKE_SOURCE_DIR}/src/llvm-pr-185775.patch -R --check" ) add_custom_target(build ALL DEPENDS llvm-build) diff --git a/src/llvm-pr-185770.patch b/src/llvm-pr-185770.patch deleted file mode 100644 index 2d47923..0000000 --- a/src/llvm-pr-185770.patch +++ /dev/null @@ -1,105 +0,0 @@ -From d702761d9135ebbb83590d4dd1323be433701ebd Mon Sep 17 00:00:00 2001 -From: Alex Crichton -Date: Tue, 10 Mar 2026 15:49:55 -0700 -Subject: [PATCH] [WebAssembly] Move __cpp_exception to libunwind - -The `__cpp_exception` symbol is now defined in libunwind instead of -compiler-rt. This is moved for a few reasons, but the primary reason is -that compiler-rt is linked duplicate-ly into all shared objects meaning -that it's not suitable for define-once symbols such as -`__cpp_exception`. By moving the definition to the user of the symbol, -libunwind itself, that guarantees that the symbol should be defined -exactly once and only when appropriate. A secondary reason for this -movement is that it avoids the need to compile compiler-rt twice: once -with exception and once without, and instead the same build can be used -for both exceptions-and-not. ---- - compiler-rt/lib/builtins/CMakeLists.txt | 1 - - .../lib/builtins/wasm/__cpp_exception.S | 26 ------------------- - libunwind/src/Unwind-wasm.c | 15 +++++++++++ - .../compiler-rt/lib/builtins/sources.gni | 1 - - 4 files changed, 15 insertions(+), 28 deletions(-) - delete mode 100644 compiler-rt/lib/builtins/wasm/__cpp_exception.S - -diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt -index 6c27f6d4d529e..f0570a9092f40 100644 ---- a/compiler-rt/lib/builtins/CMakeLists.txt -+++ b/compiler-rt/lib/builtins/CMakeLists.txt -@@ -891,7 +891,6 @@ set(s390x_SOURCES - - set(wasm_SOURCES - wasm/__c_longjmp.S -- wasm/__cpp_exception.S - ${GENERIC_TF_SOURCES} - ${GENERIC_SOURCES} - ) -diff --git a/compiler-rt/lib/builtins/wasm/__cpp_exception.S b/compiler-rt/lib/builtins/wasm/__cpp_exception.S -deleted file mode 100644 -index 0496e1dbf6158..0000000000000 ---- a/compiler-rt/lib/builtins/wasm/__cpp_exception.S -+++ /dev/null -@@ -1,26 +0,0 @@ --//===-- __cpp_exception.S - Implement __cpp_exception ---------------------===// --// --// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. --// See https://llvm.org/LICENSE.txt for license information. --// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception --// --//===----------------------------------------------------------------------===// --// --// This file implements __cpp_exception which LLVM uses to implement exception --// handling when Wasm EH is enabled. --// --//===----------------------------------------------------------------------===// -- --#ifdef __wasm_exception_handling__ -- --#ifdef __wasm64__ --#define PTR i64 --#else --#define PTR i32 --#endif -- --.globl __cpp_exception --.tagtype __cpp_exception PTR --__cpp_exception: -- --#endif // !__wasm_exception_handling__ -diff --git a/libunwind/src/Unwind-wasm.c b/libunwind/src/Unwind-wasm.c -index 2f4498c3f3989..c0ca9b775d244 100644 ---- a/libunwind/src/Unwind-wasm.c -+++ b/libunwind/src/Unwind-wasm.c -@@ -69,6 +69,21 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) { - __builtin_wasm_throw(0, exception_object); - } - -+// Define the `__cpp_exception` symbol which `__builtin_wasm_throw` above will -+// reference. This is defined here in `libunwind` as the single canonical -+// definition for this API and it's required for users to ensure that there's -+// only one copy of `libunwind` within a wasm module to ensure this is only -+// defined once and exactly once. -+__asm__(".globl __cpp_exception\n" -+#if defined(__wasm32__) -+ ".tagtype __cpp_exception i32\n" -+#elif defined(__wasm64__) -+ ".tagtype __cpp_exception i64\n" -+#else -+#error "Unsupported Wasm architecture" -+#endif -+ "__cpp_exception:\n"); -+ - /// Called by __cxa_end_catch. - _LIBUNWIND_EXPORT void - _Unwind_DeleteException(_Unwind_Exception *exception_object) { -diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/sources.gni b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/sources.gni -index 2ac71aa8e8367..c9eeede16e3eb 100644 ---- a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/sources.gni -+++ b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/sources.gni -@@ -539,7 +539,6 @@ if (current_cpu == "ve") { - if (current_cpu == "wasm") { - builtins_sources += [ - "wasm/__c_longjmp.S", -- "wasm/__cpp_exception.S", - ] - } - diff --git a/src/llvm-pr-185775.patch b/src/llvm-pr-185775.patch deleted file mode 100644 index f1fdb6a..0000000 --- a/src/llvm-pr-185775.patch +++ /dev/null @@ -1,152 +0,0 @@ -From 0e36e8f304cd5f3997916f5d85201bb17e340337 Mon Sep 17 00:00:00 2001 -From: Alex Crichton -Date: Tue, 10 Mar 2026 16:14:36 -0700 -Subject: [PATCH] [WebAssembly] Clang support for exception-based lookup paths - -This commit is an attempt to make progress on WebAssembly/wasi-sdk#565 -where with wasi-sdk I'd like to ship a single toolchain which is -capable of building binaries both with C++ exceptions and without. This -means that there can't be a single set of precompiled libraries that are -used because one set of libraries is wrong for the other mode. The -support added here is to use `-fwasm-exceptions` to automatically select -a lookup path in the sysroot. The intention is then that wasi-sdk will -ship both a "eh" set of C++ libraries as well as a "noeh" set of C++ -libraries too. Clang will automatically select the correct one based on -compilation flags which means that the final distribution will be able -to build both binaries with exceptions and without. ---- - clang/lib/Driver/ToolChains/WebAssembly.cpp | 51 ++++++++++++++------- - clang/test/Driver/wasm-toolchain.cpp | 35 ++++++++++++++ - 2 files changed, 70 insertions(+), 16 deletions(-) - -diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp -index b5fa5760a46a0..e532ef0743cc2 100644 ---- a/clang/lib/Driver/ToolChains/WebAssembly.cpp -+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp -@@ -34,6 +34,15 @@ std::string WebAssembly::getMultiarchTriple(const Driver &D, - TargetTriple.getOSAndEnvironmentName()).str(); - } - -+/// Returns a directory name in which separate objects compile with/without -+/// exceptions may lie. This is used both for `#include` paths as well as lib -+/// paths. -+static std::string GetCXXExceptionsDir(const ArgList &DriverArgs) { -+ if (DriverArgs.getLastArg(options::OPT_fwasm_exceptions)) -+ return "eh"; -+ return "noeh"; -+} -+ - std::string wasm::Linker::getLinkerPath(const ArgList &Args) const { - const ToolChain &ToolChain = getToolChain(); - if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) { -@@ -230,12 +239,16 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA, - } - } - --/// Given a base library directory, append path components to form the --/// LTO directory. --static std::string AppendLTOLibDir(const std::string &Dir) { -+/// Append `Dir` to `Paths`, but also include the LTO directories before that if -+/// LTO is eanbled. -+static void AppendLibDirAndLTODir(ToolChain::path_list &Paths, const Driver &D, -+ const std::string &Dir) { -+ if (D.isUsingLTO()) { - // The version allows the path to be keyed to the specific version of - // LLVM in used, as the bitcode format is not stable. -- return Dir + "/llvm-lto/" LLVM_VERSION_STRING; -+ Paths.push_back(Dir + "/llvm-lto/" LLVM_VERSION_STRING); -+ } -+ Paths.push_back(Dir); - } - - WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple, -@@ -256,14 +269,15 @@ WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple, - } else { - const std::string MultiarchTriple = - getMultiarchTriple(getDriver(), Triple, SysRoot); -- if (D.isUsingLTO()) { -- // For LTO, enable use of lto-enabled sysroot libraries too, if available. -- // Note that the directory is keyed to the LLVM revision, as LLVM's -- // bitcode format is not stable. -- auto Dir = AppendLTOLibDir(SysRoot + "/lib/" + MultiarchTriple); -- getFilePaths().push_back(Dir); -- } -- getFilePaths().push_back(SysRoot + "/lib/" + MultiarchTriple); -+ std::string TripleLibDir = SysRoot + "/lib/" + MultiarchTriple; -+ // Allow sysroots to segregate objects based on whether exceptions are -+ // enabled or not. This is intended to assist with distribution of pre-built -+ // sysroots that contain libraries that are capable of producing binaries -+ // entirely without exception-handling instructions but also with if -+ // exceptions are enabled, for example. -+ AppendLibDirAndLTODir(getFilePaths(), D, -+ TripleLibDir + "/" + GetCXXExceptionsDir(Args)); -+ AppendLibDirAndLTODir(getFilePaths(), D, TripleLibDir); - } - - if (getTriple().getOS() == llvm::Triple::WASI) { -@@ -580,13 +594,18 @@ void WebAssembly::addLibCxxIncludePaths( - if (Version.empty()) - return; - -- // First add the per-target include path if the OS is known. -+ // First add the per-target-per-exception-handling include path if the -+ // OS is known, then second add the per-target include path. - if (IsKnownOs) { -- std::string TargetDir = LibPath + "/" + MultiarchTriple + "/c++/" + Version; -- addSystemInclude(DriverArgs, CC1Args, TargetDir); -+ std::string TargetDir = LibPath + "/" + MultiarchTriple; -+ std::string Suffix = "/c++/" + Version; -+ addSystemInclude(DriverArgs, CC1Args, -+ TargetDir + "/" + GetCXXExceptionsDir(DriverArgs) + -+ Suffix); -+ addSystemInclude(DriverArgs, CC1Args, TargetDir + Suffix); - } - -- // Second add the generic one. -+ // Third add the generic one. - addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version); - } - -diff --git a/clang/test/Driver/wasm-toolchain.cpp b/clang/test/Driver/wasm-toolchain.cpp -index d7ff76cedfd10..30a2f9397e3f4 100644 ---- a/clang/test/Driver/wasm-toolchain.cpp -+++ b/clang/test/Driver/wasm-toolchain.cpp -@@ -111,3 +111,38 @@ - // COMPILE_WALI_STDCXX: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include" - // COMPILE_WALI_STDCXX: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-linux-muslwali" - // COMPILE_WALI_STDCXX: "-internal-isystem" "[[SYSROOT:[^"]+]]/include" -+ -+// With a known OS "eh" and "noeh" directories are added to enable segregating -+// object built with/without exception-handling -+ -+// RUN: %clangxx -### --target=wasm32-wasi --stdlib=libc++ %s 2>&1 \ -+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree/usr \ -+// RUN: | FileCheck -check-prefix=EH_OFF %s -+// EH_OFF: "-cc1" -+// EH_OFF: "-isysroot" "[[SYSROOT:[^"]+]]" -+// EH_OFF: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-wasi/noeh/c++/v1" -+// EH_OFF-NOT: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-wasi/eh/c++/v1" -+// EH_OFF: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-wasi/c++/v1" -+// EH_OFF: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/c++/v1" -+// EH_OFF: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-wasi" -+// EH_OFF: "-internal-isystem" "[[SYSROOT:[^"]+]]/include" -+ -+// RUN: %clangxx -### --target=wasm32-wasi -fwasm-exceptions --stdlib=libc++ %s 2>&1 \ -+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree/usr \ -+// RUN: | FileCheck -check-prefix=EH_ON %s -+// EH_ON: "-cc1" -+// EH_ON: "-isysroot" "[[SYSROOT:[^"]+]]" -+// EH_ON: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-wasi/eh/c++/v1" -+// EH_ON-NOT: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-wasi/noeh/c++/v1" -+// EH_ON: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-wasi/c++/v1" -+// EH_ON: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/c++/v1" -+// EH_ON: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-wasi" -+// EH_ON: "-internal-isystem" "[[SYSROOT:[^"]+]]/include" -+// -+// RUN: %clangxx -### --target=wasm32-wasi --sysroot=/foo --stdlib=libc++ %s 2>&1 \ -+// RUN: | FileCheck -check-prefix=EH_OFF_LINK %s -+// EH_OFF_LINK: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi/noeh" "-L/foo/lib/wasm32-wasi" -+// -+// RUN: %clangxx -### --target=wasm32-wasi -fwasm-exceptions --sysroot=/foo --stdlib=libc++ %s 2>&1 \ -+// RUN: | FileCheck -check-prefix=EH_ON_LINK %s -+// EH_ON_LINK: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi/eh" "-L/foo/lib/wasm32-wasi" diff --git a/src/llvm-pr-186054.patch b/src/llvm-pr-186054.patch index c7756d7..3347c0a 100644 --- a/src/llvm-pr-186054.patch +++ b/src/llvm-pr-186054.patch @@ -1,8 +1,8 @@ -From f71fdfcbd6fcc7b521c74b5856ebeacdd6cf55d9 Mon Sep 17 00:00:00 2001 +From 46301f073b8cc85ad0d2f1dcdda923209bff173b Mon Sep 17 00:00:00 2001 From: Catherine Date: Thu, 12 Mar 2026 08:19:49 +0000 Subject: [PATCH] [libc++abi] Revert gating of `__cxa_thread_atexit` on - Linux||Fuchsia + Wasm/WASI This was done in the commit 3c100d5d548d with the description "Enable -Wmissing-prototypes" which seems incongruent to me. @@ -23,26 +23,28 @@ wasm-ld: error: /tmp/repro-dd1ad7.o: undefined symbol: __cxa_thread_atexit clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` --- - libcxxabi/src/cxa_thread_atexit.cpp | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) + libcxxabi/src/cxa_thread_atexit.cpp | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libcxxabi/src/cxa_thread_atexit.cpp b/libcxxabi/src/cxa_thread_atexit.cpp -index 402a52c741012..1bdcb4ef192b4 100644 +index 402a52c741012..099be242c6dc6 100644 --- a/libcxxabi/src/cxa_thread_atexit.cpp +++ b/libcxxabi/src/cxa_thread_atexit.cpp -@@ -106,7 +106,6 @@ namespace { +@@ -106,7 +106,7 @@ namespace { #endif // HAVE___CXA_THREAD_ATEXIT_IMPL -#if defined(__linux__) || defined(__Fuchsia__) ++#if defined(__linux__) || defined(__Fuchsia__) || defined(__wasm__) extern "C" { _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(Dtor dtor, void* obj, void* dso_symbol) throw() { -@@ -141,6 +140,5 @@ extern "C" { +@@ -141,6 +141,7 @@ extern "C" { } #endif // HAVE___CXA_THREAD_ATEXIT_IMPL } --} // extern "C" ++ + } // extern "C" -#endif // defined(__linux__) || defined(__Fuchsia__) -+ } // extern "C" ++#endif // defined(__linux__) || defined(__Fuchsia__) || defined(__wasm__) } // namespace __cxxabiv1 diff --git a/src/llvm-project b/src/llvm-project index 4434dab..1b7c3e5 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 4434dabb69916856b824f68a64b029c67175e532 +Subproject commit 1b7c3e57bbc8e367ff8203e8818b018337319d7e diff --git a/src/llvm-undo-part-of-194317.patch b/src/llvm-undo-part-of-194317.patch new file mode 100644 index 0000000..a5c74c0 --- /dev/null +++ b/src/llvm-undo-part-of-194317.patch @@ -0,0 +1,15 @@ +diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h +index e1e60e18fd7c..d1fb4cdbcd43 100644 +--- a/libcxx/include/__locale_dir/locale_base_api.h ++++ b/libcxx/include/__locale_dir/locale_base_api.h +@@ -132,7 +132,9 @@ + // (by providing global non-reserved names) and the new API. As we move individual platforms + // towards the new way of defining the locale base API, this should disappear since each platform + // will define those directly. +-# include <__locale_dir/locale_base_api/ibm.h> ++# if defined(__MVS__) ++# include <__locale_dir/locale_base_api/ibm.h> ++# endif + + # include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> + diff --git a/src/wasi-libc b/src/wasi-libc index 161b319..e2507dd 160000 --- a/src/wasi-libc +++ b/src/wasi-libc @@ -1 +1 @@ -Subproject commit 161b3195fc2558d2b1ba3eb9ffae3b2b47407623 +Subproject commit e2507dd1d4a4fa2d1163efadede8c75cb2d5ed07 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3b5972d..1e70377 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -123,9 +123,6 @@ function(add_testcase test) if(WASI_SDK_EXCEPTIONS) list(APPEND runner -Wexceptions) endif() - if(target MATCHES "wasip3") - list(APPEND runner -Wcomponent-model-async -Sp3) - endif() endif() foreach(env IN LISTS arg_ENV) diff --git a/version.py b/version.py index 62f0ff9..bcec1c7 100755 --- a/version.py +++ b/version.py @@ -25,51 +25,65 @@ def git_commit(dir): def parse_git_version(version): - # Parse, e.g.: wasi-sdk-21-0-g317548590b40+m + # Parse, e.g.: wasi-sdk-$version-0-g317548590b40+m parts = version.replace('+', '-').split('-') assert parts.pop(0) == 'wasi' assert parts.pop(0) == 'sdk' - major, minor = parts.pop(0), parts.pop(0) - git = None dirty = False - - if parts: - # Check: git|dirty. - next = parts.pop(0) - if next == 'm': - dirty = True - elif minor != '0': - git = next[1:] - - # Check: dirty. - if parts: - assert parts.pop(0) == 'm', f'expected dirty flag: +m' - dirty = True - - assert not parts, f'unexpected suffixes: {parts}' - return major, minor, git, dirty + git = parts.pop() + assert git is not None + # If git printed `+m` at the end then we're dirty and the next-to-last part + # is now the git commit + if git == 'm': + dirty = True + git = parts.pop() + + # If the git commit doesn't start with `g` then that's not actually a git + # commit. Technically this should look for `GIT_REF_LEN` hexadecimal digits, + # but that's left for later. + if not git.startswith('g'): + parts.append(git) + git = None + + # The next part in the back is the number of commits since the tag, and the + # first part in the front is the major version of wasi-sdk itself. + commits_since_tag = parts.pop() + major_version = parts.pop(0) + + # If there are 0 commits since the last tag then forcibly drop the git part + # as that produces a nice clean version for tagged commits. + if commits_since_tag == '0': + git = None + + # Pretend the commits since the tag is a minor version number, and then + # add in any other words after the tag to the prerelease part, if any. + ret = f'{major_version}.{commits_since_tag}' + if len(parts) > 0: + ret += '-' + '-'.join(parts) + + # Throw on git/dirty info + if git: + ret += git + if dirty: + ret += '+m' + return ret # Some inline tests to check Git version parsing: -assert parse_git_version( - 'wasi-sdk-21-1-g317548590b40+m') == ('21', '1', '317548590b40', True) -assert parse_git_version('wasi-sdk-21-2+m') == ('21', '2', None, True) -assert parse_git_version( - 'wasi-sdk-23-0-g317548590b40') == ('23', '0', None, False) - +assert parse_git_version('wasi-sdk-21-1-g317548590b40+m') == '21.1g317548590b40+m' +assert parse_git_version('wasi-sdk-21-2+m') == '21.2+m' +assert parse_git_version('wasi-sdk-23-0-g317548590b40') == '23.0' +assert parse_git_version('wasi-sdk-23-tag-0-g317548590b40') == '23.0-tag' +assert parse_git_version('wasi-sdk-23-some-tag-0-g317548590b40') == '23.0-some-tag' +assert parse_git_version('wasi-sdk-23-some.tag-0-g317548590b40') == '23.0-some.tag' +assert parse_git_version('wasi-sdk-23-tag.rc1-1-g100') == '23.1-tag.rc1g100' def git_version(): version = exec(['git', 'describe', '--long', '--candidates=999', '--match=wasi-sdk-*', '--dirty=+m', f'--abbrev={GIT_REF_LEN}'], os.path.dirname(sys.argv[0])) - major, minor, git, dirty = parse_git_version(version) - version = f'{major}.{minor}' - if git: - version += f'g{git}' - if dirty: - version += '+m' - return version + return parse_git_version(version) def parse_cmake_set(line):