From 383dbce282c093b45089e9922fddc9722d2223ad Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 13 Oct 2025 15:41:41 +0200 Subject: [PATCH 01/22] wip --- eng/Subsets.props | 4 +- eng/liveBuilds.targets | 21 +++-- eng/native.props | 23 +++++ src/coreclr/CMakeLists.txt | 3 +- .../dlls/mscoree/coreclr/CMakeLists.txt | 2 + src/coreclr/gcinfo/CMakeLists.txt | 1 + src/coreclr/hosts/corerun/CMakeLists.txt | 4 +- src/coreclr/minipal/Unix/CMakeLists.txt | 4 + src/coreclr/nativeresources/CMakeLists.txt | 4 + src/coreclr/pal/src/CMakeLists.txt | 4 + src/coreclr/runtime.proj | 12 +-- src/libraries/externals.csproj | 2 +- .../corehost/browserhost/CMakeLists.txt | 58 ++++++------- src/native/corehost/browserhost/ReadMe.md | 7 +- .../corehost/browserhost/configure.cmake | 6 -- .../browserhost/{native.rc => empty.c} | 5 +- .../corehost/browserhost/host/CMakeLists.txt | 39 +++++++++ .../browserhost/{ => host}/browserhost.cpp | 0 .../browserhost/{ => host}/config.h.in | 3 - .../corehost/browserhost/host/configure.cmake | 4 + .../{ => host}/libBrowserHost.footer.js | 0 .../browserhost/sample/CMakeLists.txt | 11 +-- src/native/corehost/build.cmd | 7 +- src/native/corehost/corehost.proj | 19 +++-- src/native/libs/CMakeLists.txt | 17 ++-- .../libs/Common/JavaScript/CMakeLists.txt | 74 ++++++++++++++++ .../CMakeLists.txt | 3 +- .../CMakeLists.txt | 48 ++++++----- .../entrypoints.c | 5 ++ .../extra_libs.cmake | 2 +- .../libs/System.Native.Browser/CMakeLists.txt | 84 +------------------ src/native/libs/System.Native/CMakeLists.txt | 2 + .../CMakeLists.txt | 1 + src/native/libs/build-native.proj | 17 +--- src/native/minipal/CMakeLists.txt | 2 + src/native/rollup.config.defines.js | 3 +- src/native/rollup.config.js | 19 +++-- 37 files changed, 301 insertions(+), 219 deletions(-) create mode 100644 eng/native.props delete mode 100644 src/native/corehost/browserhost/configure.cmake rename src/native/corehost/browserhost/{native.rc => empty.c} (59%) create mode 100644 src/native/corehost/browserhost/host/CMakeLists.txt rename src/native/corehost/browserhost/{ => host}/browserhost.cpp (100%) rename src/native/corehost/browserhost/{ => host}/config.h.in (75%) create mode 100644 src/native/corehost/browserhost/host/configure.cmake rename src/native/corehost/browserhost/{ => host}/libBrowserHost.footer.js (100%) create mode 100644 src/native/libs/Common/JavaScript/CMakeLists.txt diff --git a/eng/Subsets.props b/eng/Subsets.props index 5f592075c54e3f..77c476e801a193 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -54,7 +54,7 @@ <_SdkToolsSupportedOS Condition="'$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">true - <_SdkToolsSupportedArch Condition="'$(TargetArchitecture)' != 'armel' and '$(TargetsWasm)' != 'true'">true + <_SdkToolsSupportedArch Condition="'$(TargetArchitecture)' != 'armel'">true true <_UseNativeAotForComponentsCrossOS Condition="'$(CrossBuild)' == 'true' and '$(_hostArchitecture)' == '$(_targetArchitecture)' and '$(_hostOS)' != 'windows'">true @@ -365,7 +365,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 '$(TargetsWasm)' != 'true'">true + <_BuildAnyCrossArch Condition="('$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(HostOS)' != '$(TargetOS)' or '$(EnableNativeSanitizers)' != '') and '$(TargetArchitecture)' != 'wasm'">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 diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets index 29f99870456374..135b98b15aac0c 100644 --- a/eng/liveBuilds.targets +++ b/eng/liveBuilds.targets @@ -215,7 +215,21 @@ $(LibrariesNativeArtifactsPath)*.dex; $(LibrariesNativeArtifactsPath)*.jar;" IsNative="true" /> - + + + - + + + + + <_RuntimeVariant /> + <_RuntimeVariant Condition="'$(WasmEnableThreads)' == 'true'">-threads + + <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != '' and '$(TargetsWasm)' == 'true'">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native + <_TzdDir Condition="'$(PkgSystem_Runtime_TimeZoneData)' != '' and '$(TargetsWasm)' == 'true'">$([MSBuild]::NormalizePath('$(PkgSystem_Runtime_TimeZoneData)', 'contentFiles', 'any', 'any', 'data')) + + + + <_NativeCMakeArg Condition="'$(_IcuDir)' != ''" Include="-cmakeargs "-DCMAKE_ICU_DIR=$(_IcuDir)"" /> + <_NativeCMakeArg Condition="'$(_TzdDir)' != ''" Include="-cmakeargs "-DCMAKE_TZD_DIR=$(_TzdDir)"" /> + <_NativeCMakeArg Include="-cmakeargs "-DCMAKE_PRODUCT_VERSION=$(ProductVersion)"" /> + <_NativeCMakeArg Include="-cmakeargs "-DCMAKE_CONTINUOUS_INTEGRATION_BUILD=$(ContinuousIntegrationBuild)"" /> + <_NativeCMakeArg Condition="'$(TargetsBrowser)' == 'true' and '$(RuntimeFlavor)' == 'CoreCLR'" Include="-cmakeargs "-DSTATIC_LIBS_ONLY=1"" /> + + + diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 2bc06d83bc8495..967d8253a4d59e 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -78,7 +78,8 @@ else() set(GEN_PINVOKE 0) # WASM-TODO should we start using System.Native.Browser and System.Runtime.InteropServices.JavaScript.Native also for Mono ? set(BUILD_LIBS_NATIVE_BROWSER 1) - add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost browserhost) + set(STATIC_LIB_DESTINATION $ENV{__CMakeBinDir}/libs-native) + add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost corehost) add_dependencies(runtime browserhost) endif() endif() diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 7f497cd6f3a00b..504ffc0c881e4b 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -265,6 +265,8 @@ endif(CLR_CMAKE_TARGET_WIN32) # add the install targets if(NOT CLR_CMAKE_HOST_ARCH_WASM) install_clr(TARGETS coreclr DESTINATIONS . sharedFramework COMPONENT runtime) +else() + install_clr(TARGETS coreclr_static DESTINATIONS . sharedFramework COMPONENT runtime) endif(NOT CLR_CMAKE_HOST_ARCH_WASM) if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_ARCH_WASM) diff --git a/src/coreclr/gcinfo/CMakeLists.txt b/src/coreclr/gcinfo/CMakeLists.txt index b809dac02f086a..a652648f32a689 100644 --- a/src/coreclr/gcinfo/CMakeLists.txt +++ b/src/coreclr/gcinfo/CMakeLists.txt @@ -92,4 +92,5 @@ 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) + install_clr(TARGETS gcinfo_unix_wasm DESTINATIONS sharedFramework COMPONENT runtime) endif (CLR_CMAKE_TARGET_ARCH_WASM) diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index f41afefcd30fc0..035a55778461de 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -63,9 +63,9 @@ else() target_link_libraries(corerun PRIVATE System.Native.Browser-Static) set(JS_SYSTEM_NATIVE_BROWSER - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js") + "${STATIC_LIB_DESTINATION}/libSystem.Native.Browser.js") set(JS_SYSTEM_BROWSER_UTILS - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Browser.Utils.js") + "${STATIC_LIB_DESTINATION}/libSystem.Browser.Utils.js") set(JS_CORE_RUN_PRE "${CMAKE_CURRENT_SOURCE_DIR}/wasm/libCorerun.pre.js") set_target_properties(corerun PROPERTIES diff --git a/src/coreclr/minipal/Unix/CMakeLists.txt b/src/coreclr/minipal/Unix/CMakeLists.txt index baa9c41161813a..31528782153f54 100644 --- a/src/coreclr/minipal/Unix/CMakeLists.txt +++ b/src/coreclr/minipal/Unix/CMakeLists.txt @@ -14,3 +14,7 @@ add_library(coreclrminipal ) target_link_libraries(coreclrminipal PRIVATE minipal) + +if (CLR_CMAKE_TARGET_ARCH_WASM) + install_clr(TARGETS coreclrminipal DESTINATIONS sharedFramework COMPONENT runtime) +endif (CLR_CMAKE_TARGET_ARCH_WASM) diff --git a/src/coreclr/nativeresources/CMakeLists.txt b/src/coreclr/nativeresources/CMakeLists.txt index 7dba113d91ea3b..7d9dc018f5d374 100644 --- a/src/coreclr/nativeresources/CMakeLists.txt +++ b/src/coreclr/nativeresources/CMakeLists.txt @@ -11,3 +11,7 @@ add_library_clr(nativeresourcestring ) install_clr (TARGETS nativeresourcestring DESTINATIONS lib) + +if (CLR_CMAKE_TARGET_ARCH_WASM) + install_clr(TARGETS nativeresourcestring DESTINATIONS sharedFramework COMPONENT runtime) +endif (CLR_CMAKE_TARGET_ARCH_WASM) diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index ac17e9a6c885e9..ac22c0d1924263 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -361,3 +361,7 @@ endif(FEATURE_EVENT_TRACE) # Install the static PAL library for VS install_clr (TARGETS coreclrpal DESTINATIONS lib) + +if (CLR_CMAKE_TARGET_ARCH_WASM) + install_clr(TARGETS coreclrpal DESTINATIONS sharedFramework COMPONENT runtime) +endif (CLR_CMAKE_TARGET_ARCH_WASM) diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index f0bef340c0d06e..2baed187441d3f 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -4,20 +4,16 @@ <_BuildNativeTargetOS>$(TargetOS) <_BuildNativeTargetOS Condition="'$(TargetsLinuxBionic)' == 'true'">linux-bionic true - - <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != '' and '$(TargetsBrowser)' == 'true'">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native - <_TzdDir Condition="'$(PkgSystem_Runtime_TimeZoneData)' != ''">$([MSBuild]::NormalizePath('$(PkgSystem_Runtime_TimeZoneData)', 'contentFiles', 'any', 'any', 'data')) - - + - + @@ -54,8 +50,6 @@ <_CoreClrBuildArg Condition="'$(BuildSubdirectory)' != ''" Include="-subdir $(BuildSubdirectory)" /> <_CoreClrBuildArg Include="-cmakeargs "-DCLR_DOTNET_HOST_PATH=$(DOTNET_HOST_PATH)"" /> <_CoreClrBuildArg Condition="'$(HasCdacBuildTool)' == 'true'" Include="-cmakeargs "-DCDAC_BUILD_TOOL_BINARY_PATH=$(RuntimeBinDir)cdac-build-tool\cdac-build-tool.dll"" /> - <_CoreClrBuildArg Condition="'$(_IcuDir)' != ''" Include="-cmakeargs "-DCMAKE_ICU_DIR=$(_IcuDir)"" /> - <_CoreClrBuildArg Condition="'$(_TzdDir)' != ''" Include="-cmakeargs "-DCMAKE_TZD_DIR=$(_TzdDir)"" /> <_CoreClrBuildArg Condition="'$(FeatureXplatEventSource)' == 'false'" Include="-cmakeargs "-DFEATURE_EVENTSOURCE_XPLAT=0"" /> @@ -112,7 +106,7 @@ <_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">build-runtime.cmd <_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">build-runtime.sh - <_CoreClrBuildCommand>"$(MSBuildThisFileDirectory)$(_CoreClrBuildScript)" @(_CoreClrBuildArg, ' ') + <_CoreClrBuildCommand>"$(MSBuildThisFileDirectory)$(_CoreClrBuildScript)" @(_CoreClrBuildArg, ' ') @(_NativeCMakeArg, ' ') diff --git a/src/libraries/externals.csproj b/src/libraries/externals.csproj index e207c88bf99da1..d689529b137efa 100644 --- a/src/libraries/externals.csproj +++ b/src/libraries/externals.csproj @@ -24,7 +24,7 @@ Version="$(MicrosoftDiaSymReaderNativeVersion)" /> - + <_HostSymbols Include="$(DotNetHostBinDir)$(LibPrefix)hostfxr$(LibSuffix)$(SymbolsSuffix)" /> diff --git a/src/native/corehost/browserhost/CMakeLists.txt b/src/native/corehost/browserhost/CMakeLists.txt index 375d17c3cb9257..5d4af0dcb2ceca 100644 --- a/src/native/corehost/browserhost/CMakeLists.txt +++ b/src/native/corehost/browserhost/CMakeLists.txt @@ -4,12 +4,8 @@ project(browserhost) set(DOTNET_PROJECT_NAME "browserhost") -configure_file(${CLR_SRC_NATIVE_DIR}/corehost/configure.h.in ${GENERATED_INCLUDE_DIR}/corehost/configure.h) -target_include_directories(hostmisc_interface INTERFACE ${GENERATED_INCLUDE_DIR}/corehost) - -set(SOURCES - ./browserhost.cpp - native.rc +set(BROWSERHOST_SOURCES + empty.c ) set(HEADERS ) @@ -18,19 +14,20 @@ add_compile_definitions(FEATURE_APPHOST) add_definitions(-DFEATURE_APPHOST=1) add_definitions(-DFEATURE_STATIC_HOST=1) -add_executable(browserhost ${SOURCES}) +add_subdirectory(host) + +add_executable(browserhost ${BROWSERHOST_SOURCES}) set_target_properties(browserhost PROPERTIES OUTPUT_NAME dotnet.native) set(CMAKE_EXECUTABLE_SUFFIX ".js") + +add_dependencies(browserhost BrowserHost-Static) add_dependencies(browserhost System.Native.Browser-Rollup) add_dependencies(browserhost System.Native.Browser-Static) add_dependencies(browserhost System.Runtime.InteropServices.JavaScript.Native-Static) -install(TARGETS browserhost DESTINATION corehost COMPONENT runtime) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dotnet.native.wasm DESTINATION corehost COMPONENT runtime) - -include(configure.cmake) - LIST(APPEND NATIVE_LIBS + hostmisc + clrinterpreter coreclr_static System.Native.Browser-Static System.Runtime.InteropServices.JavaScript.Native-Static @@ -44,21 +41,14 @@ LIST(APPEND NATIVE_LIBS System.Native.TimeZoneData ) -# WASM-TODO set(RUNTIMEINFO_LIB runtimeinfo) - -target_compile_options(browserhost PRIVATE - -fwasm-exceptions - -msimd128 - ) - set(JS_SYSTEM_NATIVE_BROWSER - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js") + "${STATIC_LIB_DESTINATION}/libSystem.Native.Browser.js") set(JS_SYSTEM_BROWSER_UTILS - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Browser.Utils.js") + "${STATIC_LIB_DESTINATION}/libSystem.Browser.Utils.js") set(JS_SYSTEM_RUNTIME_INTEROPSERVICES_JAVASCRIPT_NATIVE - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js") + "${STATIC_LIB_DESTINATION}/libSystem.Runtime.InteropServices.JavaScript.Native.js") set(JS_BROWSER_HOST - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/libBrowserHost.js") + "${STATIC_LIB_DESTINATION}/libBrowserHost.js") set(JS_SYSTEM_NATIVE_BROWSER_EXPOST "${CMAKE_CURRENT_SOURCE_DIR}/../../libs/System.Native.Browser/libSystem.Native.Browser.extpost.js") @@ -67,6 +57,11 @@ set_target_properties(browserhost PROPERTIES LINK_FLAGS "--js-library ${JS_SYSTEM_NATIVE_BROWSER} --js-library ${JS_SYSTEM_BROWSER_UTILS} --js-library ${JS_SYSTEM_RUNTIME_INTEROPSERVICES_JAVASCRIPT_NATIVE} --js-library ${JS_BROWSER_HOST} --extern-post-js ${JS_SYSTEM_NATIVE_BROWSER_EXPOST}" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +target_compile_options(browserhost PRIVATE + -fwasm-exceptions + -msimd128 + ) + if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG) target_link_options(browserhost PRIVATE # -sVERBOSE @@ -97,16 +92,15 @@ target_link_options(browserhost PRIVATE -Wno-unused-command-line-argument -Wl,-error-limit=0) -target_link_libraries( - browserhost - PRIVATE - hostmisc - clrinterpreter +target_link_libraries(browserhost PUBLIC + BrowserHost-Static +) +target_link_libraries(browserhost PRIVATE ${NATIVE_LIBS} - - ${START_WHOLE_ARCHIVE} - ${RUNTIMEINFO_LIB} - ${END_WHOLE_ARCHIVE} ) +install(TARGETS browserhost DESTINATION corehost COMPONENT runtime) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dotnet.native.wasm DESTINATION corehost COMPONENT runtime) +install(FILES ${CLR_SRC_NATIVE_DIR}/package.json DESTINATION corehost COMPONENT runtime) + add_subdirectory(sample) diff --git a/src/native/corehost/browserhost/ReadMe.md b/src/native/corehost/browserhost/ReadMe.md index 966f5693ebd485..c84b888122e964 100644 --- a/src/native/corehost/browserhost/ReadMe.md +++ b/src/native/corehost/browserhost/ReadMe.md @@ -16,14 +16,15 @@ It's **JavaScript ES6 module** Implements native part of the CoreCLR host and exposes it as an internal JavaScript interface to the loader. It is **Emscripten application** statically linked from libraries. -- `host/index.ts` -> compiled -> `libBrowserHost.js` linked -> `dotnet.native.js` -- `libBrowserHost.footer.js` -> compiled -> `libBrowserHost.js` linked -> `dotnet.native.js` - `libSystem.Native.Browser.js` linked -> `dotnet.native.js` - `libSystem.Browser.Utils.js` linked -> `dotnet.native.js` - `libSystem.Runtime.InteropServices.JavaScript.Native.js` linked -> `dotnet.native.js` -- `browserhost.cpp` compiled + linked -> `dotnet.native.wasm` - `libSystem.Native.Browser.a` linked -> `dotnet.native.wasm` - `libSystem.Runtime.InteropServices.JavaScript.Native.a` linked -> `dotnet.native.wasm` +- `host/index.ts` -> compiled -> `libBrowserHost.js` linked -> `dotnet.native.js` +- `host/libBrowserHost.footer.js` -> compiled -> `libBrowserHost.js` linked -> `dotnet.native.js` +- `host/browserhost.cpp` compiled -> `libBrowserHost.a` linked -> `dotnet.native.wasm` +- `empty.c` compiled + linked -> `dotnet.native.wasm` ## Build TypeScript is compiled by `src/native/rollup.config.js` diff --git a/src/native/corehost/browserhost/configure.cmake b/src/native/corehost/browserhost/configure.cmake deleted file mode 100644 index 61c98113949945..00000000000000 --- a/src/native/corehost/browserhost/configure.cmake +++ /dev/null @@ -1,6 +0,0 @@ -check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL) -check_struct_has_member ("struct dirent" d_type dirent.h HAVE_DIRENT_D_TYPE) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in - ${CMAKE_CURRENT_BINARY_DIR}/config.h) diff --git a/src/native/corehost/browserhost/native.rc b/src/native/corehost/browserhost/empty.c similarity index 59% rename from src/native/corehost/browserhost/native.rc rename to src/native/corehost/browserhost/empty.c index 0a49d6b55d9591..b5fa34dbe43d18 100644 --- a/src/native/corehost/browserhost/native.rc +++ b/src/native/corehost/browserhost/empty.c @@ -1,7 +1,4 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#define FX_VER_FILEDESCRIPTION_STR "CoreCLR test host" - -#include -#include +#include "stdio.h" diff --git a/src/native/corehost/browserhost/host/CMakeLists.txt b/src/native/corehost/browserhost/host/CMakeLists.txt new file mode 100644 index 00000000000000..4966b897b8021a --- /dev/null +++ b/src/native/corehost/browserhost/host/CMakeLists.txt @@ -0,0 +1,39 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. + +project(BrowserHost-Static) +set(DOTNET_PROJECT_NAME "BrowserHost-Static") + +include(configure.cmake) + +set(BROWSERHOST_STATIC_SOURCES + ./config.h + ./browserhost.cpp + ../../native.rc +) + +add_compile_definitions(FEATURE_APPHOST) +add_definitions(-DFEATURE_APPHOST=1) +add_definitions(-DFEATURE_STATIC_HOST=1) + +add_library(BrowserHost-Static + STATIC + ${BROWSERHOST_STATIC_SOURCES} +) +set_target_properties(BrowserHost-Static PROPERTIES OUTPUT_NAME BrowserHost CLEAN_DIRECT_OUTPUT 1) + +target_compile_options(BrowserHost-Static PRIVATE + -fwasm-exceptions + -msimd128 + ) +target_link_libraries(BrowserHost-Static PRIVATE + hostmisc + + ${START_WHOLE_ARCHIVE} + # WASM-TODO: runtimeinfo + ${END_WHOLE_ARCHIVE} +) + +install(TARGETS BrowserHost-Static DESTINATION corehost COMPONENT runtime) +install(TARGETS BrowserHost-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) +install(TARGETS BrowserHost-Static DESTINATION sharedFramework COMPONENT runtime) diff --git a/src/native/corehost/browserhost/browserhost.cpp b/src/native/corehost/browserhost/host/browserhost.cpp similarity index 100% rename from src/native/corehost/browserhost/browserhost.cpp rename to src/native/corehost/browserhost/host/browserhost.cpp diff --git a/src/native/corehost/browserhost/config.h.in b/src/native/corehost/browserhost/host/config.h.in similarity index 75% rename from src/native/corehost/browserhost/config.h.in rename to src/native/corehost/browserhost/host/config.h.in index 0c2e459443b136..6fe9ebd246667e 100644 --- a/src/native/corehost/browserhost/config.h.in +++ b/src/native/corehost/browserhost/host/config.h.in @@ -4,7 +4,4 @@ #ifndef __CONFIG_H__ #define __CONFIG_H__ -#cmakedefine01 HAVE_GETAUXVAL -#cmakedefine01 HAVE_DIRENT_D_TYPE - #endif // __CONFIG_H__ diff --git a/src/native/corehost/browserhost/host/configure.cmake b/src/native/corehost/browserhost/host/configure.cmake new file mode 100644 index 00000000000000..b460849b004677 --- /dev/null +++ b/src/native/corehost/browserhost/host/configure.cmake @@ -0,0 +1,4 @@ + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/config.h) diff --git a/src/native/corehost/browserhost/libBrowserHost.footer.js b/src/native/corehost/browserhost/host/libBrowserHost.footer.js similarity index 100% rename from src/native/corehost/browserhost/libBrowserHost.footer.js rename to src/native/corehost/browserhost/host/libBrowserHost.footer.js diff --git a/src/native/corehost/browserhost/sample/CMakeLists.txt b/src/native/corehost/browserhost/sample/CMakeLists.txt index 3a385623fde844..6699740c7dcda2 100644 --- a/src/native/corehost/browserhost/sample/CMakeLists.txt +++ b/src/native/corehost/browserhost/sample/CMakeLists.txt @@ -3,15 +3,16 @@ # this is just a incomplete sample app deployment # WASM-TODO: implement proper in-tree project via MSBuild and WASM SDK + set(SAMPLE_ASSETS index.html main.mjs dotnet.boot.js - ${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js - ${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js.map - ${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.d.ts - ${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js - ${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js.map + ${STATIC_LIB_DESTINATION}/dotnet.js + ${STATIC_LIB_DESTINATION}/dotnet.js.map + ${STATIC_LIB_DESTINATION}/dotnet.d.ts + ${STATIC_LIB_DESTINATION}/dotnet.runtime.js + ${STATIC_LIB_DESTINATION}/dotnet.runtime.js.map # Bring your own DLLs and update the dotnet.boot.js to match # HelloWorld.dll diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index ae69aeaf6cf635..24d89a6ee1314f 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -34,6 +34,7 @@ if /i [%1] == [x86] (set __BuildArch=x86&&shift&goto Arg_Loop) if /i [%1] == [x64] (set __BuildArch=x64&&shift&goto Arg_Loop) if /i [%1] == [amd64] (set __BuildArch=x64&&shift&goto Arg_Loop) if /i [%1] == [arm64] (set __BuildArch=arm64&&shift&goto Arg_Loop) +if /i [%1] == [wasm] (set __BuildArch=wasm&&shift&goto Arg_Loop) if /i [%1] == [portable] (set __PortableBuild=1&&shift&goto Arg_Loop) if /i [%1] == [targetrid] (set __TargetRid=%2&&shift&&shift&goto Arg_Loop) @@ -48,6 +49,8 @@ if /i [%1] == [msbuild] (set __Ninja=0) if /i [%1] == [runtimeflavor] (set __RuntimeFlavor=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [runtimeconfiguration] (set __RuntimeConfiguration=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [-fsanitize] ( set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLR_CMAKE_ENABLE_SANITIZERS=%2"&&shift&&shift&goto Arg_Loop) +if /i [%1] == [-os] ( set __TargetOS=%2%&&shift&&shift&goto Arg_Loop) +if /i [%1] == [-cmakeargs] ( set __ExtraCmakeParams=%__ExtraCmakeParams% %2&&shift&&shift&goto Arg_Loop) shift goto :Arg_Loop @@ -93,6 +96,7 @@ if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%" if /i "%__BuildArch%" == "x64" (set cm_BaseRid=win7) if /i "%__BuildArch%" == "x86" (set cm_BaseRid=win7) if /i "%__BuildArch%" == "arm64" (set cm_BaseRid=win10) +if /i "%__BuildArch%" == "wasm" (set cm_BaseRid=browser) :: Form the base RID to be used if we are doing a portable build if /i "%__PortableBuild%" == "1" (set cm_BaseRid=win) set cm_BaseRid=%cm_BaseRid%-%__BuildArch% @@ -104,7 +108,8 @@ for /f "delims=-" %%i in ("%__TargetRid%") do set __HostFallbackOS=%%i :: The "win" host build is Windows 10 compatible if "%__HostFallbackOS%" == "win" (set __HostFallbackOS=win10) -set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_FALLBACK_OS=%__HostFallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" +set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_PKG_RID=%__TargetRid%" "-DCLI_CMAKE_FALLBACK_OS=%__HostFallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" +set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" :: Regenerate the native build files diff --git a/src/native/corehost/corehost.proj b/src/native/corehost/corehost.proj index bb5f6a7d53ebe6..110ddfff072966 100644 --- a/src/native/corehost/corehost.proj +++ b/src/native/corehost/corehost.proj @@ -5,6 +5,7 @@ package's targets into the build. --> + true @@ -44,8 +45,8 @@ - @@ -87,8 +88,8 @@ Use IgnoreStandardErrorWarningFormat because Arcade sets WarnAsError and we want to avoid upgrading compiler warnings to errors in release branches. --> - - + + @@ -147,7 +148,7 @@ $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'build.cmd')) - $(Configuration) $(TargetArchitecture) commit $([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A')) targetrid $(TargetRid) + $(Configuration) $(TargetArchitecture) -os $(TargetOS) commit $([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A')) targetrid $(TargetRid) $(BuildArgs) configureonly $(BuildArgs) portable $(BuildArgs) incremental-native-build @@ -163,8 +164,8 @@ IgnoreStandardErrorWarningFormat because Arcade sets WarnAsError and we want to avoid upgrading compiler warnings to errors in release branches. --> - - + + #include #include #include +#endif // !TARGET_WASM static const Entry s_compressionNative[] = { +#if !defined(TARGET_WASM) DllImportEntry(BrotliDecoderCreateInstance) DllImportEntry(BrotliDecoderDecompress) DllImportEntry(BrotliDecoderDecompressStream) @@ -24,6 +28,7 @@ static const Entry s_compressionNative[] = DllImportEntry(BrotliEncoderHasMoreOutput) DllImportEntry(BrotliEncoderMaxCompressedSize) DllImportEntry(BrotliEncoderSetParameter) +#endif // !TARGET_WASM DllImportEntry(CompressionNative_Crc32) DllImportEntry(CompressionNative_Deflate) DllImportEntry(CompressionNative_DeflateEnd) diff --git a/src/native/libs/System.IO.Compression.Native/extra_libs.cmake b/src/native/libs/System.IO.Compression.Native/extra_libs.cmake index 03b40533e2109d..e0b65fdc0956ba 100644 --- a/src/native/libs/System.IO.Compression.Native/extra_libs.cmake +++ b/src/native/libs/System.IO.Compression.Native/extra_libs.cmake @@ -20,7 +20,7 @@ macro(append_extra_compression_libs NativeLibsExtra) endif () list(APPEND ${NativeLibsExtra} ${ZLIB_LIBRARIES}) - if (CLR_CMAKE_USE_SYSTEM_BROTLI) + if (CLR_CMAKE_USE_SYSTEM_BROTLI AND NOT CLR_CMAKE_TARGET_ARCH_WASM) find_library(BROTLIDEC brotlidec REQUIRED) find_library(BROTLIENC brotlienc REQUIRED) diff --git a/src/native/libs/System.Native.Browser/CMakeLists.txt b/src/native/libs/System.Native.Browser/CMakeLists.txt index dab7e46af63a8b..22725542b36f14 100644 --- a/src/native/libs/System.Native.Browser/CMakeLists.txt +++ b/src/native/libs/System.Native.Browser/CMakeLists.txt @@ -12,87 +12,7 @@ add_library(System.Native.Browser-Static ) set_target_properties(System.Native.Browser-Static PROPERTIES OUTPUT_NAME System.Native.Browser CLEAN_DIRECT_OUTPUT 1) install(TARGETS System.Native.Browser-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) +install(TARGETS System.Native.Browser-Static DESTINATION sharedFramework COMPONENT runtime) - -file(GLOB_RECURSE ROLLUP_TS_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/*.ts" - "${CMAKE_CURRENT_SOURCE_DIR}/*.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../System.Runtime.InteropServices.JavaScript.Native/*.ts" - "${CMAKE_CURRENT_SOURCE_DIR}/../System.Runtime.InteropServices.JavaScript.Native/*.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../Common/JavaScript/*.ts" - "${CMAKE_CURRENT_SOURCE_DIR}/../Common/JavaScript/*.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../../corehost/browserhost/*.ts" - "${CMAKE_CURRENT_SOURCE_DIR}/../../corehost/browserhost/*.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../../package.json" - "${CMAKE_CURRENT_SOURCE_DIR}/../../tsconfig.json" - "${CMAKE_CURRENT_SOURCE_DIR}/../../node_modules/.npm-stamp" -) - -set(ROLLUP_OUTPUTS - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js" - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js.map" - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.d.ts" - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/libBrowserHost.js" - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/libBrowserHost.js.map" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js.map" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Browser.Utils.js" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Browser.Utils.js.map" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/dotnet.runtime.js" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/dotnet.runtime.js.map" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js.map" -) - -set(ROLLUP_STAMP - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/.rollup.stamp" -) - -if(NOT PRODUCT_VERSION_JS) - # WASM-TODO get dotnet ProductVersion from MSBuild - set(PRODUCT_VERSION_JS "10.0.0-dev") -endif() -if(NOT CI_BUILD_JS) - # WASM-TODO get ContinuousIntegrationBuild from MSBuild - set(CI_BUILD_JS "false") -endif() - -add_custom_command( - OUTPUT ${ROLLUP_STAMP} - BYPRODUCTS ${ROLLUP_OUTPUTS} - COMMAND npm run rollup:cmake -- "Configuration:${CMAKE_BUILD_TYPE},ProductVersion:${PRODUCT_VERSION_JS},ContinuousIntegrationBuild:${CI_BUILD_JS}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../.." - COMMENT "Running 'npm run rollup' to generate JavaScript bundles" - DEPENDS ${ROLLUP_TS_SOURCES} - VERBATIM -) - -# WASM-TODO fixme: make this incremental -add_custom_target(System.Native.Browser-Rollup - DEPENDS ${ROLLUP_STAMP} -) - +add_subdirectory(../Common/JavaScript common-js) add_dependencies(System.Native.Browser-Static System.Native.Browser-Rollup) - -set(NPM_INSTALL_OUTPUTS - "${CMAKE_CURRENT_SOURCE_DIR}/../../node_modules/.package-lock.json" -) - -set(NPM_INSTALL_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/../../package.json" -) - -add_dependencies(System.Native.Browser-Rollup System.Native.Browser-NpmInstall) - -add_custom_command( - OUTPUT ${NPM_INSTALL_OUTPUTS} - COMMAND npm ci - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../.." - COMMENT "Running 'npm ci' to install npm packages" - DEPENDS ${NPM_INSTALL_SOURCES} - VERBATIM -) - -add_custom_target(System.Native.Browser-NpmInstall - DEPENDS ${NPM_INSTALL_OUTPUTS} -) diff --git a/src/native/libs/System.Native/CMakeLists.txt b/src/native/libs/System.Native/CMakeLists.txt index 35b483e841a95c..9d6f97151df386 100644 --- a/src/native/libs/System.Native/CMakeLists.txt +++ b/src/native/libs/System.Native/CMakeLists.txt @@ -163,8 +163,10 @@ if (CLR_CMAKE_TARGET_ARCH_WASM AND DEFINED CMAKE_TZD_DIR) target_compile_definitions(System.Native.TimeZoneData PRIVATE TZ_DATA_ENABLED) target_include_directories(System.Native.TimeZoneData PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/inc") install(TARGETS System.Native.TimeZoneData DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) + install(TARGETS System.Native.TimeZoneData DESTINATION sharedFramework COMPONENT runtime) # Also add a stub to support InvariantTimezone. add_library(System.Native.TimeZoneData.Invariant STATIC pal_datetime_time_zone_data.c) install(TARGETS System.Native.TimeZoneData.Invariant DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) + install(TARGETS System.Native.TimeZoneData.Invariant DESTINATION sharedFramework COMPONENT runtime) endif () diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt index 4af087e8dd2b10..7866ec4dde7be8 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt @@ -12,3 +12,4 @@ add_library(System.Runtime.InteropServices.JavaScript.Native-Static ) set_target_properties(System.Runtime.InteropServices.JavaScript.Native-Static PROPERTIES OUTPUT_NAME System.Runtime.InteropServices.JavaScript.Native CLEAN_DIRECT_OUTPUT 1) install(TARGETS System.Runtime.InteropServices.JavaScript.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) +install(TARGETS System.Runtime.InteropServices.JavaScript.Native-Static DESTINATION sharedFramework COMPONENT runtime) diff --git a/src/native/libs/build-native.proj b/src/native/libs/build-native.proj index 97924a6e27ec7d..765344e70c3b02 100644 --- a/src/native/libs/build-native.proj +++ b/src/native/libs/build-native.proj @@ -1,4 +1,6 @@ + + $(ArtifactsObjDir)_version.h @@ -11,29 +13,16 @@ <_BuildNativeArgs Condition="'$(EnableNativeSanitizers)' != ''">$(_BuildNativeArgs) -fsanitize=$(EnableNativeSanitizers) <_BuildNativeArgs Condition="'$(OfficialBuildId)' != ''">$(_BuildNativeArgs) /p:OfficialBuildId="$(OfficialBuildId)" - <_RuntimeVariant /> - <_RuntimeVariant Condition="'$(WasmEnableThreads)' == 'true'">-threads - <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native - <_TzdDir Condition="'$(PkgSystem_Runtime_TimeZoneData)' != ''">$([MSBuild]::NormalizePath('$(PkgSystem_Runtime_TimeZoneData)', 'contentFiles', 'any', 'any', 'data')) - <_CMakeArgs Condition="'$(CMakeArgs)' != ''"> -cmakeargs "$(CMakeArgs)" <_CMakeArgs Condition="'$(WasmEnableThreads)' == 'true'">$(_CMakeArgs) -cmakeargs "-DCMAKE_USE_PTHREADS=1" - <_CMakeArgs Condition="'$(_IcuDir)' != ''">$(_CMakeArgs) -cmakeargs "-DCMAKE_ICU_DIR=$(_IcuDir)" - <_CMakeArgs Condition="'$(_TzdDir)' != ''">$(_CMakeArgs) -cmakeargs "-DCMAKE_TZD_DIR=$(_TzdDir)" - <_CMakeArgs Condition="'$(TargetsBrowser)' == 'true' and '$(RuntimeFlavor)' == 'CoreCLR'">$(_CMakeArgs) -cmakeargs "-DBUILD_LIBS_NATIVE_BROWSER=1" - <_BuildNativeArgs>$(_BuildNativeArgs)$(_CMakeArgs) + <_BuildNativeArgs>$(_BuildNativeArgs)$(_CMakeArgs) @(_NativeCMakeArg, ' ') - - - - - Date: Mon, 13 Oct 2025 16:06:04 +0200 Subject: [PATCH 02/22] more --- eng/native.props | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/native.props b/eng/native.props index 77a5ed86e62d58..78b65d49d85326 100644 --- a/eng/native.props +++ b/eng/native.props @@ -17,7 +17,6 @@ <_NativeCMakeArg Condition="'$(_TzdDir)' != ''" Include="-cmakeargs "-DCMAKE_TZD_DIR=$(_TzdDir)"" /> <_NativeCMakeArg Include="-cmakeargs "-DCMAKE_PRODUCT_VERSION=$(ProductVersion)"" /> <_NativeCMakeArg Include="-cmakeargs "-DCMAKE_CONTINUOUS_INTEGRATION_BUILD=$(ContinuousIntegrationBuild)"" /> - <_NativeCMakeArg Condition="'$(TargetsBrowser)' == 'true' and '$(RuntimeFlavor)' == 'CoreCLR'" Include="-cmakeargs "-DSTATIC_LIBS_ONLY=1"" /> From 38070096effe63e9ebcc6fd8c18d24d22300d7ed Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 13 Oct 2025 17:00:04 +0200 Subject: [PATCH 03/22] fix --- eng/Subsets.props | 1 - src/native/libs/CMakeLists.txt | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/eng/Subsets.props b/eng/Subsets.props index 77c476e801a193..ccdcf9859e4584 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -109,7 +109,6 @@ clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools+host.native clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools - mono.emsdk+clr.native+clr.corelib+clr.tools+clr.packages+clr.crossarchtools clr.iltools+clr.packages diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index 24d4219a6b61bb..803f876cc1dc61 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -20,16 +20,18 @@ if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(STATIC_LIBS_ONLY 1) set(GEN_SHARED_LIB 0) if (NOT STATIC_LIB_DESTINATION) - set(STATIC_LIB_DESTINATION $ENV{__CMakeBinDir}/lib) + if (BUILD_LIBS_NATIVE_BROWSER) + set(STATIC_LIB_DESTINATION $ENV{__CMakeBinDir}/lib) + else () + set(STATIC_LIB_DESTINATION .) + endif () endif () elseif (STATIC_LIBS_ONLY) # Suppress exporting of the PAL APIs add_definitions(-DPALEXPORT=EXTERN_C) set(GEN_SHARED_LIB 0) - if (NOT STATIC_LIB_DESTINATION) - set(STATIC_LIB_DESTINATION lib) - endif () + set(STATIC_LIB_DESTINATION lib) else () set(GEN_SHARED_LIB 1) set(STATIC_LIB_DESTINATION .) From 77153b6ed7049cbf4ebb52654818c42865a9fbd8 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 13 Oct 2025 17:42:58 +0200 Subject: [PATCH 04/22] fix --- src/native/minipal/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/native/minipal/CMakeLists.txt b/src/native/minipal/CMakeLists.txt index ec1040877abb75..d7f9ad5e2ab78a 100644 --- a/src/native/minipal/CMakeLists.txt +++ b/src/native/minipal/CMakeLists.txt @@ -50,4 +50,6 @@ add_library(minipal_sanitizer_support OBJECT # in a non-sanitized build. set_target_properties(minipal_sanitizer_support PROPERTIES EXCLUDE_FROM_ALL ON) -install(TARGETS minipal DESTINATION sharedFramework COMPONENT runtime) \ No newline at end of file +if(CLR_CMAKE_TARGET_ARCH_WASM) + install(TARGETS minipal DESTINATION sharedFramework COMPONENT runtime) +endif(CLR_CMAKE_TARGET_ARCH_WASM) From 65ca66b83956bbfee093de022a20ce03045d633a Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 13 Oct 2025 18:51:20 +0200 Subject: [PATCH 05/22] fix --- eng/liveBuilds.targets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets index 135b98b15aac0c..377a95bfe59307 100644 --- a/eng/liveBuilds.targets +++ b/eng/liveBuilds.targets @@ -23,6 +23,7 @@ $([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'sharedFramework')) + $([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'corehost')) $([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'ilc-published')) $([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', '$(BuildArchitecture)', 'ilc')) $([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'aotsdk')) @@ -218,15 +219,14 @@ From 988028115555cee621c398131e5561800d2b93be Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 13 Oct 2025 18:57:35 +0200 Subject: [PATCH 06/22] Update src/native/corehost/build.cmd Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/native/corehost/build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index 24d89a6ee1314f..27dc13bd99b85d 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -49,7 +49,7 @@ if /i [%1] == [msbuild] (set __Ninja=0) if /i [%1] == [runtimeflavor] (set __RuntimeFlavor=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [runtimeconfiguration] (set __RuntimeConfiguration=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [-fsanitize] ( set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLR_CMAKE_ENABLE_SANITIZERS=%2"&&shift&&shift&goto Arg_Loop) -if /i [%1] == [-os] ( set __TargetOS=%2%&&shift&&shift&goto Arg_Loop) +if /i [%1] == [-os] ( set __TargetOS=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [-cmakeargs] ( set __ExtraCmakeParams=%__ExtraCmakeParams% %2&&shift&&shift&goto Arg_Loop) shift From 0bd8ca9d1aa92112883fc37a7e0a539c78bbd6ce Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 13 Oct 2025 18:58:45 +0200 Subject: [PATCH 07/22] Update src/native/corehost/build.cmd Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/native/corehost/build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index 27dc13bd99b85d..a07a2a3603bee1 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -108,7 +108,7 @@ for /f "delims=-" %%i in ("%__TargetRid%") do set __HostFallbackOS=%%i :: The "win" host build is Windows 10 compatible if "%__HostFallbackOS%" == "win" (set __HostFallbackOS=win10) -set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_PKG_RID=%__TargetRid%" "-DCLI_CMAKE_FALLBACK_OS=%__HostFallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" +set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_FALLBACK_OS=%__HostFallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" From 8b6583124827b00cfd4570b5e2bbf9fbe816a2cf Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 13 Oct 2025 18:59:15 +0200 Subject: [PATCH 08/22] fix --- src/native/libs/Common/JavaScript/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/native/libs/Common/JavaScript/CMakeLists.txt b/src/native/libs/Common/JavaScript/CMakeLists.txt index 711b5cda557dfb..9430c667a66189 100644 --- a/src/native/libs/Common/JavaScript/CMakeLists.txt +++ b/src/native/libs/Common/JavaScript/CMakeLists.txt @@ -1,6 +1,6 @@ project(Common.JavaScript C) -set(NATIVE_JAVASCRIPT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../../) +set(NATIVE_JAVASCRIPT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../..) if (NOT STATIC_LIB_DESTINATION) message(FATAL_ERROR "please set STATIC_LIB_DESTINATION") endif() @@ -14,9 +14,9 @@ file(GLOB_RECURSE ROLLUP_TS_SOURCES "${NATIVE_JAVASCRIPT_SRC}/libs/System.Runtime.InteropServices.JavaScript.Native/*.js" "${NATIVE_JAVASCRIPT_SRC}/corehost/browserhost/*.ts" "${NATIVE_JAVASCRIPT_SRC}/corehost/browserhost/*.js" - "${NATIVE_JAVASCRIPT_SRC}package.json" - "${NATIVE_JAVASCRIPT_SRC}tsconfig.json" - "${NATIVE_JAVASCRIPT_SRC}node_modules/.npm-stamp" + "${NATIVE_JAVASCRIPT_SRC}/package.json" + "${NATIVE_JAVASCRIPT_SRC}/tsconfig.json" + "${NATIVE_JAVASCRIPT_SRC}/node_modules/.npm-stamp" ) set(ROLLUP_OUTPUTS From abaa97063d50d6b2ffdaf9de097350c7d5366704 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 13 Oct 2025 19:51:54 +0200 Subject: [PATCH 09/22] fix --- eng/liveBuilds.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets index 377a95bfe59307..e1a619d1cac11b 100644 --- a/eng/liveBuilds.targets +++ b/eng/liveBuilds.targets @@ -219,6 +219,7 @@ Date: Tue, 14 Oct 2025 19:34:23 +0200 Subject: [PATCH 10/22] Update src/native/corehost/browserhost/host/CMakeLists.txt Co-authored-by: Jeremy Koritzinsky --- src/native/corehost/browserhost/host/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/native/corehost/browserhost/host/CMakeLists.txt b/src/native/corehost/browserhost/host/CMakeLists.txt index 4966b897b8021a..42d3853e930465 100644 --- a/src/native/corehost/browserhost/host/CMakeLists.txt +++ b/src/native/corehost/browserhost/host/CMakeLists.txt @@ -28,10 +28,6 @@ target_compile_options(BrowserHost-Static PRIVATE ) target_link_libraries(BrowserHost-Static PRIVATE hostmisc - - ${START_WHOLE_ARCHIVE} - # WASM-TODO: runtimeinfo - ${END_WHOLE_ARCHIVE} ) install(TARGETS BrowserHost-Static DESTINATION corehost COMPONENT runtime) From bf10e5bffcf8892c237a4671f077d08f517851f1 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 14 Oct 2025 19:34:33 +0200 Subject: [PATCH 11/22] Update src/coreclr/CMakeLists.txt Co-authored-by: Jeremy Koritzinsky --- src/coreclr/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 967d8253a4d59e..02d85086ab70f9 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -78,7 +78,7 @@ else() set(GEN_PINVOKE 0) # WASM-TODO should we start using System.Native.Browser and System.Runtime.InteropServices.JavaScript.Native also for Mono ? set(BUILD_LIBS_NATIVE_BROWSER 1) - set(STATIC_LIB_DESTINATION $ENV{__CMakeBinDir}/libs-native) + set(STATIC_LIB_DESTINATION ${CMAKE_BINARY_DIR}/libs-native) add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost corehost) add_dependencies(runtime browserhost) endif() From 1e0c027c1bdf3805ff5160e8b72eae435c890de2 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 14 Oct 2025 19:34:47 +0200 Subject: [PATCH 12/22] Update src/native/corehost/browserhost/CMakeLists.txt Co-authored-by: Jeremy Koritzinsky --- src/native/corehost/browserhost/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/native/corehost/browserhost/CMakeLists.txt b/src/native/corehost/browserhost/CMakeLists.txt index 5d4af0dcb2ceca..734480a18a6af6 100644 --- a/src/native/corehost/browserhost/CMakeLists.txt +++ b/src/native/corehost/browserhost/CMakeLists.txt @@ -20,7 +20,6 @@ add_executable(browserhost ${BROWSERHOST_SOURCES}) set_target_properties(browserhost PROPERTIES OUTPUT_NAME dotnet.native) set(CMAKE_EXECUTABLE_SUFFIX ".js") -add_dependencies(browserhost BrowserHost-Static) add_dependencies(browserhost System.Native.Browser-Rollup) add_dependencies(browserhost System.Native.Browser-Static) add_dependencies(browserhost System.Runtime.InteropServices.JavaScript.Native-Static) From 5edb655c145712bdf40db2b60859e7fd6de52812 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 14 Oct 2025 19:35:11 +0200 Subject: [PATCH 13/22] Update src/native/corehost/browserhost/host/CMakeLists.txt Co-authored-by: Jeremy Koritzinsky --- src/native/corehost/browserhost/host/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/native/corehost/browserhost/host/CMakeLists.txt b/src/native/corehost/browserhost/host/CMakeLists.txt index 42d3853e930465..a381e23483d4f1 100644 --- a/src/native/corehost/browserhost/host/CMakeLists.txt +++ b/src/native/corehost/browserhost/host/CMakeLists.txt @@ -1,7 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(BrowserHost-Static) set(DOTNET_PROJECT_NAME "BrowserHost-Static") include(configure.cmake) From ef9e60e8eaf1b5f4d678cf0588ddf3ee546a8d38 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 14 Oct 2025 19:36:48 +0200 Subject: [PATCH 14/22] Update src/native/corehost/browserhost/CMakeLists.txt Co-authored-by: Jeremy Koritzinsky --- src/native/corehost/browserhost/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/native/corehost/browserhost/CMakeLists.txt b/src/native/corehost/browserhost/CMakeLists.txt index 734480a18a6af6..45be9846246e18 100644 --- a/src/native/corehost/browserhost/CMakeLists.txt +++ b/src/native/corehost/browserhost/CMakeLists.txt @@ -95,6 +95,9 @@ target_link_libraries(browserhost PUBLIC BrowserHost-Static ) target_link_libraries(browserhost PRIVATE + ${START_WHOLE_ARCHIVE} + ${RUNTIMEINFO_LIB} + ${END_WHOLE_ARCHIVE} ${NATIVE_LIBS} ) From 9eed03e825e5009d14ee49f0edfeb099c881bf6d Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 14 Oct 2025 20:06:07 +0200 Subject: [PATCH 15/22] NativeCMakeArg feedback --- eng/native.props | 8 ++++---- src/coreclr/runtime.proj | 2 +- src/native/corehost/corehost.proj | 8 ++++---- src/native/libs/build-native.proj | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/eng/native.props b/eng/native.props index 78b65d49d85326..0640f19e02619e 100644 --- a/eng/native.props +++ b/eng/native.props @@ -13,10 +13,10 @@ - <_NativeCMakeArg Condition="'$(_IcuDir)' != ''" Include="-cmakeargs "-DCMAKE_ICU_DIR=$(_IcuDir)"" /> - <_NativeCMakeArg Condition="'$(_TzdDir)' != ''" Include="-cmakeargs "-DCMAKE_TZD_DIR=$(_TzdDir)"" /> - <_NativeCMakeArg Include="-cmakeargs "-DCMAKE_PRODUCT_VERSION=$(ProductVersion)"" /> - <_NativeCMakeArg Include="-cmakeargs "-DCMAKE_CONTINUOUS_INTEGRATION_BUILD=$(ContinuousIntegrationBuild)"" /> + + + + diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index 2baed187441d3f..d70f30b12ec4f2 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -106,7 +106,7 @@ <_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">build-runtime.cmd <_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">build-runtime.sh - <_CoreClrBuildCommand>"$(MSBuildThisFileDirectory)$(_CoreClrBuildScript)" @(_CoreClrBuildArg, ' ') @(_NativeCMakeArg, ' ') + <_CoreClrBuildCommand>"$(MSBuildThisFileDirectory)$(_CoreClrBuildScript)" @(_CoreClrBuildArg, ' ') @(NativeCMakeArg, ' ') diff --git a/src/native/corehost/corehost.proj b/src/native/corehost/corehost.proj index 110ddfff072966..23fff553c69459 100644 --- a/src/native/corehost/corehost.proj +++ b/src/native/corehost/corehost.proj @@ -88,8 +88,8 @@ Use IgnoreStandardErrorWarningFormat because Arcade sets WarnAsError and we want to avoid upgrading compiler warnings to errors in release branches. --> - - + + - - + + -cmakeargs "$(CMakeArgs)" <_CMakeArgs Condition="'$(WasmEnableThreads)' == 'true'">$(_CMakeArgs) -cmakeargs "-DCMAKE_USE_PTHREADS=1" - <_BuildNativeArgs>$(_BuildNativeArgs)$(_CMakeArgs) @(_NativeCMakeArg, ' ') + <_BuildNativeArgs>$(_BuildNativeArgs)$(_CMakeArgs) @(NativeCMakeArg, ' ') From 85e46ec2511baf13e8739800a0444bfb7d167ea7 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 14 Oct 2025 20:06:20 +0200 Subject: [PATCH 16/22] _SdkToolsSupportedArch feedback --- eng/Subsets.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Subsets.props b/eng/Subsets.props index ccdcf9859e4584..e640315cd389d3 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -54,7 +54,7 @@ <_SdkToolsSupportedOS Condition="'$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">true - <_SdkToolsSupportedArch Condition="'$(TargetArchitecture)' != 'armel'">true + <_SdkToolsSupportedArch Condition="'$(TargetArchitecture)' != 'armel' and '$(TargetsWasm)' != 'true'">true true <_UseNativeAotForComponentsCrossOS Condition="'$(CrossBuild)' == 'true' and '$(_hostArchitecture)' == '$(_targetArchitecture)' and '$(_hostOS)' != 'windows'">true From 6b147a23db2667ad020b7b3a5e1fd870a6ca491b Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 14 Oct 2025 20:07:06 +0200 Subject: [PATCH 17/22] GLOB_RECURSE feedback --- .../libs/Common/JavaScript/CMakeLists.txt | 85 +++++++++++++++---- 1 file changed, 69 insertions(+), 16 deletions(-) diff --git a/src/native/libs/Common/JavaScript/CMakeLists.txt b/src/native/libs/Common/JavaScript/CMakeLists.txt index 9430c667a66189..d08e1061003621 100644 --- a/src/native/libs/Common/JavaScript/CMakeLists.txt +++ b/src/native/libs/Common/JavaScript/CMakeLists.txt @@ -1,22 +1,75 @@ project(Common.JavaScript C) -set(NATIVE_JAVASCRIPT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../..) if (NOT STATIC_LIB_DESTINATION) message(FATAL_ERROR "please set STATIC_LIB_DESTINATION") endif() -file(GLOB_RECURSE ROLLUP_TS_SOURCES - "${NATIVE_JAVASCRIPT_SRC}/libs/Common/JavaScript/*.ts" - "${NATIVE_JAVASCRIPT_SRC}/libs/Common/JavaScript/*.js" - "${NATIVE_JAVASCRIPT_SRC}/libs/System.Native.Browser/*.ts" - "${NATIVE_JAVASCRIPT_SRC}/libs/System.Native.Browser/*.js" - "${NATIVE_JAVASCRIPT_SRC}/libs/System.Runtime.InteropServices.JavaScript.Native/*.ts" - "${NATIVE_JAVASCRIPT_SRC}/libs/System.Runtime.InteropServices.JavaScript.Native/*.js" - "${NATIVE_JAVASCRIPT_SRC}/corehost/browserhost/*.ts" - "${NATIVE_JAVASCRIPT_SRC}/corehost/browserhost/*.js" - "${NATIVE_JAVASCRIPT_SRC}/package.json" - "${NATIVE_JAVASCRIPT_SRC}/tsconfig.json" - "${NATIVE_JAVASCRIPT_SRC}/node_modules/.npm-stamp" +set(ROLLUP_TS_SOURCES + "${CLR_SRC_NATIVE_DIR}/package.json" + "${CLR_SRC_NATIVE_DIR}/tsconfig.json" + "${CLR_SRC_NATIVE_DIR}/node_modules/.package-lock.json" + "${CLR_SRC_NATIVE_DIR}/rollup.config.js" + "${CLR_SRC_NATIVE_DIR}/rollup.config.defines.js" + "${CLR_SRC_NATIVE_DIR}/rollup.config.plugins.js" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/libBrowserHost.footer.js" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/libSystem.Browser.Utils.footer.js" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/libSystem.Native.Browser.footer.js" + "${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/cross-linked.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/host.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/index.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/types.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/bootstrap.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/config.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/cross-module.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/dotnet.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/dotnet.d.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/exit.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/host-builder.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/index.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/lib-initializers.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/logging.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/per-module.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/polyfills.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/promise-controller.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/run.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/runtime-list.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/types.ts" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/types.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/cross-linked/index.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/cross-module/index.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/per-module/index.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/consts.d.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/emscripten.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/emsdk.d.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/exchange.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/export-api.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/index.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/internal.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/node.d.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/public-api.ts" + "${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/v8.d.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/native/cross-linked.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/native/crypto.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/native/globalization-locale.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/native/index.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/native/per-module.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/types.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/utils/cross-module.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/utils/host.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/utils/index.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/utils/memory.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/utils/per-module.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/utils/strings.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/cross-module.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/per-module.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/types.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/native/cross-linked.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts" + "${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/types.ts" ) set(ROLLUP_OUTPUTS @@ -49,11 +102,11 @@ add_custom_target(System.Native.Browser-Rollup ) set(NPM_INSTALL_OUTPUTS - "${NATIVE_JAVASCRIPT_SRC}/node_modules/.package-lock.json" + "${CLR_SRC_NATIVE_DIR}/node_modules/.package-lock.json" ) set(NPM_INSTALL_SOURCES - "${NATIVE_JAVASCRIPT_SRC}/package.json" + "${CLR_SRC_NATIVE_DIR}/package.json" ) add_dependencies(System.Native.Browser-Rollup System.Native.Browser-NpmInstall) @@ -61,7 +114,7 @@ add_dependencies(System.Native.Browser-Rollup System.Native.Browser-NpmInstall) add_custom_command( OUTPUT ${NPM_INSTALL_OUTPUTS} COMMAND npm ci - WORKING_DIRECTORY "${NATIVE_JAVASCRIPT_SRC}" + WORKING_DIRECTORY "${CLR_SRC_NATIVE_DIR}" COMMENT "Running 'npm ci' to install npm packages" DEPENDS ${NPM_INSTALL_SOURCES} VERBATIM From d3a375192ce83170373479611a232cabf2c0bb4b Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 14 Oct 2025 20:14:30 +0200 Subject: [PATCH 18/22] fix System.Native.TimeZoneData.Invariant --- src/coreclr/hosts/corerun/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index 035a55778461de..cec25ae3312fcb 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -53,7 +53,7 @@ else() target_link_libraries(corerun PRIVATE coreclr_static System.Native-Static - System.Native.TimeZoneData) + System.Native.TimeZoneData.Invariant) # linker options for NodeJs, link in JavaScript helper, access to local filesystem if (CLR_CMAKE_TARGET_BROWSER) target_compile_options(corerun PRIVATE From ac739b425d2126f9461e6c6dd4c48a6c943cb441 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 14 Oct 2025 20:14:55 +0200 Subject: [PATCH 19/22] zlib feedback --- src/native/libs/System.IO.Compression.Native/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/native/libs/System.IO.Compression.Native/CMakeLists.txt b/src/native/libs/System.IO.Compression.Native/CMakeLists.txt index 5f6b81398f71db..5bf84b8a96f6ae 100644 --- a/src/native/libs/System.IO.Compression.Native/CMakeLists.txt +++ b/src/native/libs/System.IO.Compression.Native/CMakeLists.txt @@ -127,13 +127,14 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) install (TARGETS ${BROTLI_LIB} DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) endif() endforeach(BROTLI_LIB ${BROTLI_LIBRARIES}) - else() - install (TARGETS zlib DESTINATION sharedFramework COMPONENT runtime) endif() if (NOT CLR_CMAKE_USE_SYSTEM_ZLIB) install (TARGETS zlib DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) endif() + if (CLR_CMAKE_TARGET_ARCH_WASM) + install (TARGETS zlib DESTINATION sharedFramework COMPONENT runtime) + endif() else () set(NATIVE_LIBS_EXTRA) append_extra_compression_libs(NATIVE_LIBS_EXTRA) From fb3ad000eb65d417a9537e5f97df75ae285aa2b8 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 14 Oct 2025 20:20:43 +0200 Subject: [PATCH 20/22] dependencies feedback --- src/native/corehost/browserhost/CMakeLists.txt | 4 +--- src/native/corehost/browserhost/host/CMakeLists.txt | 1 + .../CMakeLists.txt | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/native/corehost/browserhost/CMakeLists.txt b/src/native/corehost/browserhost/CMakeLists.txt index 45be9846246e18..1d8933720177d5 100644 --- a/src/native/corehost/browserhost/CMakeLists.txt +++ b/src/native/corehost/browserhost/CMakeLists.txt @@ -21,8 +21,6 @@ set_target_properties(browserhost PROPERTIES OUTPUT_NAME dotnet.native) set(CMAKE_EXECUTABLE_SUFFIX ".js") add_dependencies(browserhost System.Native.Browser-Rollup) -add_dependencies(browserhost System.Native.Browser-Static) -add_dependencies(browserhost System.Runtime.InteropServices.JavaScript.Native-Static) LIST(APPEND NATIVE_LIBS hostmisc @@ -95,10 +93,10 @@ target_link_libraries(browserhost PUBLIC BrowserHost-Static ) target_link_libraries(browserhost PRIVATE + ${NATIVE_LIBS} ${START_WHOLE_ARCHIVE} ${RUNTIMEINFO_LIB} ${END_WHOLE_ARCHIVE} - ${NATIVE_LIBS} ) install(TARGETS browserhost DESTINATION corehost COMPONENT runtime) diff --git a/src/native/corehost/browserhost/host/CMakeLists.txt b/src/native/corehost/browserhost/host/CMakeLists.txt index a381e23483d4f1..42d3853e930465 100644 --- a/src/native/corehost/browserhost/host/CMakeLists.txt +++ b/src/native/corehost/browserhost/host/CMakeLists.txt @@ -1,6 +1,7 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. +project(BrowserHost-Static) set(DOTNET_PROJECT_NAME "BrowserHost-Static") include(configure.cmake) diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt index 7866ec4dde7be8..271ef54b649cb8 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt @@ -10,6 +10,8 @@ add_library(System.Runtime.InteropServices.JavaScript.Native-Static STATIC ${BROWSER_INTEROP_SOURCES} ) +add_dependencies(System.Runtime.InteropServices.JavaScript.Native-Static System.Native.Browser-Rollup) + set_target_properties(System.Runtime.InteropServices.JavaScript.Native-Static PROPERTIES OUTPUT_NAME System.Runtime.InteropServices.JavaScript.Native CLEAN_DIRECT_OUTPUT 1) install(TARGETS System.Runtime.InteropServices.JavaScript.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) install(TARGETS System.Runtime.InteropServices.JavaScript.Native-Static DESTINATION sharedFramework COMPONENT runtime) From 99f68c3259a0a4574b7708d9df9b802a328e2d2f Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 14 Oct 2025 20:20:56 +0200 Subject: [PATCH 21/22] CMAKE_BINARY_DIR feedback --- src/native/libs/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index 803f876cc1dc61..49b5607a62b58c 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -21,7 +21,7 @@ if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(GEN_SHARED_LIB 0) if (NOT STATIC_LIB_DESTINATION) if (BUILD_LIBS_NATIVE_BROWSER) - set(STATIC_LIB_DESTINATION $ENV{__CMakeBinDir}/lib) + set(STATIC_LIB_DESTINATION ${CMAKE_BINARY_DIR}/lib) else () set(STATIC_LIB_DESTINATION .) endif () From 11d51e3a0f1f070df40e8938ea04b1c6be60c1fc Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 15 Oct 2025 10:53:21 +0200 Subject: [PATCH 22/22] feedback --- .../corehost/browserhost/CMakeLists.txt | 39 +++++++++++++++++-- .../browserhost/{host => }/browserhost.cpp | 0 .../browserhost/{host => }/config.h.in | 0 .../browserhost/{host => }/configure.cmake | 0 .../corehost/browserhost/host/CMakeLists.txt | 35 ----------------- .../{host => }/libBrowserHost.footer.js | 0 .../libs/Common/JavaScript/CMakeLists.txt | 2 +- src/native/rollup.config.js | 2 +- 8 files changed, 37 insertions(+), 41 deletions(-) rename src/native/corehost/browserhost/{host => }/browserhost.cpp (100%) rename src/native/corehost/browserhost/{host => }/config.h.in (100%) rename src/native/corehost/browserhost/{host => }/configure.cmake (100%) delete mode 100644 src/native/corehost/browserhost/host/CMakeLists.txt rename src/native/corehost/browserhost/{host => }/libBrowserHost.footer.js (100%) diff --git a/src/native/corehost/browserhost/CMakeLists.txt b/src/native/corehost/browserhost/CMakeLists.txt index 1d8933720177d5..b0a8a79d6fc6e2 100644 --- a/src/native/corehost/browserhost/CMakeLists.txt +++ b/src/native/corehost/browserhost/CMakeLists.txt @@ -2,6 +2,41 @@ # The .NET Foundation licenses this file to you under the MIT license. project(browserhost) +set(DOTNET_PROJECT_NAME "BrowserHost-Static") + +# the host library + +include(configure.cmake) + +set(BROWSERHOST_STATIC_SOURCES + ./config.h + ./browserhost.cpp + ../native.rc +) + +add_compile_definitions(FEATURE_APPHOST) +add_definitions(-DFEATURE_APPHOST=1) +add_definitions(-DFEATURE_STATIC_HOST=1) + +add_library(BrowserHost-Static + STATIC + ${BROWSERHOST_STATIC_SOURCES} +) +set_target_properties(BrowserHost-Static PROPERTIES OUTPUT_NAME BrowserHost CLEAN_DIRECT_OUTPUT 1) + +target_compile_options(BrowserHost-Static PRIVATE + -fwasm-exceptions + -msimd128 + ) +target_link_libraries(BrowserHost-Static PRIVATE + hostmisc +) + +install(TARGETS BrowserHost-Static DESTINATION corehost COMPONENT runtime) +install(TARGETS BrowserHost-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) +install(TARGETS BrowserHost-Static DESTINATION sharedFramework COMPONENT runtime) + +# the executable set(DOTNET_PROJECT_NAME "browserhost") set(BROWSERHOST_SOURCES @@ -14,14 +49,10 @@ add_compile_definitions(FEATURE_APPHOST) add_definitions(-DFEATURE_APPHOST=1) add_definitions(-DFEATURE_STATIC_HOST=1) -add_subdirectory(host) - add_executable(browserhost ${BROWSERHOST_SOURCES}) set_target_properties(browserhost PROPERTIES OUTPUT_NAME dotnet.native) set(CMAKE_EXECUTABLE_SUFFIX ".js") -add_dependencies(browserhost System.Native.Browser-Rollup) - LIST(APPEND NATIVE_LIBS hostmisc clrinterpreter diff --git a/src/native/corehost/browserhost/host/browserhost.cpp b/src/native/corehost/browserhost/browserhost.cpp similarity index 100% rename from src/native/corehost/browserhost/host/browserhost.cpp rename to src/native/corehost/browserhost/browserhost.cpp diff --git a/src/native/corehost/browserhost/host/config.h.in b/src/native/corehost/browserhost/config.h.in similarity index 100% rename from src/native/corehost/browserhost/host/config.h.in rename to src/native/corehost/browserhost/config.h.in diff --git a/src/native/corehost/browserhost/host/configure.cmake b/src/native/corehost/browserhost/configure.cmake similarity index 100% rename from src/native/corehost/browserhost/host/configure.cmake rename to src/native/corehost/browserhost/configure.cmake diff --git a/src/native/corehost/browserhost/host/CMakeLists.txt b/src/native/corehost/browserhost/host/CMakeLists.txt deleted file mode 100644 index 42d3853e930465..00000000000000 --- a/src/native/corehost/browserhost/host/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(BrowserHost-Static) -set(DOTNET_PROJECT_NAME "BrowserHost-Static") - -include(configure.cmake) - -set(BROWSERHOST_STATIC_SOURCES - ./config.h - ./browserhost.cpp - ../../native.rc -) - -add_compile_definitions(FEATURE_APPHOST) -add_definitions(-DFEATURE_APPHOST=1) -add_definitions(-DFEATURE_STATIC_HOST=1) - -add_library(BrowserHost-Static - STATIC - ${BROWSERHOST_STATIC_SOURCES} -) -set_target_properties(BrowserHost-Static PROPERTIES OUTPUT_NAME BrowserHost CLEAN_DIRECT_OUTPUT 1) - -target_compile_options(BrowserHost-Static PRIVATE - -fwasm-exceptions - -msimd128 - ) -target_link_libraries(BrowserHost-Static PRIVATE - hostmisc -) - -install(TARGETS BrowserHost-Static DESTINATION corehost COMPONENT runtime) -install(TARGETS BrowserHost-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) -install(TARGETS BrowserHost-Static DESTINATION sharedFramework COMPONENT runtime) diff --git a/src/native/corehost/browserhost/host/libBrowserHost.footer.js b/src/native/corehost/browserhost/libBrowserHost.footer.js similarity index 100% rename from src/native/corehost/browserhost/host/libBrowserHost.footer.js rename to src/native/corehost/browserhost/libBrowserHost.footer.js diff --git a/src/native/libs/Common/JavaScript/CMakeLists.txt b/src/native/libs/Common/JavaScript/CMakeLists.txt index d08e1061003621..77d4364ab06eb4 100644 --- a/src/native/libs/Common/JavaScript/CMakeLists.txt +++ b/src/native/libs/Common/JavaScript/CMakeLists.txt @@ -11,7 +11,7 @@ set(ROLLUP_TS_SOURCES "${CLR_SRC_NATIVE_DIR}/rollup.config.js" "${CLR_SRC_NATIVE_DIR}/rollup.config.defines.js" "${CLR_SRC_NATIVE_DIR}/rollup.config.plugins.js" - "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/libBrowserHost.footer.js" + "${CLR_SRC_NATIVE_DIR}/corehost/browserhost/libBrowserHost.footer.js" "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/libSystem.Browser.Utils.footer.js" "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js" "${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/libSystem.Native.Browser.footer.js" diff --git a/src/native/rollup.config.js b/src/native/rollup.config.js index 5091817a417af7..5c69511139bfbc 100644 --- a/src/native/rollup.config.js +++ b/src/native/rollup.config.js @@ -130,7 +130,7 @@ const libBrowserHost = configure({ name: "libBrowserHost", format: "iife", file: staticLibDestination + "/libBrowserHost.js", - footer: await fs.readFile("./corehost/browserhost/host/libBrowserHost.footer.js"), + footer: await fs.readFile("./corehost/browserhost/libBrowserHost.footer.js"), }], terser: { compress: {