wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Support for clang compilation (and cross-compilation) for native windows platform (--target=x86_64-windows-msvc)

Open SBKarr opened this issue 1 year ago • 2 comments

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 avatar Jul 04 '24 00:07 SBKarr

@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.

wenyongh avatar Jul 11 '24 07:07 wenyongh

If you find this issue and the change above does not work , my Solution:

  1. 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

gajanak avatar May 22 '25 17:05 gajanak