Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] Add the illink substitutions for SIMD #79672

Merged
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 @@ -248,6 +248,8 @@
<PlatformManifestFileEntry Include="emcc-default.rsp" IsNative="true" />
<PlatformManifestFileEntry Include="emcc-link.rsp" IsNative="true" />
<PlatformManifestFileEntry Include="emcc-props.json" IsNative="true" />
<PlatformManifestFileEntry Include="ILLink.Substitutions.WasmIntrinsics.xml" IsNative="true" />
<PlatformManifestFileEntry Include="ILLink.Substitutions.NoWasmIntrinsics.xml" IsNative="true" />
<!-- ICU-specific files -->
<PlatformManifestFileEntry Include="libicudata.a" IsNative="true" />
<PlatformManifestFileEntry Include="libicui18n.a" IsNative="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<PackageFile Include="Sdk\AutoImport.props" TargetPath="Sdk" />
<PackageFile Include="Sdk\Sdk.props" TargetPath="Sdk" />
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\ILLink.Substitutions.*.xml" TargetPath="Sdk" />
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\WasmApp.props" TargetPath="Sdk" />
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\WasmApp.targets" TargetPath="Sdk" />
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\WasmApp.Native.*" TargetPath="Sdk" />
Expand Down
13 changes: 13 additions & 0 deletions src/mono/wasm/build/ILLink.Substitutions.NoWasmIntrinsics.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<linker>
<assembly fullname="System.Private.CoreLib">
<type fullname="System.Numerics.Vector">
<method signature="System.Boolean get_IsHardwareAccelerated()" body="stub" value="false" />
</type>
<type fullname="System.Runtime.Intrinsics.Vector128">
<method signature="System.Boolean get_IsHardwareAccelerated()" body="stub" value="false" />
</type>
<type fullname="System.Runtime.Intrinsics.Wasm.PackedSimd">
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
</type>
</assembly>
</linker>
13 changes: 13 additions & 0 deletions src/mono/wasm/build/ILLink.Substitutions.WasmIntrinsics.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<linker>
<assembly fullname="System.Private.CoreLib">
<type fullname="System.Numerics.Vector">
<method signature="System.Boolean get_IsHardwareAccelerated()" body="stub" value="true" />
</type>
<type fullname="System.Runtime.Intrinsics.Vector128">
<method signature="System.Boolean get_IsHardwareAccelerated()" body="stub" value="true" />
</type>
<type fullname="System.Runtime.Intrinsics.Wasm.PackedSimd">
<method signature="System.Boolean get_IsSupported()" body="stub" value="true" />
</type>
</assembly>
</linker>
2 changes: 2 additions & 0 deletions src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
<WasmGenerateAppBundle Condition="'$(WasmGenerateAppBundle)' == ''">false</WasmGenerateAppBundle>
<UseAppHost>false</UseAppHost>
<TrimMode Condition="'$(TrimMode)' == ''">partial</TrimMode>
<_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' == 'true'">$(_ExtraTrimmerArgs) --substitutions $(MSBuildThisFileDirectory)/ILLink.Substitutions.WasmIntrinsics.xml</_ExtraTrimmerArgs>
<_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' != 'true'">$(_ExtraTrimmerArgs) --substitutions $(MSBuildThisFileDirectory)/ILLink.Substitutions.NoWasmIntrinsics.xml</_ExtraTrimmerArgs>
Comment on lines +112 to +113
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is using private properties from the ILLink sdk. Since this file is shipped, we need to use an alternate way to pass these arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is suggested in the repo docs: https://github.com/dotnet/linker/blob/2db841fc5f6bc7592b66ffe3bd0e1c888d022f93/docs/illink-options.md?plain=1#L3-L7

The illink is IL linker version shipping with .NET Core or .NET 5 platforms. It's bundled with the .NET SDK and most of the options are accessible using msbuild properties but any option can also be passed using _ExtraTrimmerArgs property.

And it is being used by multiple other projects like xamarin-macios.
@marek-safar Is there an alternate property that should be used for passing arbitrary arguments to the linker?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked @vitek-karas about it yesterday and he thinks there's currently no other way to set that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding @sbomer who knows best.

If this is an important scenario we could add more official support for it in the linker SDK bits.


<!-- Temporarily `false`, till sdk gets a fix for supporting the new file -->
<WasmEmitSymbolMap Condition="'$(WasmEmitSymbolMap)' == '' and '$(RunAOTCompilation)' != 'true'">false</WasmEmitSymbolMap>
Expand Down