diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c36d62d4..6d2630581 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,7 @@ option(BUILD_TESTS "Whether or not to build tests" OFF) option(SIMD "Whether or not to build simd-enabled intrinsics into wasi-libc" OFF) option(BUILD_SHARED "Whether or not to build shared libraries" ON) option(CHECK_SYMBOLS "Whether or not to check the exported symbols of libc.a" OFF) +set(WASI_SDK_VERSION "" CACHE STRING "Version information for wasi-sdk to embed in headers") if(TARGET_TRIPLE MATCHES "-threads$") set(WASI p1) diff --git a/libc-bottom-half/CMakeLists.txt b/libc-bottom-half/CMakeLists.txt index bd1cb009e..999474805 100644 --- a/libc-bottom-half/CMakeLists.txt +++ b/libc-bottom-half/CMakeLists.txt @@ -6,6 +6,12 @@ add_subdirectory(signal) # ============================================================================= # sysroot headers from the bottom half # +if(WASI_SDK_VERSION) + set(__wasi_sdk_version__ ${WASI_SDK_VERSION}) + if (WASI_SDK_VERSION MATCHES "([0-9]+)\\..*") + set(__wasi_sdk_major__ ${CMAKE_MATCH_1}) + endif() +endif() configure_file(headers/public/wasi/version.h.in ${SYSROOT_INC}/wasi/version.h) add_custom_target(sysroot-wasi-snapshot-header DEPENDS ${SYSROOT_INC}/wasi/version.h) add_dependencies(sysroot_inc sysroot-wasi-snapshot-header) diff --git a/libc-bottom-half/headers/public/wasi/version.h.in b/libc-bottom-half/headers/public/wasi/version.h.in index 54e060a9d..2cca21efc 100644 --- a/libc-bottom-half/headers/public/wasi/version.h.in +++ b/libc-bottom-half/headers/public/wasi/version.h.in @@ -11,4 +11,7 @@ #cmakedefine __wasip2__ #cmakedefine __wasip3__ +#cmakedefine __wasi_sdk_major__ @__wasi_sdk_major__@ +#cmakedefine __wasi_sdk_version__ "@__wasi_sdk_version__@" + #endif /* __WASI_VERSION_H */