Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,21 @@
<PublishReadyToRun>true</PublishReadyToRun>
<!-- Disable crossgen on NetBSD, illumos, Solaris and Haiku for now. This can be revisited when we have full support. -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris' or '$(TargetOS)' == 'haiku'">false</PublishReadyToRun>
<!-- TODO-WASM: WASM framework R2R needs the CoreLib model (native/*.wasm webcil + kept lib/*.dll IL),
not the SDK's in-place R2R which replaces lib/*.dll. See dotnet/runtime#121257. -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'browser' or '$(TargetOS)' == 'wasi'">false</PublishReadyToRun>
<PublishReadyToRun Condition="'$(TargetOS)' == 'wasi'">false</PublishReadyToRun>
<PublishReadyToRun Condition="'$(StageTwoBuild)'=='true'">false</PublishReadyToRun>
<UsesMuxerHostModel Condition="'$(TargetsMobile)' != 'true'">true</UsesMuxerHostModel>
<IncludeDiaSymReaderNative Condition="'$(TargetOS)' == 'windows'">true</IncludeDiaSymReaderNative>
<UseLocalCrossgen2Pack>$(PublishReadyToRun)</UseLocalCrossgen2Pack>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetOS)' == 'browser' and '$(PublishReadyToRun)' == 'true'">
<IncludeMibcFilesInReadyToRun>false</IncludeMibcFilesInReadyToRun>
<PublishReadyToRunComposite>false</PublishReadyToRunComposite>
<PublishReadyToRunContainerFormat>wasm</PublishReadyToRunContainerFormat>
<PublishReadyToRunEmitSymbols>false</PublishReadyToRunEmitSymbols>
<_PublishReadyToRunCrossgen2ExtraArgs>--opt-cross-module:*;--codegenopt:JitWasmNyiToR2RUnsupported=1;--codegenopt:JitWasmSimdNyiToR2RUnsupported=1</_PublishReadyToRunCrossgen2ExtraArgs>
</PropertyGroup>

<!-- Use the Mach-O format for Apple mobile platforms as we can't load native code from PE files on these platforms -->
<PropertyGroup Condition="'$(TargetsAppleMobile)' == 'true'">
<ForcePublishReadyToRunComposite>true</ForcePublishReadyToRunComposite>
Expand Down Expand Up @@ -65,77 +71,76 @@
</PropertyGroup>
</Target>

<!--
WASM framework R2R: crossgen each shared-framework assembly to a webcil-in-wasm R2R image under the
pack native/r2r/, keeping the IL in lib/ (the CoreLib model generalized; the SDK's in-place R2R can't
be used as it drops the IL). See dotnet/runtime#121257. WasmFrameworkR2RSubset limits the set.
-->
<PropertyGroup Condition="'$(TargetsBrowser)' == 'true' and '$(RuntimeFlavor)' == 'CoreCLR'">
<WasmEnableFrameworkR2R Condition="'$(WasmEnableFrameworkR2R)' == ''">true</WasmEnableFrameworkR2R>
<_WasmFrameworkR2RDir>$([MSBuild]::NormalizeDirectory('$(IntermediateOutputPath)', 'framework-r2r'))</_WasmFrameworkR2RDir>
</PropertyGroup>

<Target Name="_ComputeBrowserFrameworkR2RInputs"
Condition="'$(WasmEnableFrameworkR2R)' == 'true'"
DependsOnTargets="ResolveLibrariesFromLocalBuild;ResolveRuntimeFilesFromLocalBuild">
<!-- WASM framework R2R uses the SDK compilation pipeline, but keeps the IL in lib/ and puts the
webcil-in-wasm R2R images under native/r2r/ for trimming and per-app R2R. -->
<Target Name="_ConfigureBrowserFrameworkR2R"
Condition="'$(TargetOS)' == 'browser' and '$(PublishReadyToRun)' == 'true'"
BeforeTargets="_PrepareForReadyToRunCompilation">
<ItemGroup>
<_WasmFrameworkR2RInput Include="$(LibrariesSharedFrameworkBinArtifactsPath)*.dll"
Exclude="$(LibrariesSharedFrameworkBinArtifactsPath)*.resources.dll" />
<!-- Optional subset filter for bring-up: keep only assemblies named in WasmFrameworkR2RSubset. -->
<_WasmFrameworkR2RInput Remove="@(_WasmFrameworkR2RInput)"
Condition="'$(WasmFrameworkR2RSubset)' != '' and !$([System.String]::Copy(';$(WasmFrameworkR2RSubset);').Contains(';%(FileName);'))" />
<_WasmFrameworkR2RInput>
<OutputWasm>$(_WasmFrameworkR2RDir)%(FileName).wasm</OutputWasm>
</_WasmFrameworkR2RInput>
<!-- Full crossgen -r closure so a change to ANY referenced framework assembly re-runs crossgen,
even when only a WasmFrameworkR2RSubset is being compiled. -->
<_WasmFrameworkR2RReference Include="$(LibrariesSharedFrameworkBinArtifactsPath)*.dll" />
<_WasmFrameworkR2RExclude Include="$(LibrariesSharedFrameworkBinArtifactsPath)*.dll"
Exclude="@(_WasmFrameworkR2RInput)" />
<PublishReadyToRunExclude Include="@(_WasmFrameworkR2RExclude->'%(FileName)%(Extension)')" />
<PublishReadyToRunExclude Include="System.Private.CoreLib.dll" />
</ItemGroup>
<PropertyGroup>
<_WasmCoreLibIL Condition="Exists('$(CoreCLRArtifactsPath)System.Private.CoreLib.dll')">$(CoreCLRArtifactsPath)System.Private.CoreLib.dll</_WasmCoreLibIL>
<_WasmCoreLibIL Condition="'$(_WasmCoreLibIL)' == '' and Exists('$(CoreCLRArtifactsPath)IL\System.Private.CoreLib.dll')">$(CoreCLRArtifactsPath)IL\System.Private.CoreLib.dll</_WasmCoreLibIL>
<_WasmCrossgen2Exe>$([MSBuild]::NormalizePath('$(Crossgen2InBuildDir)', 'crossgen2$(ExeSuffix)'))</_WasmCrossgen2Exe>
</PropertyGroup>
</Target>

<Target Name="_CrossgenBrowserFrameworkR2R"
Condition="'$(WasmEnableFrameworkR2R)' == 'true'"
DependsOnTargets="_ComputeBrowserFrameworkR2RInputs"
Inputs="@(_WasmFrameworkR2RInput);@(_WasmFrameworkR2RReference);$(_WasmCoreLibIL);$(_WasmCrossgen2Exe)"
Outputs="@(_WasmFrameworkR2RInput->'%(OutputWasm)')">
<MakeDir Directories="$(_WasmFrameworkR2RDir)" />
<Error Condition="!Exists('$(_WasmCrossgen2Exe)')"
Text="WasmEnableFrameworkR2R is true but crossgen2 was not found at '$(_WasmCrossgen2Exe)'. Build the crossgen2 pack or set WasmEnableFrameworkR2R=false." />
<Error Condition="'$(_WasmCoreLibIL)' == ''"
Text="WasmEnableFrameworkR2R is true but System.Private.CoreLib IL was not found under '$(CoreCLRArtifactsPath)'. Build CoreCLR first or set WasmEnableFrameworkR2R=false." />
<Message Importance="High" Text="Crossgen R2R (wasm): %(_WasmFrameworkR2RInput.FileName)" />
<!-- opt-cross-module:* enables cross-module inlining/optimization across the whole shared framework
(the -r closure); still one R2R image per assembly (non-composite). -->
<Exec Command="&quot;$(_WasmCrossgen2Exe)&quot; -o:&quot;%(_WasmFrameworkR2RInput.OutputWasm)&quot; -r:&quot;$(LibrariesSharedFrameworkBinArtifactsPath)*.dll&quot; -r:&quot;$(_WasmCoreLibIL)&quot; &quot;--opt-cross-module:*&quot; --targetarch:$(TargetArchitecture) --targetos:$(TargetOS) --obj-format:wasm --codegenopt:JitWasmNyiToR2RUnsupported=1 --codegenopt:JitWasmSimdNyiToR2RUnsupported=1 -O &quot;%(_WasmFrameworkR2RInput.FullPath)&quot;" />
Text="PublishReadyToRun is true but System.Private.CoreLib IL was not found under '$(CoreCLRArtifactsPath)'. Build CoreCLR first or set PublishReadyToRun=false." />
<Error Condition="!Exists('$(_WasmCrossgen2Exe)')"
Text="PublishReadyToRun is true but crossgen2 was not found at '$(_WasmCrossgen2Exe)'. Build the crossgen2 pack or set PublishReadyToRun=false." />
<ItemGroup>
<_ReadyToRunCompilerInputs Include="$(LibrariesSharedFrameworkBinArtifactsPath)*.dll;$(_WasmCoreLibIL)" />
<_ReadyToRunCompilerInputs Include="$(Crossgen2InBuildDir)*jit*.dll;$(Crossgen2InBuildDir)*jit*.dylib;$(Crossgen2InBuildDir)*jit*.so" />
</ItemGroup>
</Target>

<!-- No Inputs/Outputs so images are packed even when crossgen was incrementally skipped. native/r2r is a
dedicated subfolder (no collision with dotnet.native.wasm / served webcils). CoreLib.wasm comes from
the coreclr build (crossgen-corelib), not this loop. -->
<Target Name="_AddBrowserFrameworkR2RToPackage"
Condition="'$(WasmEnableFrameworkR2R)' == 'true'"
DependsOnTargets="_CrossgenBrowserFrameworkR2R"
BeforeTargets="AddFrameworkFilesToPackage">
Condition="'$(TargetOS)' == 'browser' and '$(PublishReadyToRun)' == 'true'"
AfterTargets="_ReadyToRunSharedFramework">
<ItemGroup>
<_WasmFrameworkR2ROutput Include="@(_WasmFrameworkR2RInput->'%(OutputWasm)')"
Condition="Exists('%(_WasmFrameworkR2RInput.OutputWasm)')" />
<_WasmFrameworkR2RCompileInput Include="@(_ReadyToRunCompileList)"
Condition="$([System.String]::Copy('%(OutputR2RImage)').EndsWith('.wasm'))" />
<_WasmFrameworkR2ROutput Include="@(_WasmFrameworkR2RCompileInput->'%(OutputR2RImage)')" />
<_WasmFrameworkR2ROutput Include="$(CoreCLRArtifactsPath)System.Private.CoreLib.wasm"
Condition="Exists('$(CoreCLRArtifactsPath)System.Private.CoreLib.wasm')" />
<LibrariesRuntimeFiles Include="@(_WasmFrameworkR2ROutput)" IsNative="true" NativeSubDirectory="r2r" />
<FilesToPackage Include="@(_WasmFrameworkR2RCompileInput)"
IsNative=""
DestinationSubDirectory=""
RelativePath="%(FileName)%(Extension)"
TargetPath="runtimes/$(RuntimeIdentifier)/lib/$(TargetFramework)" />
<FilesToPackage Remove="@(_WasmFrameworkR2ROutput)" />
<FilesToPackage Include="@(_WasmFrameworkR2ROutput)"
IsNative="true"
TargetPath="runtimes/$(RuntimeIdentifier)/native/r2r" />
<PlatformManifestFileEntry Include="@(_WasmFrameworkR2ROutput->'%(FileName)%(Extension)')" IsNative="true" />
<_WasmFrameworkR2RLayoutExpected Include="@(_WasmFrameworkR2ROutput)">
<LayoutPath>$([MSBuild]::NormalizePath('$(MicrosoftNetCoreAppRuntimePackNativeDir)', 'r2r', '%(FileName)%(Extension)'))</LayoutPath>
</_WasmFrameworkR2RLayoutExpected>
<!-- Remove out-of-date R2R images left in the in-tree runtime-pack layout by a previous build. -->
<_WasmFrameworkR2RLayoutObsolete Include="$([MSBuild]::NormalizeDirectory('$(MicrosoftNetCoreAppRuntimePackNativeDir)', 'r2r'))*.wasm"
Exclude="@(_WasmFrameworkR2RLayoutExpected->'%(LayoutPath)')"
Condition="'$(MicrosoftNetCoreAppRuntimePackNativeDir)' != ''" />
</ItemGroup>
<!-- In-tree runtime-pack layout is assembled by binplace + libs.pretest (not the nupkg), so copy in explicitly. -->
<Delete Files="@(_WasmFrameworkR2RLayoutObsolete)" />
<Copy Condition="'$(MicrosoftNetCoreAppRuntimePackNativeDir)' != '' and '@(_WasmFrameworkR2ROutput)' != ''"
SourceFiles="@(_WasmFrameworkR2ROutput)"
DestinationFolder="$([MSBuild]::NormalizeDirectory('$(MicrosoftNetCoreAppRuntimePackNativeDir)', 'r2r'))"
SkipUnchangedFiles="true" />
</Target>

<Target Name="_CleanDisabledBrowserFrameworkR2RLayout"
Condition="'$(TargetOS)' == 'browser' and '$(PublishReadyToRun)' != 'true' and '$(MicrosoftNetCoreAppRuntimePackNativeDir)' != ''"
BeforeTargets="AddFrameworkFilesToPackage">
<RemoveDir Directories="$([MSBuild]::NormalizeDirectory('$(MicrosoftNetCoreAppRuntimePackNativeDir)', 'r2r'))" />
</Target>

<!--
Put the mibc file into tools and not into PgoData. Add it after GetFilesToPackage to ensure it isn't automatically classified.
Putting it in tools will also hide it from being part of the RuntimeList.xml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,12 @@ Copyright (c) .NET Foundation. All rights reserved.
DependsOnTargets="_ComputeWasmBuildCandidates"
Condition="'$(_WasmEnableWebcil)' == 'true'">
<ItemGroup>
<_WasmBuildPrebuiltR2RInput Include="$(_WasmBuildPrebuiltR2RDirectory)*.dll;$(_WasmBuildPrebuiltR2RDirectory)*.wasm"
Condition="'$(_WasmBuildPrebuiltR2RDirectory)' != ''" />
<_WasmWebcilBuildStampInput Include="$(MSBuildProjectFullPath);$(MSBuildThisFileFullPath);$(_WebAssemblySdkTasksAssembly)" />
<_WasmWebcilBuildStampLine Include="%(_WasmWebcilStampProperty.Identity)=$(%(_WasmWebcilStampProperty.Identity))" />
<_WasmWebcilBuildStampLine Include="PrebuiltR2R=%(_WasmBuildPrebuiltR2RInput.Identity)|%(_WasmBuildPrebuiltR2RInput.ModifiedTime)" />
<_WasmWebcilBuildStampLine Include="Input=%(_WasmWebcilBuildStampInput.Identity)|%(_WasmWebcilBuildStampInput.ModifiedTime)" />
</ItemGroup>
<WriteLinesToFile File="$(IntermediateOutputPath)wasm-webcil-build.stamp"
Lines="@(_WasmWebcilBuildStampLine)"
Expand All @@ -451,9 +456,9 @@ Copyright (c) .NET Foundation. All rights reserved.
Inputs="@(_WasmDllBuildCandidates);$(IntermediateOutputPath)wasm-webcil-build.stamp;$(MSBuildProjectFullPath);$(MSBuildThisFileFullPath);$(_WebAssemblySdkTasksAssembly)"
Outputs="@(_WasmDllBuildCandidates->'%(WebcilOutputPath)')">

<ConvertDllsToWebcil Candidates="@(_WasmDllBuildCandidates)" IntermediateOutputPath="$(_WasmBuildTmpWebcilPath)" OutputPath="$(_WasmBuildWebcilPath)" IsEnabled="$(_WasmEnableWebcil)" WebcilVersion="$(_WasmWebcilVersion)" PrebuiltR2RDirectory="$(_WasmBuildPrebuiltR2RDirectory)">
<ConvertDllsToWebcil Candidates="@(_WasmDllBuildCandidates)" IntermediateOutputPath="$(_WasmBuildTmpWebcilPath)" OutputPath="$(_WasmBuildWebcilPath)" IsEnabled="$(_WasmEnableWebcil)" WebcilVersion="$(_WasmWebcilVersion)" PrebuiltR2RDirectory="$(_WasmBuildPrebuiltR2RDirectory)" ConversionStamp="$(IntermediateOutputPath)wasm-webcil-build.stamp">
<Output TaskParameter="FileWrites" ItemName="FileWrites" />
<Output TaskParameter="FileWrites" ItemName="_WasmConvertedWebcilOutputs" />
<Output TaskParameter="FilesToTouch" ItemName="_WasmConvertedWebcilOutputs" />
</ConvertDllsToWebcil>

<!-- Touch is needed for property-triggered full rebuilds: the task's content comparison
Expand Down Expand Up @@ -1040,10 +1045,34 @@ Copyright (c) .NET Foundation. All rights reserved.
<_WasmPublishTmpWebcilPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'tmp-webcil', 'publish'))</_WasmPublishTmpWebcilPath>
</PropertyGroup>

<ConvertDllsToWebcil Candidates="@(_NewWasmPublishStaticWebAssets)" IntermediateOutputPath="$(_WasmPublishTmpWebcilPath)" OutputPath="$(_WasmPublishWebcilPath)" IsEnabled="$(_WasmEnableWebcil)" WebcilVersion="$(_WasmWebcilVersion)" PrebuiltR2RDirectory="$(_WasmPublishPrebuiltR2RDirectory)">
<!-- Publish always reaches the conversion task. Keep a composition stamp so changes to properties
or prebuilt R2R membership/timestamps override per-file timestamp checks. -->
<ItemGroup>
<_WasmPublishPrebuiltR2RInput Include="$(_WasmPublishPrebuiltR2RDirectory)*.dll;$(_WasmPublishPrebuiltR2RDirectory)*.wasm"
Condition="'$(_WasmPublishPrebuiltR2RDirectory)' != ''" />
<_WasmPublishWebcilStampInput Include="$(MSBuildProjectFullPath);$(MSBuildThisFileFullPath);$(_WebAssemblySdkTasksAssembly)" />
<_WasmPublishWebcilStampLine Include="_WasmEnableWebcil=$(_WasmEnableWebcil)" />
<_WasmPublishWebcilStampLine Include="_WasmWebcilVersion=$(_WasmWebcilVersion)" />
<_WasmPublishWebcilStampLine Include="PublishReadyToRun=$(PublishReadyToRun)" />
<_WasmPublishWebcilStampLine Include="_WasmPublishPrebuiltR2RDirectory=$(_WasmPublishPrebuiltR2RDirectory)" />
<_WasmPublishWebcilStampLine Include="PrebuiltR2R=%(_WasmPublishPrebuiltR2RInput.Identity)|%(_WasmPublishPrebuiltR2RInput.ModifiedTime)" />
<_WasmPublishWebcilStampLine Include="Input=%(_WasmPublishWebcilStampInput.Identity)|%(_WasmPublishWebcilStampInput.ModifiedTime)" />
</ItemGroup>
<WriteLinesToFile File="$(IntermediateOutputPath)wasm-webcil-publish.stamp"
Lines="@(_WasmPublishWebcilStampLine)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)wasm-webcil-publish.stamp" />
</ItemGroup>

<ConvertDllsToWebcil Candidates="@(_NewWasmPublishStaticWebAssets)" IntermediateOutputPath="$(_WasmPublishTmpWebcilPath)" OutputPath="$(_WasmPublishWebcilPath)" IsEnabled="$(_WasmEnableWebcil)" WebcilVersion="$(_WasmWebcilVersion)" PrebuiltR2RDirectory="$(_WasmPublishPrebuiltR2RDirectory)" ConversionStamp="$(IntermediateOutputPath)wasm-webcil-publish.stamp">
<Output TaskParameter="WebcilCandidates" ItemName="_NewWebcilPublishStaticWebAssetsCandidates" />
<Output TaskParameter="FileWrites" ItemName="FileWrites" />
<Output TaskParameter="FilesToTouch" ItemName="_WasmConvertedPublishWebcilOutputs" />
</ConvertDllsToWebcil>
<!-- Content-equal copies preserve timestamps; mark outputs newer than the processed stamp. -->
<Touch Files="@(_WasmConvertedPublishWebcilOutputs)" Condition="'@(_WasmConvertedPublishWebcilOutputs)' != ''" />

<!-- _NewWebcilPublishStaticWebAssetsCandidates contain the `Fingerprint` and the `Integrity` from the old assets.
Remove them and call DefineStaticWebAssets so that they can get re-computed appropriately.
Expand Down
Loading
Loading