Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions eng/native.props

This file was deleted.

78 changes: 78 additions & 0 deletions eng/native.wasm.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<Project>
<ItemGroup>
<PackageReference Condition="'$(TargetsWasm)' == 'true'" Include="Microsoft.NETCore.Runtime.ICU.Transport" PrivateAssets="all" Version="$(MicrosoftNETCoreRuntimeICUTransportVersion)" GeneratePathProperty="true" />
<PackageReference Condition="'$(TargetsWasm)' == 'true'" Include="System.Runtime.TimeZoneData" PrivateAssets="all" Version="$(SystemRuntimeTimeZoneDataVersion)" GeneratePathProperty="true" />
</ItemGroup>

<PropertyGroup>
<_RuntimeVariant />
<_RuntimeVariant Condition="'$(WasmEnableThreads)' == 'true'">-threads</_RuntimeVariant>

<_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != '' and '$(TargetsWasm)' == 'true'">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native</_IcuDir>
<_TzdDir Condition="'$(PkgSystem_Runtime_TimeZoneData)' != '' and '$(TargetsWasm)' == 'true'">$([MSBuild]::NormalizePath('$(PkgSystem_Runtime_TimeZoneData)', 'contentFiles', 'any', 'any', 'data'))</_TzdDir>
</PropertyGroup>

<ItemGroup>
<NativeCMakeArg Condition="'$(_IcuDir)' != ''" Include="-cmakeargs &quot;-DCMAKE_ICU_DIR=$(_IcuDir)&quot;" />
<NativeCMakeArg Condition="'$(_TzdDir)' != ''" Include="-cmakeargs &quot;-DCMAKE_TZD_DIR=$(_TzdDir)&quot;" />
<NativeCMakeArg Condition="'$(RuntimeFlavor)' == 'Mono'" Include="-cmakeargs &quot;-DCLR_CMAKE_RUNTIME_MONO=1&quot;" />
<NativeCMakeArg Condition="'$(RuntimeFlavor)' == 'CoreCLR'" Include="-cmakeargs &quot;-DCLR_CMAKE_RUNTIME_CORECLR=1&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_PRODUCT_VERSION=$(ProductVersion)&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_CONTINUOUS_INTEGRATION_BUILD=$(ContinuousIntegrationBuild)&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_NET_CORE_APP_CURRENT_VERSION=$(NetCoreAppCurrentVersion)&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_BUILD_LIBRARIES_CONFIGURATION=$(LibrariesConfiguration)&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_BUILD_RUNTIME_CONFIGURATION=$(RuntimeConfiguration)&quot;" />
<NativeCMakeArg Condition="'$(TargetsBrowser)' == 'true' and '$(RuntimeFlavor)' == 'CoreCLR'" Include="-cmakeargs &quot;-DBUILD_LIBS_NATIVE_BROWSER=1&quot;" />
</ItemGroup>

<Target Name="GenerateEmccExports" Condition="'$(TargetsBrowser)' == 'true'">
<ItemGroup>
<EmccExportedRuntimeMethod Include="FS" />
<EmccExportedRuntimeMethod Include="out" />
<EmccExportedRuntimeMethod Include="err" />
<EmccExportedRuntimeMethod Include="ccall" />
<EmccExportedRuntimeMethod Include="cwrap" />
<EmccExportedRuntimeMethod Include="setValue" />
<EmccExportedRuntimeMethod Include="getValue" />
<EmccExportedRuntimeMethod Include="UTF8ToString" />
<EmccExportedRuntimeMethod Include="UTF8ArrayToString" />
<EmccExportedRuntimeMethod Include="lengthBytesUTF8" />
<EmccExportedRuntimeMethod Include="stringToUTF8Array" />
<EmccExportedRuntimeMethod Include="FS_createPath" />
<EmccExportedRuntimeMethod Include="FS_createDataFile" />
<EmccExportedRuntimeMethod Include="removeRunDependency" />
<EmccExportedRuntimeMethod Include="addRunDependency" />
<EmccExportedRuntimeMethod Include="addFunction" />
<EmccExportedRuntimeMethod Include="safeSetTimeout" />
<EmccExportedRuntimeMethod Include="runtimeKeepalivePush" />
<EmccExportedRuntimeMethod Include="runtimeKeepalivePop" />
<EmccExportedRuntimeMethod Include="maybeExit" />
<EmccExportedRuntimeMethod Include="abort" />

<EmccExportedFunction Include="_free" />
<EmccExportedFunction Include="_htons" />
<EmccExportedFunction Include="_malloc" />
<EmccExportedFunction Include="_sbrk" />
<EmccExportedFunction Include="_memalign" />
<EmccExportedFunction Include="_posix_memalign" />
<EmccExportedFunction Include="_memset" />
<EmccExportedFunction Include="_ntohs" />
<EmccExportedFunction Include="stackAlloc" />
<EmccExportedFunction Include="stackRestore" />
<EmccExportedFunction Include="stackSave" />
<!-- TODO-WASM hide -->
<EmccExportedFunction Include="_GetDotNetRuntimeContractDescriptor" />
</ItemGroup>
<PropertyGroup>
<_EmccExportedRuntimeMethods>@(EmccExportedRuntimeMethod -> '%(Identity)',',')</_EmccExportedRuntimeMethods>
<_EmccExportedFunctions>@(EmccExportedFunction -> '%(Identity)',',')</_EmccExportedFunctions>
</PropertyGroup>

<ItemGroup>
<NativeCMakeArg Condition="'$(TargetsBrowser)' == 'true'" Include="-cmakeargs &quot;-DCMAKE_EMCC_EXPORTED_RUNTIME_METHODS=$(_EmccExportedRuntimeMethods)&quot;" />
<NativeCMakeArg Condition="'$(TargetsBrowser)' == 'true'" Include="-cmakeargs &quot;-DCMAKE_EMCC_EXPORTED_FUNCTIONS=$(_EmccExportedFunctions)&quot;" />
</ItemGroup>

</Target>

</Project>
4 changes: 4 additions & 0 deletions eng/testing/tests.browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<EMSDK_PATH Condition="'$(EMSDK_PATH)' == '' and '$(ContinuousIntegrationBuild)' == 'true' and '$(MonoProjectRoot)' != ''">$([MSBuild]::NormalizeDirectory($(BrowserProjectRoot), 'emsdk'))</EMSDK_PATH>

<WasmEmitSymbolMap Condition="'$(WasmEmitSymbolMap)' == ''">true</WasmEmitSymbolMap>
<InvariantGlobalization Condition="'$(InvariantGlobalization)' == ''">false</InvariantGlobalization>

<_WasmMainJSFileName Condition="'$(WasmMainJSPath)' != ''">$([System.IO.Path]::GetFileName('$(WasmMainJSPath)'))</_WasmMainJSFileName>
<_WasmStrictVersionMatch Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</_WasmStrictVersionMatch>
Expand All @@ -34,6 +35,9 @@
<UseSystemResourceKeys Condition="'$(UseSystemResourceKeys)' == ''">false</UseSystemResourceKeys>
<EventSourceSupport Condition="'$(EventSourceSupport)' == ''">true</EventSourceSupport>
<NullabilityInfoContextSupport Condition="'$(NullabilityInfoContextSupport)' == ''">true</NullabilityInfoContextSupport>

<!-- TODO-WASM https://github.com/dotnet/runtime/issues/120248 -->
<WasmEnableWebcil Condition="'$(RuntimeFlavor)' == 'CoreCLR'">false</WasmEnableWebcil>
</PropertyGroup>

<!-- We expect WASM users to indicate they would like to have bigger download size by adding WasmIncludeFullIcuData, -->
Expand Down
10 changes: 7 additions & 3 deletions eng/testing/workloads-browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<Target Name="_GetWorkloadsToInstall" DependsOnTargets="_SetPackageVersionForWorkloadsTesting" Returns="@(WorkloadIdForTesting);@(WorkloadCombinationsToInstall)">
<Error Condition="'$(RIDForWorkload)' == ''" Text="$(RIDForWorkload) is unset" />
<ItemGroup>
<ItemGroup Condition="'$(RuntimeFlavor)' == 'Mono'">
<WorkloadIdForTesting Include="wasm-tools;wasm-experimental"
ManifestName="Microsoft.NET.Workload.Mono.ToolChain.Current"
Variant="latest"
Expand Down Expand Up @@ -67,11 +67,15 @@
</_DefaultRuntimePackNuGetPath>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'$(RuntimeFlavor)' == 'Mono'">
<_RuntimePackNugetAvailable Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono.$(RIDForWorkload).*$(PackageVersionForWorkloadManifests).nupkg" />
<_RuntimePackNugetAvailable Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono.*.$(RIDForWorkload).*$(PackageVersionForWorkloadManifests).nupkg" />
<_RuntimePackNugetAvailable Remove="@(_RuntimePackNugetAvailable)" Condition="$([System.String]::new('%(_RuntimePackNugetAvailable.FileName)').EndsWith('.symbols'))" />
</ItemGroup>
<ItemGroup Condition="'$(RuntimeFlavor)' == 'CoreCLR'">
<_RuntimePackNugetAvailable Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.$(RIDForWorkload).*$(PackageVersionForWorkloadManifests).nupkg" />
<_RuntimePackNugetAvailable Remove="@(_RuntimePackNugetAvailable)" Condition="$([System.String]::new('%(_RuntimePackNugetAvailable.FileName)').EndsWith('.symbols'))" />
</ItemGroup>

<Error Condition="@(_RuntimePackNugetAvailable -> Count()) != 2 and @(_RuntimePackNugetAvailable -> Count()) != 1"
Text="Expected to find either one or two in $(LibrariesShippingPackagesDir): @(_RuntimePackNugetAvailable->'%(FileName)%(Extension)')" />
Expand All @@ -87,7 +91,7 @@
</ItemGroup>

<Message
Condition="@(_RuntimePackNugetAvailable -> Count()) == 1"
Condition="'$(RuntimeFlavor)' == 'Mono' and @(_RuntimePackNugetAvailable -> Count()) == 1"
Importance="High"
Text="
********************
Expand Down
17 changes: 10 additions & 7 deletions src/coreclr/hosts/corerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,23 @@ else()
"${STATIC_LIB_DESTINATION}/libSystem.Native.Browser.js")
set(JS_SYSTEM_BROWSER_UTILS
"${STATIC_LIB_DESTINATION}/libSystem.Browser.Utils.js")
set(JS_CORE_RUN_PRE
"${CMAKE_CURRENT_SOURCE_DIR}/wasm/libCorerun.pre.js")
set(JS_CORE_RUN
"${CMAKE_CURRENT_SOURCE_DIR}/wasm/libCorerun.extpost.js")
set_target_properties(corerun PROPERTIES
LINK_DEPENDS "${JS_CORE_RUN_PRE};${JS_SYSTEM_NATIVE_BROWSER};${JS_SYSTEM_BROWSER_UTILS};"
LINK_FLAGS "--pre-js ${JS_CORE_RUN_PRE} --js-library ${JS_SYSTEM_NATIVE_BROWSER} --js-library ${JS_SYSTEM_BROWSER_UTILS}"
LINK_DEPENDS "${JS_CORE_RUN};${JS_SYSTEM_NATIVE_BROWSER};${JS_SYSTEM_BROWSER_UTILS};"
LINK_FLAGS "--js-library ${JS_SYSTEM_NATIVE_BROWSER} --js-library ${JS_SYSTEM_BROWSER_UTILS} --extern-post-js ${JS_CORE_RUN}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
target_link_options(corerun PRIVATE
-sEXIT_RUNTIME=0
-sINITIAL_MEMORY=134217728
-sMAXIMUM_MEMORY=2147483648
-sALLOW_MEMORY_GROWTH=1
-sSTACK_SIZE=5MB
-sEXPORTED_RUNTIME_METHODS=cwrap,ccall,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAP64,HEAPU64,HEAPF32,HEAPF64,safeSetTimeout,maybeExit,exitJS,abort,lengthBytesUTF8,UTF8ToString,stringToUTF8Array
-sEXPORTED_FUNCTIONS=_main,_GetDotNetRuntimeContractDescriptor
-sMODULARIZE=1
-sEXPORT_ES6=1
-sEXPORTED_RUNTIME_METHODS=ENV,${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS}
-sEXPORTED_FUNCTIONS=_main,${CMAKE_EMCC_EXPORTED_FUNCTIONS}
-sEXPORT_NAME=createDotnetRuntime
-sENVIRONMENT=node,shell,web
-Wl,-error-limit=0)

Expand All @@ -96,7 +99,7 @@ else()
# If not running in the browser, add
# Node.js file system support.
target_link_options(corerun PRIVATE
-lnoderawfs.js
-sNODERAWFS=1
-lnodefs.js)
endif()
endif()
Expand Down
43 changes: 43 additions & 0 deletions src/coreclr/hosts/corerun/wasm/libCorerun.extpost.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

/* eslint-disable no-undef */
/* eslint-disable space-before-function-paren */
/* eslint-disable @typescript-eslint/no-unused-vars */
var fetch = fetch || undefined; var dotnetNativeModuleLoaded = false; var dotnetInternals = null;
export function selfRun() {
const Module = {};
const corePreRun = () => {
// copy all node/shell env variables to emscripten env
if (globalThis.process && globalThis.process.env) {
for (const [key, value] of Object.entries(process.env)) {
Module.ENV[key] = value;
}
}

Module.ENV["DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"] = "true";
};
Module.preRun = [corePreRun];

const runtimeApi = {
Module,
INTERNAL: {},
runtimeId: 0,
runtimeBuildInfo: {
productVersion: "corerun",
gitHash: "corerun",
buildConfiguration: "corerun",
wasmEnableThreads: false,
wasmEnableSIMD: true,
wasmEnableExceptionHandling: true,
},
};
dotnetInternals = [
runtimeApi,
[],
];

createDotnetRuntime(runtimeApi.Module);
}
selfRun();
20 changes: 0 additions & 20 deletions src/coreclr/hosts/corerun/wasm/libCorerun.pre.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/coreclr/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<ProjectReference Condition="'$(HasCdacBuildTool)' == 'true'" Include="tools\cdac-build-tool\cdac-build-tool.csproj" ReferenceOutputAssembly="false" GlobalPropertiesToRemove="$(NativeBuildPartitionPropertiesToRemove)" />
</ItemGroup>

<Import Project="$(RepositoryEngineeringDir)native.props" />
<Import Project="$(RepositoryEngineeringDir)native.wasm.targets" />
<Import Project="$(RepositoryEngineeringDir)nativepgo.targets" />

<Target Name="BuildRuntime"
DependsOnTargets="GetPgoDataPackagePath"
DependsOnTargets="GetPgoDataPackagePath;GenerateEmccExports"
BeforeTargets="Build">
<ItemGroup>
<_CMakeArgs Include="$(CMakeArgs)" />
Expand Down
Loading
Loading