wasm-micro-runtime
wasm-micro-runtime copied to clipboard
Support for clang compilation (and cross-compilation) for native windows platform (--target=x86_64-windows-msvc)
Feature
Just a little fixes in cmake files to make clang builds for windows successful.
Benefit
Possibility for cross-compilation for native windows target --target=x86_64-windows-msvc on other platforms. Useful for CI, automatic builds, etc
Implementation
Patch attached: 0001-Windows-clang-fixes.patch.txt
Check for clang before NOT MINGW to reuse MinGW asms, that successfully works with clang, instead of MSVC's asms. Also, clang parser failed on backslashes with spaces.
@SBKarr thanks for the patch, it seems a good enhancement, could you help submit an PR? BTW, is it better to change to:
if (NOT MINGW)
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.asm)
else ()
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_mingw_x64.s)
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
set_property(SOURCE ${IWASM_COMMON_DIR}/arch/invokeNative_mingw_x64.s PROPERTY LANGUAGE C)
endif ()
endif ()
which sets the property of invokeNative_mingw_x64.s when it is used and the compiler is clang.
If you find this issue and the change above does not work , my Solution:
- ensure you have enabled ASM as language in cmake. Adding to your poject or enable_language(ASM)
Setting the LANGUAGE to ASM like above.
set_property(SOURCE ${IWASM_COMMON_DIR}/arch/invokeNative_mingw_x64.s PROPERTY LANGUAGE ASM)
Tested with Clang 20.1.5 cmake 4 [cmake] -- The ASM compiler identification is Clang with GNU-like command-line [cmake] -- Found assembler: clang.exe