From 9adf90a7f7bc1b5780ef07b4ffe5056dfbb01f48 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Thu, 7 May 2026 16:32:53 -0700 Subject: [PATCH 1/5] Build wasm JIT and crossgen2 R2R of System.Private.CoreLib for browser target Enable 'build.cmd clr+libs -os browser' to: 1. Build clrjit_universal_wasm_x64 (the wasm-targeting JIT for the host platform) 2. Build crossgen2 that can use the wasm JIT 3. Run crossgen2 on System.Private.CoreLib to produce a .wasm R2R output Key changes: - eng/Subsets.props: Remove wasm exclusion from cross-arch build; use ClrWasmJitSubset - src/coreclr/CMakeLists.txt: Early-return for wasm cross-component (only JIT+deps) - src/coreclr/jit/CMakeLists.txt: Create clrjit_universal_wasm_* target - src/coreclr/gcinfo/CMakeLists.txt: Create gcinfo_universal_wasm library - src/coreclr/crossgen-corelib.proj: Enable crossgen2 for browser with wasm format - eng/native/configureplatform.cmake: Guard emscripten flags from cross-component builds - Fix missing PROFILING_SUPPORTED guards in JIT wasm codegen Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/Subsets.props | 6 ++++-- eng/native/configureplatform.cmake | 2 +- src/coreclr/CMakeLists.txt | 17 ++++++++++++++--- src/coreclr/crossgen-corelib.proj | 13 +++++++++++-- src/coreclr/gcinfo/CMakeLists.txt | 1 + src/coreclr/jit/CMakeLists.txt | 4 ++++ src/coreclr/jit/codegenwasm.cpp | 2 ++ src/coreclr/jit/compiler.cpp | 2 ++ src/coreclr/tools/aot/crossgen2/crossgen2.props | 2 +- src/coreclr/utilcode/CMakeLists.txt | 4 +++- 10 files changed, 43 insertions(+), 10 deletions(-) diff --git a/eng/Subsets.props b/eng/Subsets.props index ba8bc03906a1cb..1431cd92a378d9 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -372,7 +372,7 @@ The cross tools are used as part of the build process with the downloaded build tools, so we need to build them for the host architecture and build them as unsanitized binaries. --> - <_BuildAnyCrossArch Condition="('$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(HostOS)' != '$(TargetOS)' or '$(EnableNativeSanitizers)' != '') and '$(TargetArchitecture)' != 'wasm'">true + <_BuildAnyCrossArch Condition="('$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(HostOS)' != '$(TargetOS)' or '$(EnableNativeSanitizers)' != '')">true <_BuildCrossComponents Condition="$(_subset.Contains('+clr.crossarchtools+'))">true <_BuildCrossComponents Condition="'$(ClrRuntimeBuildSubsets)' != '' and ('$(PrimaryRuntimeFlavor)' == 'CoreCLR' or '$(TargetsMobile)' == 'true')">true <_CrossBitwidthBuild Condition="'$(BuildArchitecture)' == 'x64' and ('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'arm')">true @@ -381,7 +381,9 @@ - <_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true' and ($(_subset.Contains('+clr.tools+')) or $(_subset.Contains('+clr.nativecorelib+')) or $(_subset.Contains('+clr.crossarchtools+')))" Include="ClrAllJitsSubset=true" /> + <_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true' and '$(TargetArchitecture)' != 'wasm' and ($(_subset.Contains('+clr.tools+')) or $(_subset.Contains('+clr.nativecorelib+')) or $(_subset.Contains('+clr.crossarchtools+')))" Include="ClrAllJitsSubset=true" /> + + <_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true' and '$(TargetArchitecture)' == 'wasm' and ($(_subset.Contains('+clr.tools+')) or $(_subset.Contains('+clr.nativecorelib+')) or $(_subset.Contains('+clr.crossarchtools+')))" Include="ClrWasmJitSubset=true" /> <_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true' and '$(TargetsWindows)' == 'true'" Include="ClrDebugSubset=true" /> false - - false + false CopyILCoreLib @@ -42,6 +41,11 @@ $(CrossgenTargetName);LinkCoreLibMachO + + wasm + CopyILCoreLib;$(CrossgenTargetName) + + $(CrossgenTargetName);CopyR2RComponentCoreLib @@ -68,6 +72,10 @@ $([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).dylib')) + + $([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).NotReadyYet.wasm')) + + $([MSBuild]::NormalizePath('$(IntermediateOutputPath)', '$(CoreLibAssemblyName).dll')) @@ -149,6 +157,7 @@ $(CrossGenDllCmd) -r:$([MSBuild]::NormalizePath('$(BinDir)', 'IL', '*.dll')) $(CrossGenDllCmd) --targetarch:$(TargetArchitecture) $(CrossGenDllCmd) --obj-format:$(PublishReadyToRunContainerFormat) + $(CrossGenDllCmd) --codegenopt:JitWasmNyiToR2RUnsupported=1 $(CrossGenDllCmd) --composite $(CrossGenDllCmd) --targetos:$(TargetOS) diff --git a/src/coreclr/gcinfo/CMakeLists.txt b/src/coreclr/gcinfo/CMakeLists.txt index 05521608a09a73..9757b755f27173 100644 --- a/src/coreclr/gcinfo/CMakeLists.txt +++ b/src/coreclr/gcinfo/CMakeLists.txt @@ -93,5 +93,6 @@ endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX) if (CLR_CMAKE_TARGET_ARCH_WASM) create_gcinfo_lib(TARGET gcinfo_unix_wasm OS browser ARCH wasm) + create_gcinfo_lib(TARGET gcinfo_universal_wasm OS universal ARCH wasm) install_clr(TARGETS gcinfo_unix_wasm DESTINATIONS sharedFramework COMPONENT runtime) endif (CLR_CMAKE_TARGET_ARCH_WASM) diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index dd83c6891518fe..3dadf640040780 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -719,6 +719,10 @@ if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64) endif(CLR_CMAKE_BUILD_COMMUNITY_ALTJITS EQUAL 1) endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64) +if (CLR_CMAKE_TARGET_ARCH_WASM) + create_standalone_jit(TARGET clrjit_universal_wasm_${ARCH_HOST_NAME} OS universal ARCH wasm) +endif (CLR_CMAKE_TARGET_ARCH_WASM) + if (CLR_CMAKE_TARGET_ARCH_LOONGARCH64) create_standalone_jit(TARGET clrjit_unix_loongarch64_${ARCH_HOST_NAME} OS unix ARCH loongarch64) endif (CLR_CMAKE_TARGET_ARCH_LOONGARCH64) diff --git a/src/coreclr/jit/codegenwasm.cpp b/src/coreclr/jit/codegenwasm.cpp index 0d89746cf97da6..cadcd3ce857632 100644 --- a/src/coreclr/jit/codegenwasm.cpp +++ b/src/coreclr/jit/codegenwasm.cpp @@ -3321,10 +3321,12 @@ void CodeGen::genEmitGSCookieCheck(bool tailCall) NYI_WASM("genEmitGSCookieCheck"); } +#ifdef PROFILING_SUPPORTED void CodeGen::genProfilingLeaveCallback(unsigned helper) { NYI_WASM("genProfilingLeaveCallback"); } +#endif void CodeGen::genSpillVar(GenTree* tree) { diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 24b980ccc8f755..b01372eead07a5 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -3113,10 +3113,12 @@ void Compiler::compInitOptions(JitFlags* jitFlags) printf("OPTIONS: compProcedureSplittingEH = %s\n", dspBool(opts.compProcedureSplittingEH)); // This is rare; don't clutter up the dump with it normally. +#ifdef PROFILING_SUPPORTED if (compProfilerHookNeeded) { printf("OPTIONS: compProfilerHookNeeded = %s\n", dspBool(compProfilerHookNeeded)); } +#endif if (jitFlags->IsSet(JitFlags::JIT_FLAG_BBOPT)) { diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2.props b/src/coreclr/tools/aot/crossgen2/crossgen2.props index 2589fde1ea9da4..825f499e688d04 100644 --- a/src/coreclr/tools/aot/crossgen2/crossgen2.props +++ b/src/coreclr/tools/aot/crossgen2/crossgen2.props @@ -55,7 +55,7 @@ CopyToPublishDirectory="PreserveNewest" ExcludeFromSingleFile="$(PublishSingleFile)" Link="%(FileName)%(Extension)" - Condition="'$(TargetsWasm)' != 'true'" + Condition="'$(TargetsWasm)' != 'true' or '$(CrossHostArch)' != ''" /> Date: Mon, 11 May 2026 10:42:40 -0700 Subject: [PATCH 2/5] Fix ./build.sh clr -os browser for wasm cross-component builds The wasm cross-component build (host=x64, target=wasm) produces libclrjit_universal_wasm_x64.so for crossgen2. Several CMake files used CLR_CMAKE_TARGET_ARCH_WASM where CLR_CMAKE_HOST_ARCH_WASM is correct, since the PAL and minipal code runs on the host, not the target. Changes: - pal/src/CMakeLists.txt: Use HOST_ARCH_WASM for libunwind, arch source selection, and multithreading guards. - clrfeatures.cmake: Disable FEATURE_EVENT_TRACE and FEATURE_EVENTSOURCE_XPLAT for wasm cross-builds (not needed for crossgen2, and eventing dependencies are unavailable). - CMakeLists.txt: Add build_resources(), nativeresources, and dlls/mscorrc to the wasm cross-build early-return block so the JIT can link mscorrc and coreclrpal. - native/minipal/CMakeLists.txt: Include ospagesize.c in cross-builds where host is not wasm (the POSIX implementation is needed on x64). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/coreclr/CMakeLists.txt | 43 ++++++++++++++++++++++++++++++ src/coreclr/clrfeatures.cmake | 4 +-- src/coreclr/pal/src/CMakeLists.txt | 20 +++++++------- src/native/minipal/CMakeLists.txt | 6 +++-- 4 files changed, 59 insertions(+), 14 deletions(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 99211dcdda4a16..1066a1b315ab39 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -189,6 +189,49 @@ endif(FEATURE_STANDALONE_GC) if(CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_TARGET_ARCH_WASM) include_directories("inc") include_directories("minipal") + if (CLR_CMAKE_HOST_UNIX) + include_directories("pal/inc") + include_directories("pal/inc/rt") + include_directories("pal/src/safecrt") + set (NATIVE_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nativeresources) + include_directories(${NATIVE_RESOURCE_DIR}) + + if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set (PROCESS_RC_SCRIPT ${NATIVE_RESOURCE_DIR}/processrc.ps1) + else() + set (PROCESS_RC_SCRIPT ${NATIVE_RESOURCE_DIR}/processrc.sh) + endif() + set (RESOURCE_STRING_HEADER_DIR ${NATIVE_RESOURCE_DIR}) + + function(build_resources SOURCE TARGET_NAME TARGET_FILE) + set_property(SOURCE ${SOURCE} APPEND PROPERTY COMPILE_DEFINITIONS "RC_INVOKED") + set(PREPROCESSED_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.rc.i) + + preprocess_file(${SOURCE} ${PREPROCESSED_SOURCE}) + + set(RESOURCE_ENTRY_ARRAY_CPP ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.cpp) + + if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + add_custom_command( + OUTPUT ${RESOURCE_ENTRY_ARRAY_CPP} + COMMAND powershell -NoProfile -ExecutionPolicy ByPass -File \"${PROCESS_RC_SCRIPT}\" ${PREPROCESSED_SOURCE} ${TARGET_NAME} >${RESOURCE_ENTRY_ARRAY_CPP} + DEPENDS ${PREPROCESSED_SOURCE} ${PROCESS_RC_SCRIPT} + ) + else() + add_custom_command( + OUTPUT ${RESOURCE_ENTRY_ARRAY_CPP} + COMMAND ${PROCESS_RC_SCRIPT} ${PREPROCESSED_SOURCE} ${TARGET_NAME} >${RESOURCE_ENTRY_ARRAY_CPP} + DEPENDS ${PREPROCESSED_SOURCE} ${PROCESS_RC_SCRIPT} + ) + endif() + + include_directories(${RESOURCE_STRING_HEADER_DIR}) + set(${TARGET_FILE} ${RESOURCE_ENTRY_ARRAY_CPP} PARENT_SCOPE) + endfunction() + + add_subdirectory(nativeresources) + add_subdirectory(dlls/mscorrc) + endif (CLR_CMAKE_HOST_UNIX) add_subdirectory(utilcode) add_subdirectory(gcinfo) add_subdirectory(jit) diff --git a/src/coreclr/clrfeatures.cmake b/src/coreclr/clrfeatures.cmake index 0a15452b398e85..0cf973e1e8013c 100644 --- a/src/coreclr/clrfeatures.cmake +++ b/src/coreclr/clrfeatures.cmake @@ -24,14 +24,14 @@ if(CLR_CMAKE_TARGET_TIZEN_LINUX) endif() if(NOT DEFINED FEATURE_EVENT_TRACE) - if (NOT CLR_CMAKE_TARGET_BROWSER) + if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT (CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_TARGET_ARCH_WASM)) # To actually disable FEATURE_EVENT_TRACE, also change clr.featuredefines.props set(FEATURE_EVENT_TRACE 1) endif() endif(NOT DEFINED FEATURE_EVENT_TRACE) if(NOT DEFINED FEATURE_EVENTSOURCE_XPLAT) - if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ANDROID) + if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT (CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_TARGET_ARCH_WASM)) # To actually disable FEATURE_EVENTSOURCE_XPLAT, also change clr.featuredefines.props set(FEATURE_EVENTSOURCE_XPLAT 1) endif() diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 6903d78e15c9de..9e75a724102757 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -10,7 +10,7 @@ elseif (CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_OPENBSD) include_directories(SYSTEM $ENV{ROOTFS_DIR}/usr/local/include) endif() -if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM) +if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_HOST_ARCH_WASM) include_directories(${CLR_SRC_NATIVE_DIR}/external/libunwind/include) include_directories(${CLR_SRC_NATIVE_DIR}/external/libunwind/include/tdep) include_directories(${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind/include) @@ -21,7 +21,7 @@ elseif(NOT CLR_CMAKE_TARGET_APPLE) find_unwind_libs(UNWIND_LIBS) else() add_subdirectory(${CLR_SRC_NATIVE_DIR}/external/libunwind_extras ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind) -endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM) +endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_HOST_ARCH_WASM) include(configure.cmake) @@ -86,9 +86,9 @@ endif(CLR_CMAKE_TARGET_APPLE) if (FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) add_definitions(-DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) endif(FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) -if(NOT CLR_CMAKE_TARGET_ARCH_WASM OR FEATURE_MULTITHREADING) +if(NOT CLR_CMAKE_HOST_ARCH_WASM OR FEATURE_MULTITHREADING) add_definitions(-DFEATURE_MULTITHREADING) -endif(NOT CLR_CMAKE_TARGET_ARCH_WASM OR FEATURE_MULTITHREADING) +endif(NOT CLR_CMAKE_HOST_ARCH_WASM OR FEATURE_MULTITHREADING) add_definitions(-DLP64COMPATIBLE) add_definitions(-DCORECLR) add_definitions(-DPIC) @@ -116,7 +116,7 @@ endif(CLR_CMAKE_TARGET_HAIKU) # turn off capability to remove unused functions (which was enabled in debug build with sanitizers) set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--no-gc-sections") -if (NOT CLR_CMAKE_TARGET_ARCH_WASM) +if (NOT CLR_CMAKE_HOST_ARCH_WASM) set(ARCH_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/context2.S arch/${PAL_ARCH_SOURCES_DIR}/debugbreak.S @@ -124,18 +124,18 @@ if (NOT CLR_CMAKE_TARGET_ARCH_WASM) ) endif() -if (CLR_CMAKE_TARGET_ARCH_WASM) +if (CLR_CMAKE_HOST_ARCH_WASM) set(PLATFORM_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/stubs.cpp ) endif() -if(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_ARCH_WASM) +if(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_HOST_ARCH_WASM) list(APPEND PLATFORM_SOURCES arch/${PAL_ARCH_SOURCES_DIR}/callsignalhandlerwrapper.S arch/${PAL_ARCH_SOURCES_DIR}/signalhandlerhelper.cpp ) -endif(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_ARCH_WASM) +endif(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_HOST_ARCH_WASM) if(CLR_CMAKE_HOST_ARCH_ARM) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -215,9 +215,9 @@ set_source_files_properties( INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/../inc/rt ) -if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM) +if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_HOST_ARCH_WASM) set(LIBUNWIND_OBJECTS $) -endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM) +endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_HOST_ARCH_WASM) add_library(coreclrpal_objects OBJECT diff --git a/src/native/minipal/CMakeLists.txt b/src/native/minipal/CMakeLists.txt index af1990a9909fc4..21a57a385ae2ec 100644 --- a/src/native/minipal/CMakeLists.txt +++ b/src/native/minipal/CMakeLists.txt @@ -19,8 +19,10 @@ set(SOURCES # ospagesize is provided inline in the header on Windows and WASM; the .c file # only contains the POSIX implementation. Including it on those platforms would # produce a redefinition error (mono builds for wasi/browser set HOST_WASM but -# not CLR_CMAKE_TARGET_ARCH_WASM, so check both). -if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_ARCH_WASM AND NOT HOST_WASM) +# not CLR_CMAKE_TARGET_ARCH_WASM, so check both). In cross-component builds +# (e.g. host=x64, target=wasm) the code runs on the host, so we still need the +# POSIX implementation; only skip when the HOST is actually wasm. +if(NOT WIN32 AND NOT HOST_WASM AND NOT (CLR_CMAKE_TARGET_ARCH_WASM AND NOT CLR_CROSS_COMPONENTS_BUILD)) list(APPEND SOURCES ospagesize.c) endif() From 28df490e661fee0b30883980153ca2c016d8e230 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Mon, 11 May 2026 10:55:10 -0700 Subject: [PATCH 3/5] Fix missing BBF_PROF_WEIGHT in wasm EH dispatch blocks Use setBBProfileWeight(BB_ZERO_WEIGHT) instead of bbSetRunRarely() for the switch and rethrow blocks created by the wasm EH pass. bbSetRunRarely() only scales the weight to zero without setting the BBF_PROF_WEIGHT flag, which causes a checked build assertion when PGO data (.mibc) is applied. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/coreclr/jit/fgwasm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/fgwasm.cpp b/src/coreclr/jit/fgwasm.cpp index 66fb058fc935f3..267105c653c049 100644 --- a/src/coreclr/jit/fgwasm.cpp +++ b/src/coreclr/jit/fgwasm.cpp @@ -2313,8 +2313,8 @@ void Compiler::fgWasmEhTransformTry(ArrayStack* catchRetBlocks, BasicBlock* const rethrowBlock = fgNewBBinRegion(BBJ_THROW, biasedEnclosingTryIndex, biasedEnclosingHndIndex, switchBlock); - switchBlock->bbSetRunRarely(); - rethrowBlock->bbSetRunRarely(); + switchBlock->setBBProfileWeight(BB_ZERO_WEIGHT); + rethrowBlock->setBBProfileWeight(BB_ZERO_WEIGHT); // Split the header so we can branch to the switch on exception. // From 29790ebba95022cf15d317cfbe7763e9d2d0554e Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Mon, 11 May 2026 13:02:13 -0700 Subject: [PATCH 4/5] Enable JitWasmNyiToR2RUnsupported in release builds NYI_WASM was always fatal in release builds because: 1. The JitWasmNyiToR2RUnsupported config was CONFIG_INTEGER (debug-only) 2. The NYI_WASM macro had an #if DEBUG guard that fell back to NYIRAW Change CONFIG_INTEGER to RELEASE_CONFIG_INTEGER and remove the #if DEBUG split so NYI_WASM can gracefully skip unsupported methods via implReadyToRunUnsupported() in all build configurations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/coreclr/jit/error.h | 4 ---- src/coreclr/jit/jitconfigvalues.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/coreclr/jit/error.h b/src/coreclr/jit/error.h index cf2103620f2c9f..6c533a5ccc50b9 100644 --- a/src/coreclr/jit/error.h +++ b/src/coreclr/jit/error.h @@ -226,13 +226,9 @@ extern void notYetImplemented(const char* msg, const char* file, unsigned line); #define NYI_LOONGARCH64(msg) do { } while (0) #define NYI_RISCV64(msg) do { } while (0) -#if DEBUG #define NYI_WASM(msg) do { if (JitConfig.JitWasmNyiToR2RUnsupported() > 0) \ { JITDUMP("NYI_WASM: " msg); implReadyToRunUnsupported(); } \ else { NYIRAW("NYI_WASM: " msg); } } while (0) -#else -#define NYI_WASM(msg) NYIRAW("NYI_WASM: " msg) -#endif // DEBUG #else diff --git a/src/coreclr/jit/jitconfigvalues.h b/src/coreclr/jit/jitconfigvalues.h index a87b20f8491c78..88ac0fe83e4924 100644 --- a/src/coreclr/jit/jitconfigvalues.h +++ b/src/coreclr/jit/jitconfigvalues.h @@ -885,7 +885,7 @@ CONFIG_INTEGER(JitDispIns, "JitDispIns", 0) #if defined(TARGET_WASM) // Set this to 1 to turn NYI_WASM into R2R unsupported failures instead of asserts. -CONFIG_INTEGER(JitWasmNyiToR2RUnsupported, "JitWasmNyiToR2RUnsupported", 0) +RELEASE_CONFIG_INTEGER(JitWasmNyiToR2RUnsupported, "JitWasmNyiToR2RUnsupported", 0) // Specify methods that will fail with R2R unsupported after codegen. // Useful for bypassing methods that compile cleanly but have invalid Wasm codegen. CONFIG_STRING(JitR2RUnsupportedRange, "JitR2RUnsupportedRange") From f1b24278f4c330c4d7324524b019c5b814597f7b Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Mon, 11 May 2026 14:04:34 -0700 Subject: [PATCH 5/5] Use inheritWeightPercentage for wasm EH dispatch blocks Address review feedback: use inheritWeightPercentage(regionEntryBlock, 0) instead of setBBProfileWeight(BB_ZERO_WEIGHT). This properly propagates the BBF_PROF_WEIGHT flag from the source block and handles both PGO and non-PGO cases correctly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/coreclr/jit/fgwasm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/fgwasm.cpp b/src/coreclr/jit/fgwasm.cpp index 267105c653c049..d695e77b5c5b10 100644 --- a/src/coreclr/jit/fgwasm.cpp +++ b/src/coreclr/jit/fgwasm.cpp @@ -2313,8 +2313,8 @@ void Compiler::fgWasmEhTransformTry(ArrayStack* catchRetBlocks, BasicBlock* const rethrowBlock = fgNewBBinRegion(BBJ_THROW, biasedEnclosingTryIndex, biasedEnclosingHndIndex, switchBlock); - switchBlock->setBBProfileWeight(BB_ZERO_WEIGHT); - rethrowBlock->setBBProfileWeight(BB_ZERO_WEIGHT); + switchBlock->inheritWeightPercentage(regionEntryBlock, 0); + rethrowBlock->inheritWeightPercentage(regionEntryBlock, 0); // Split the header so we can branch to the switch on exception. //