Skip to content

Commit b0075f9

Browse files
authored
Add some CMake guards when building the sysroot (#462)
* Require that the compiler is Clang, for example gcc and msvc cannot compile to WebAssembly. * Require that the Clang version is above the minimum threshold. Unsure what the minimum threshold is at this time so I've set it to 18.0.0
1 parent 0de1b48 commit b0075f9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmake/wasi-sdk-sysroot.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ if(NOT CMAKE_BUILD_TYPE)
55
set(CMAKE_BUILD_TYPE RelWithDebInfo)
66
endif()
77

8+
if(NOT CMAKE_C_COMPILER_ID MATCHES Clang)
9+
message(FATAL_ERROR "C compiler ${CMAKE_C_COMPILER} is not `Clang`, it is ${CMAKE_C_COMPILER_ID}")
10+
endif()
11+
12+
set(minimum_clang_required 18.0.0)
13+
14+
if(CMAKE_C_COMPILER_VERSION VERSION_LESS ${minimum_clang_required})
15+
message(FATAL_ERROR "compiler version ${CMAKE_C_COMPILER_VERSION} is less than the required version ${minimum_clang_required}")
16+
endif()
17+
818
find_program(MAKE make REQUIRED)
919

1020
option(WASI_SDK_DEBUG_PREFIX_MAP "Pass `-fdebug-prefix-map` for built artifacts" ON)

0 commit comments

Comments
 (0)