Skip to content

Commit 637bdc9

Browse files
authored
Add __wasi_sdk_{major,version}__ defines (#709)
This commit updates the generated `wasi/version.h` file with two new `#define`s: * `__wasi_sdk_major__` set to `29` for example for `wasi-sdk-29.0` * `__wasi_sdk_version__` set to `"29.0"` for example for `wasi-sdk-29.0` This'll get set when building wasi-sdk itself through `-DWASI_SDK_VERSION=...` as part of the configuration of libc itself. cc #688
1 parent 06bef3c commit 637bdc9

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ option(BUILD_TESTS "Whether or not to build tests" OFF)
4949
option(SIMD "Whether or not to build simd-enabled intrinsics into wasi-libc" OFF)
5050
option(BUILD_SHARED "Whether or not to build shared libraries" ON)
5151
option(CHECK_SYMBOLS "Whether or not to check the exported symbols of libc.a" OFF)
52+
set(WASI_SDK_VERSION "" CACHE STRING "Version information for wasi-sdk to embed in headers")
5253

5354
if(TARGET_TRIPLE MATCHES "-threads$")
5455
set(WASI p1)

libc-bottom-half/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ add_subdirectory(signal)
66
# =============================================================================
77
# sysroot headers from the bottom half
88
#
9+
if(WASI_SDK_VERSION)
10+
set(__wasi_sdk_version__ ${WASI_SDK_VERSION})
11+
if (WASI_SDK_VERSION MATCHES "([0-9]+)\\..*")
12+
set(__wasi_sdk_major__ ${CMAKE_MATCH_1})
13+
endif()
14+
endif()
915
configure_file(headers/public/wasi/version.h.in ${SYSROOT_INC}/wasi/version.h)
1016
add_custom_target(sysroot-wasi-snapshot-header DEPENDS ${SYSROOT_INC}/wasi/version.h)
1117
add_dependencies(sysroot_inc sysroot-wasi-snapshot-header)

libc-bottom-half/headers/public/wasi/version.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@
1111
#cmakedefine __wasip2__
1212
#cmakedefine __wasip3__
1313

14+
#cmakedefine __wasi_sdk_major__ @__wasi_sdk_major__@
15+
#cmakedefine __wasi_sdk_version__ "@__wasi_sdk_version__@"
16+
1417
#endif /* __WASI_VERSION_H */

0 commit comments

Comments
 (0)