From 07088a9ea5f029332acb0d56f655b73635922143 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 23 Apr 2026 16:52:18 +0200 Subject: [PATCH 1/3] prep --- eng/native/gen-buildsys.cmd | 4 ++-- src/mono/browser/browser.proj | 15 +++++++++++---- src/mono/browser/runtime/CMakeLists.txt | 2 +- src/mono/mono/mini/llvm-intrinsics.h | 9 ++------- src/mono/mono/mini/simd-intrinsics.c | 8 ++++---- src/mono/wasi/wasi.proj | 2 +- src/mono/wasm/build/WasmApp.Common.targets | 4 ++-- src/native/libs/CMakeLists.txt | 1 + .../pal_icushim_static.c | 14 ++++++++++---- src/native/libs/System.Native/pal_networking.c | 4 ++++ src/native/libs/System.Native/pal_threading.c | 5 +++++ 11 files changed, 43 insertions(+), 25 deletions(-) diff --git a/eng/native/gen-buildsys.cmd b/eng/native/gen-buildsys.cmd index 0f5cccf8c89aed..d9f45f46e3776f 100644 --- a/eng/native/gen-buildsys.cmd +++ b/eng/native/gen-buildsys.cmd @@ -20,9 +20,9 @@ if /i "%__Os%" == "browser" ( echo Error: Should set EMSDK_PATH environment variable pointing to emsdk root. exit /B 1 ) - set EMSDK_QUIET=1 && call "%__repoRoot%\src\mono\browser\emsdk\emsdk_env" + set "EMSDK_QUIET=1" && call "%__repoRoot%\src\mono\browser\emsdk\emsdk_env.cmd" ) else ( - set EMSDK_QUIET=1 && call "%EMSDK_PATH%\emsdk_env" + set "EMSDK_QUIET=1" && call "%EMSDK_PATH%\emsdk_env.cmd" ) ) diff --git a/src/mono/browser/browser.proj b/src/mono/browser/browser.proj index 6fc1288c56a3b5..b9f72ca324b0fd 100644 --- a/src/mono/browser/browser.proj +++ b/src/mono/browser/browser.proj @@ -132,6 +132,16 @@ + + + + + + + + + + @@ -236,10 +246,7 @@ - - - - <_EmccLinkFlags Include="-s TEXTDECODER=0"/> + diff --git a/src/mono/browser/runtime/CMakeLists.txt b/src/mono/browser/runtime/CMakeLists.txt index d8e1bfab597139..788707244c11bd 100644 --- a/src/mono/browser/runtime/CMakeLists.txt +++ b/src/mono/browser/runtime/CMakeLists.txt @@ -44,7 +44,7 @@ set(ignoreMeEmsdkPath "${EMSDK_PATH}") if(CMAKE_BUILD_TYPE STREQUAL "Release") add_custom_command(TARGET dotnet.native - POST_BUILD COMMAND ${EMSDK_PATH}/bin/wasm-opt --enable-exception-handling --enable-simd --enable-bulk-memory ${CONFIGURATION_WASM_OPT_FLAGS} --strip-dwarf ${NATIVE_BIN_DIR}/dotnet.native.wasm -o ${NATIVE_BIN_DIR}/dotnet.native.wasm + POST_BUILD COMMAND ${EMSDK_PATH}/bin/wasm-opt --enable-exception-handling --enable-simd --enable-bulk-memory --enable-nontrapping-float-to-int ${CONFIGURATION_WASM_OPT_FLAGS} --strip-dwarf ${NATIVE_BIN_DIR}/dotnet.native.wasm -o ${NATIVE_BIN_DIR}/dotnet.native.wasm COMMENT "Stripping debug symbols from dotnet.native.wasm using wasm-opt") endif() diff --git a/src/mono/mono/mini/llvm-intrinsics.h b/src/mono/mono/mini/llvm-intrinsics.h index d1cb974e41e118..dfb8953e80039c 100644 --- a/src/mono/mono/mini/llvm-intrinsics.h +++ b/src/mono/mono/mini/llvm-intrinsics.h @@ -247,13 +247,12 @@ INTRINS(AESNI_AESDECLAST, x86_aesni_aesdeclast, X86) INTRINS(AESNI_AESENC, x86_aesni_aesenc, X86) INTRINS(AESNI_AESENCLAST, x86_aesni_aesenclast, X86) INTRINS(AESNI_AESIMC, x86_aesni_aesimc, X86) - +#endif +#if defined(TARGET_AMD64) || defined(TARGET_X86) || defined(TARGET_WASM) INTRINS_OVR(SSE_SSUB_SATI8, ssub_sat, Generic, v128_i1_t) INTRINS_OVR(SSE_USUB_SATI8, usub_sat, Generic, v128_i1_t) INTRINS_OVR(SSE_SSUB_SATI16, ssub_sat, Generic, v128_i2_t) INTRINS_OVR(SSE_USUB_SATI16, usub_sat, Generic, v128_i2_t) -#endif -#if defined(TARGET_AMD64) || defined(TARGET_X86) || defined(TARGET_WASM) INTRINS_OVR(SSE_SADD_SATI8, sadd_sat, Generic, v128_i1_t) INTRINS_OVR(SSE_UADD_SATI8, uadd_sat, Generic, v128_i1_t) INTRINS_OVR(SSE_SADD_SATI16, sadd_sat, Generic, v128_i2_t) @@ -298,10 +297,6 @@ INTRINS_OVR(WASM_PMAX_V4, fabs, Generic, sse_r4_t) INTRINS_OVR(WASM_PMAX_V2, fabs, Generic, sse_r8_t) INTRINS(WASM_Q15MULR_SAT_SIGNED, wasm_q15mulr_sat_signed, Wasm) INTRINS(WASM_SHUFFLE, wasm_shuffle, Wasm) -INTRINS_OVR(WASM_SUB_SAT_SIGNED_V16, wasm_sub_sat_signed, Wasm, sse_i1_t) -INTRINS_OVR(WASM_SUB_SAT_SIGNED_V8, wasm_sub_sat_signed, Wasm, sse_i2_t) -INTRINS_OVR(WASM_SUB_SAT_UNSIGNED_V16, wasm_sub_sat_unsigned, Wasm, sse_i1_t) -INTRINS_OVR(WASM_SUB_SAT_UNSIGNED_V8, wasm_sub_sat_unsigned, Wasm, sse_i2_t) INTRINS(WASM_SWIZZLE, wasm_swizzle, Wasm) INTRINS(WASM_GET_EXCEPTION, wasm_get_exception, Wasm) INTRINS(WASM_GET_EHSELECTOR, wasm_get_ehselector, Wasm) diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index 66ba056611ece4..36dcf1a4f29990 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -6823,16 +6823,16 @@ emit_wasm_supported_intrinsics ( switch (arg0_type) { case MONO_TYPE_I1: - c0 = INTRINS_WASM_SUB_SAT_SIGNED_V16; + c0 = INTRINS_SSE_SSUB_SATI8; break; case MONO_TYPE_I2: - c0 = INTRINS_WASM_SUB_SAT_SIGNED_V8; + c0 = INTRINS_SSE_SSUB_SATI16; break; case MONO_TYPE_U1: - c0 = INTRINS_WASM_SUB_SAT_UNSIGNED_V16; + c0 = INTRINS_SSE_USUB_SATI8; break; case MONO_TYPE_U2: - c0 = INTRINS_WASM_SUB_SAT_UNSIGNED_V8; + c0 = INTRINS_SSE_USUB_SATI16; break; } diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 826ed0b6f28db9..0e8cbbd53ee43b 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -58,7 +58,7 @@ - + diff --git a/src/mono/wasm/build/WasmApp.Common.targets b/src/mono/wasm/build/WasmApp.Common.targets index 01f96edb3f6015..86c53bcec5609c 100644 --- a/src/mono/wasm/build/WasmApp.Common.targets +++ b/src/mono/wasm/build/WasmApp.Common.targets @@ -930,8 +930,8 @@ <_WasmOptPostLinkFileName Condition="'$([System.IO.Path]::IsPathRooted($(_WasmOptPostLinkFileName)))' != 'true'">$([System.IO.Path]::Combine($(_WasmIntermediateOutputPath), $(_WasmOptPostLinkFileName))) - - + diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index cd45a5fa9c7288..0ceeaef498484d 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -150,6 +150,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) add_compile_options(-Wno-unsafe-buffer-usage) add_compile_options(-Wno-cast-function-type-strict) + add_compile_options(-Wno-c++-keyword) endif () endif () diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index 54560d29049981..385ca51cb3d889 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -25,6 +25,11 @@ static int32_t isLoaded = 0; static int32_t isDataSet = 0; +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wjump-misses-init" +#endif + static void log_shim_error(const char* format, ...) { va_list args; @@ -83,7 +88,7 @@ int32_t mono_wasi_load_icu_data(const void* pData) static int32_t load_icu_data(const void* pData) { - UErrorCode status = 0; + UErrorCode status = U_ZERO_ERROR; udata_setCommonData(pData, &status); if (U_FAILURE(status)) @@ -108,6 +113,7 @@ static const char * cstdlib_load_icu_data(const char *path) { char *file_buf = NULL; + long file_buf_size = 0; FILE *fp = fopen(path, "rb"); if (fp == NULL) @@ -122,7 +128,7 @@ cstdlib_load_icu_data(const char *path) goto error; } - long file_buf_size = ftell(fp); + file_buf_size = ftell(fp); if (file_buf_size == -1) { @@ -130,7 +136,7 @@ cstdlib_load_icu_data(const char *path) goto error; } - file_buf = malloc(sizeof(char) * (unsigned long)(file_buf_size + 1)); + file_buf = (char *)malloc(sizeof(char) * (unsigned long)(file_buf_size + 1)); if (file_buf == NULL) { @@ -223,7 +229,7 @@ int32_t GlobalizationNative_LoadICU(void) } #endif - UErrorCode status = 0; + UErrorCode status = U_ZERO_ERROR; UVersionInfo version; // Request the CLDR version to perform basic ICU initialization and find out // whether it worked. diff --git a/src/native/libs/System.Native/pal_networking.c b/src/native/libs/System.Native/pal_networking.c index 7f13890ca61fe3..10b11cc1b4f969 100644 --- a/src/native/libs/System.Native/pal_networking.c +++ b/src/native/libs/System.Native/pal_networking.c @@ -78,6 +78,10 @@ extern int getdomainname(char *name, int namelen); #include #endif +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wjump-misses-init" +#endif #if HAVE_KQUEUE #if KEVENT_HAS_VOID_UDATA diff --git a/src/native/libs/System.Native/pal_threading.c b/src/native/libs/System.Native/pal_threading.c index 3085ff6b23a57a..5eee09e7328ec5 100644 --- a/src/native/libs/System.Native/pal_threading.c +++ b/src/native/libs/System.Native/pal_threading.c @@ -24,6 +24,11 @@ #endif #include +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wjump-misses-init" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // LowLevelMonitor - Represents a non-recursive mutex and condition From 2a93bc3d1225eb0d9ecf4f12862d63ba2bf51c22 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 23 Apr 2026 23:37:21 +0200 Subject: [PATCH 2/3] more --- eng/native/configureplatform.cmake | 3 +-- src/coreclr/hosts/corerun/CMakeLists.txt | 2 +- src/mono/browser/build/BrowserWasmApp.CoreCLR.targets | 2 +- src/native/corehost/browserhost/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 18952687829684..f89df1824bf4a3 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -504,10 +504,9 @@ else() if(CLR_CMAKE_TARGET_BROWSER) add_link_options(-fwasm-exceptions) add_link_options(-Wno-unused-command-line-argument) - add_link_options(-Wl,-error-limit=0) + add_link_options(-Wl,--error-limit=0) add_link_options(-nostdlib) - add_link_options(-lbulkmemory) add_link_options(-lstubs) add_link_options(-lc) add_link_options(-lmalloc) diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index 58f715de6fdfe1..fff6415cc16f8c 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -89,7 +89,7 @@ else() -sEXPORTED_FUNCTIONS=_main,___stack_pointer,${CMAKE_EMCC_EXPORTED_FUNCTIONS} -sEXPORT_NAME=createDotnetRuntime -sENVIRONMENT=node,shell,web - -Wl,-error-limit=0) + -Wl,--error-limit=0) if (CORERUN_IN_BROWSER) # Node.js doesn't have good support for WASM_BIGINT diff --git a/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets index 02f69b8e2be52c..ab69d2c3d8465b 100644 --- a/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets +++ b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets @@ -532,7 +532,7 @@ <_EmccLinkStepArgs Include="$(EmccExtraLDFlags)" /> - <_EmccLinkStepArgs Include="-Wl,-error-limit=0" /> + <_EmccLinkStepArgs Include="-Wl,--error-limit=0" /> diff --git a/src/native/corehost/browserhost/CMakeLists.txt b/src/native/corehost/browserhost/CMakeLists.txt index a5b68de643fc0f..2249627f393f8d 100644 --- a/src/native/corehost/browserhost/CMakeLists.txt +++ b/src/native/corehost/browserhost/CMakeLists.txt @@ -121,7 +121,7 @@ target_link_options(browserhost PRIVATE -sEXPORT_NAME=createDotnetRuntime -sENVIRONMENT=web,webview,worker,node,shell --emit-symbol-map - -Wl,-error-limit=0) + -Wl,--error-limit=0) target_link_libraries(browserhost PRIVATE BrowserHost-Static From 8bd56bb57b9a89e96e957c130838cc1da9501b34 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 23 Apr 2026 23:44:27 +0200 Subject: [PATCH 3/3] keep bulk --- eng/native/configureplatform.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index f89df1824bf4a3..7ec69f328b6531 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -507,6 +507,7 @@ else() add_link_options(-Wl,--error-limit=0) add_link_options(-nostdlib) + add_link_options(-lbulkmemory) add_link_options(-lstubs) add_link_options(-lc) add_link_options(-lmalloc)