Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions eng/codeOptimization.targets
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<PropertyGroup>
<!-- Only use mibc files if UsingToolIbcOptimization is false. Allows enabling/disabling using ibc instead of mibc data -->
<IncludeMibcFilesInReadyToRun Condition="'$(UsingToolIbcOptimization)' != 'true' and '$(EnableNgenOptimization)' == 'true' and '$(DotNetBuildSourceOnly)' != 'true'">true</IncludeMibcFilesInReadyToRun>
<!-- TODO-WASM: crossgen2 crashes emitting embedded PGO data with cross-module R2R for wasm, and there is no
wasm PGO profile to gain from. Re-enable once https://github.com/dotnet/runtime/issues/132825 is fixed. -->
<IncludeMibcFilesInReadyToRun Condition="'$(TargetOS)' == 'browser' or '$(TargetOS)' == 'wasi'"></IncludeMibcFilesInReadyToRun>
</PropertyGroup>
<ItemGroup>
<PublishReadyToRunPgoFiles Condition="'$(IncludeMibcFilesInReadyToRun)' == 'true'" Include="$(CoreCLRArtifactsPath)StandardOptimizationData.mibc"/>
Expand Down
6 changes: 5 additions & 1 deletion eng/testing/tests.browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
<WasmEnableHotReload>false</WasmEnableHotReload>
<CompressionEnabled>false</CompressionEnabled>
<DisableBuildCompression>true</DisableBuildCompression>
<!-- WASM-TODO enable trimming https://github.com/dotnet/runtime/issues/133193 -->
<PublishTrimmed>false</PublishTrimmed>
<PublishTrimmed Condition="'$(RunAOTCompilation)' == 'true' or '$(TestTrimming)' == 'true'">true</PublishTrimmed>
<!-- Merged runtime-test wrappers are not trim-safe (they crash ILLink); keep them untrimmed unless they explicitly opt in below. -->
<PublishTrimmed Condition="'$(TestFramework)' == 'GeneratedRunner'">false</PublishTrimmed>
Comment thread
pavelsavara marked this conversation as resolved.
<PublishTrimmed Condition="'$(RunAOTCompilation)' == 'true' or '$(PublishReadyToRun)' == 'true' or '$(TestTrimming)' == 'true'">true</PublishTrimmed>
<_WasmInTreeDefaults>false</_WasmInTreeDefaults>
<WasmBuildNativeImplicitInReleaseConfiguration>false</WasmBuildNativeImplicitInReleaseConfiguration>

<ResolveWasmOutputsDependsOn>
$(ResolveWasmOutputsDependsOn);
Expand Down
6 changes: 5 additions & 1 deletion eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@
<_ResolvedStreamConformanceTests
Include="@(ResolvedFileToPublish)"
Condition="'%(ResolvedFileToPublish.FileName)' == 'StreamConformanceTests'" />
<_ResolvedTestUtilities
Include="@(ResolvedFileToPublish)"
Condition="'%(ResolvedFileToPublish.FileName)' == 'TestUtilities'" />
<TrimmerRootDescriptor Include="$(MSBuildThisFileDirectory)ILLink.Descriptor.xunit.xml" Condition="'$(SkipXunitTrimmerDescriptor)' != 'true'" />
<TrimmerRootDescriptor Include="$(MSBuildThisFileDirectory)ILLink.Descriptor.TestUtilities.xml" Condition="'$(SkipTestUtilitiesReference)' != 'true'" />
<!-- Only root TestUtilities when it is actually in the link set; some trimmed apps don't reference it. -->
<TrimmerRootDescriptor Include="$(MSBuildThisFileDirectory)ILLink.Descriptor.TestUtilities.xml" Condition="'$(SkipTestUtilitiesReference)' != 'true' and '@(_ResolvedTestUtilities)' != ''" />
<TrimmerRootDescriptor
Include="$(MSBuildThisFileDirectory)ILLink.Descriptor.StreamConformanceTests.xml"
Condition="'$(SkipTestUtilitiesReference)' != 'true' and '$(TargetsAppleMobile)' == 'true' and '@(_ResolvedStreamConformanceTests)' != ''" />
Expand Down
14 changes: 14 additions & 0 deletions eng/testing/tests.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@
<NoWarn>$(NoWarn);IL2121</NoWarn>
</PropertyGroup>

<Target Name="_RootWasmTestRunnerForTrimming"
BeforeTargets="PrepareForILLink"
Condition="'$(TestFramework)' == 'xunit' and '$(PublishTrimmed)' == 'true' and '$(EnableAggressiveTrimming)' != 'true'">
<ItemGroup>
<TrimmerRootAssembly Include="WasmTestRunner" RootMode="all" />

<TrimmerRootDescriptor Include="$(MSBuildThisFileDirectory)ILLink.Descriptor.xunit.xml" Condition="'$(SkipXunitTrimmerDescriptor)' != 'true'" />

<!-- Only root TestUtilities when it is actually in the link set; some trimmed apps don't reference it. -->
<_ResolvedTestUtilities Include="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.FileName)' == 'TestUtilities'" />
<TrimmerRootDescriptor Include="$(MSBuildThisFileDirectory)ILLink.Descriptor.TestUtilities.xml" Condition="'$(SkipTestUtilitiesReference)' != 'true' and '@(_ResolvedTestUtilities)' != ''" />
</ItemGroup>
</Target>

<PropertyGroup>
<BuildAOTTestsOn Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(Scenario)' == 'BuildWasmApps'">helix</BuildAOTTestsOn>
<BuildAOTTestsOn Condition="'$(BuildAOTTestsOnHelix)' == 'true'">helix</BuildAOTTestsOn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
Suppress the NU1511 warning in the whole project as putting it on a P2P doesn't work: https://github.com/NuGet/Home/issues/14121 -->
<NoWarn>$(NoWarn);NU1511</NoWarn>
<WasmEnableStreamingResponse>false</WasmEnableStreamingResponse>

<!-- Remove when PublishReadyToRun becomes default https://github.com/dotnet/runtime/issues/132466 -->
<PublishReadyToRun Condition="'$(PublishReadyToRun)' == '' and '$(RuntimeFlavor)' == 'CoreCLR'">true</PublishReadyToRun>
</PropertyGroup>
Comment thread
pavelsavara marked this conversation as resolved.

<!-- Make debugging easier -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<linker>
<!-- Real project references on Apple mobile; embedded resources (not link inputs) on browser, so only rooted here. -->
<assembly fullname="System.Runtime.Loader.Test.Assembly" />
<assembly fullname="System.Runtime.Loader.Test.Assembly2" />
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
<assembly fullname="LoaderLinkTest.Dynamic" />
<assembly fullname="ReferencedClassLib" />
<assembly fullname="ReferencedClassLibNeutralIsSatellite" />
<assembly fullname="System.Runtime.Loader.Test.Assembly" />
<assembly fullname="System.Runtime.Loader.Test.Assembly2" />
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetOS)' == 'browser' or ('$(TargetsAppleMobile)' == 'true' and '$(EnableAggressiveTrimming)' == 'true' and '$(UseNativeAotRuntime)' != 'true')">
<TrimmerRootDescriptor Include="$(MSBuildThisFileDirectory)ILLink.Descriptors.xml" />
<!-- Test.Assembly/Test.Assembly2 are embedded resources on browser (not link inputs); only root them where they are real references. -->
<TrimmerRootDescriptor Condition="'$(TargetsAppleMobile)' == 'true'" Include="$(MSBuildThisFileDirectory)ILLink.Descriptors.AppleMobile.xml" />
</ItemGroup>

<Target Name="PreserveEnCAssembliesFromLinking" Condition="'$(TargetOS)' == 'browser' and '$(EnableAggressiveTrimming)' == 'true'" BeforeTargets="PrepareForILLink">
Expand Down
6 changes: 5 additions & 1 deletion src/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@
NativeLibrary items are converted to NativeFileReference items later in the
flow (in _CoreCLRPrepareForNativeBuild) so we have to inspect both here. -->
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and (@(NativeFileReference->Count()) &gt; 0 or @(NativeLibrary->Count()) &gt; 0)">true</WasmBuildNative>
<!-- TODO-WASM: At the moment we are skipping dotnet.native.wasm that always contain diagnostic-server.
Related https://github.com/dotnet/runtime/issues/132772
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(EnableDiagnostics)' == 'true'">true</WasmBuildNative>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(WasmPerformanceInstrumentation)' != ''">true</WasmBuildNative>
-->
</PropertyGroup>

<!-- When publishing a trimmed app, default to relinking in Release, matching the Mono
Expand All @@ -213,7 +217,7 @@
pack only ships thunks for the framework's own [UnmanagedCallersOnly] methods. -->
<PropertyGroup Condition="'$(WasmBuildingForNestedPublish)' == 'true'">
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(PublishTrimmed)' != 'true'">false</WasmBuildNative>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(Configuration)' == 'Release'">true</WasmBuildNative>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(Configuration)' == 'Release' and '$(WasmBuildNativeImplicitInReleaseConfiguration)' != 'false'">true</WasmBuildNative>
</PropertyGroup>
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ public CoreCLRWasmNativeDefaultsTests(ITestOutputHelper output, SharedBuildPerTe
// comparison is textual, so a numerically equal but differently spelled size counts as
// a mismatch. That only costs an unnecessary relink, never a mismatched binary.
{ "<EmccStackSize>2097152</EmccStackSize>", true },
// a non-registry trigger: setting WasmPerformanceInstrumentation always forces a relink
{ "<WasmPerformanceInstrumentation>all</WasmPerformanceInstrumentation>", true },
// WasmPerformanceInstrumentation would force a relink, but that defaulting is temporarily
// disabled in BrowserWasmApp.CoreCLR.targets pending https://github.com/dotnet/runtime/issues/132772,
// so it currently does not relink.
{ "<WasmPerformanceInstrumentation>all</WasmPerformanceInstrumentation>", false },
};

[Theory]
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/build/WasmApp.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@
<!-- not aot, not trimmed app, no reason to relink -->
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(PublishTrimmed)' != 'true'">false</WasmBuildNative>

<!-- default to relinking in Release config -->
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(Configuration)' == 'Release'">true</WasmBuildNative>
<!-- default to relinking in Release config (unless the in-tree defaults are disabled) -->
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(Configuration)' == 'Release' and '$(WasmBuildNativeImplicitInReleaseConfiguration)' != 'false'">true</WasmBuildNative>
</PropertyGroup>

<PropertyGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/native/corehost/corehost.proj
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.js" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.a" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(LibrariesSharedFrameworkDir)*.dat" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(CoreCLRSharedFrameworkDir)libcoreclr_static.a" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(CoreCLRSharedFrameworkDir)libcoreclrminipal.a" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(CoreCLRSharedFrameworkDir)libcoreclrpal.a" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(CoreCLRSharedFrameworkDir)libgcinfo_unix_wasm.a" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(CoreCLRSharedFrameworkDir)libnativeresourcestring.a" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)libBrowserHost.a" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)dotnet.native.js" />
<_MicrosoftNetCoreAppRuntimePackNativeDirFiles Include="$(HostSharedFrameworkDir)dotnet.native.js.symbols" />
Expand Down
13 changes: 13 additions & 0 deletions src/native/libs/Common/JavaScript/host/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import type { InternalExchange, BrowserHostExports, RuntimeAPI, BrowserHostExportsTable, LoaderConfigInternal } from "./types";
import { InternalExchangeIndex } from "./types";
import { _ems_ } from "../ems-ambient";
import { ENVIRONMENT_IS_NODE } from "../per-module";

import GitHash from "consts:gitHash";

Expand Down Expand Up @@ -62,6 +63,18 @@ function setupEmscripten() {
throw new Error("Invalid runtime config, cannot initialize the runtime.");
}

const globalThisAny = globalThis as any;
// On Node.js, process.env is the lowest-precedence source of environment variables: it must not
// override values from the generated manifest (dotnet.js) or from withEnvironmentVariable().
if (ENVIRONMENT_IS_NODE && globalThisAny.process && globalThisAny.process.env) {
const processEnv = globalThisAny.process.env;
for (const key in processEnv) {
if (loaderConfig.environmentVariables[key] === undefined) {
loaderConfig.environmentVariables[key] = processEnv[key];
}
}
}

for (const key in loaderConfig.environmentVariables) {
_ems_.ENV[key] = loaderConfig.environmentVariables[key];
}
Expand Down
9 changes: 9 additions & 0 deletions src/tasks/Crossgen2Tasks/RunReadyToRunCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class RunReadyToRunCompiler : ToolTask
public bool ShowCompilerWarnings { get; set; }
public bool UseCrossgen2 { get; set; }
public string Crossgen2ExtraCommandLineArgs { get; set; }
public string Crossgen2CompositeExtraCommandLineArgs { get; set; }
public ITaskItem[] Crossgen2PgoFiles { get; set; }
Comment thread
pavelsavara marked this conversation as resolved.
public string Crossgen2ContainerFormat { get; set; }

Expand Down Expand Up @@ -382,6 +383,14 @@ private string GenerateCrossgen2ResponseFile()
result.AppendLine($"-u:\"{unrooted.ItemSpec}\"");
}
}

if (!string.IsNullOrEmpty(Crossgen2CompositeExtraCommandLineArgs))
{
foreach (string extraArg in Crossgen2CompositeExtraCommandLineArgs.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
result.AppendLine(extraArg);
}
}
}
else
{
Expand Down
Loading