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][wasi] Throw error when WasmBuildNative is explicitly set to false during a single-file build #98087

Merged
merged 22 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bddc91b
Add error when WasmBuildNative is explicitly false during single-file…
mkhamoyan Feb 7, 2024
7b578c4
Remove the space
mkhamoyan Feb 7, 2024
9e49413
Add WasmSingleFileBundle to _BoolPropertiesThatTriggerRelinking
mkhamoyan Feb 7, 2024
88fb7ed
Move common _BoolPropertiesThatTriggerRelinking to WasmApp.Common.tar…
mkhamoyan Feb 7, 2024
00af6dd
Implement general rule for WasmBuildNative=false
mkhamoyan Feb 8, 2024
dc06c88
Remove WasmBuildNative=false for trimmin tests
mkhamoyan Feb 9, 2024
2d848cb
Merge branch 'main' into wasi_error_message
mkhamoyan Feb 12, 2024
dd84cc5
import MonoAotCrossCompiler
mkhamoyan Feb 13, 2024
fd2cf9f
Revert back explicitly setting false WasmBuildNative
mkhamoyan Feb 13, 2024
1594192
Remove InvariantGlobalization from _BoolPropertiesThatTriggerRelinkin…
mkhamoyan Feb 13, 2024
5492af3
exclude invariantglobalization from error
mkhamoyan Feb 13, 2024
e458b88
Try to enable WasmBuildNative only for InvariantGlobalizationTrue tests
mkhamoyan Feb 14, 2024
9a61a09
Remove InvariantGlobalization from trigger relinking for browser
mkhamoyan Feb 14, 2024
10f820a
Move under target
mkhamoyan Feb 14, 2024
17bb799
disable trigger relinking for InvariantGlobalization
mkhamoyan Feb 14, 2024
71a7599
Move RemoveInvariantGlobalization to testing/linker templates
mkhamoyan Feb 15, 2024
810a970
Add space
mkhamoyan Feb 15, 2024
4716ecc
Add target RemoveInvariantGlobalization only for wasm
mkhamoyan Feb 15, 2024
4f53311
Fix syntax error
mkhamoyan Feb 15, 2024
4ce8ce6
Merge branch 'main' into wasi_error_message
lewing Feb 21, 2024
b6c55f4
Add test case
mkhamoyan Feb 21, 2024
3cf41b4
Update the test case
mkhamoyan Feb 21, 2024
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
12 changes: 12 additions & 0 deletions eng/testing/linker/project.csproj.template
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@
{AdditionalProjectReferences}
</ItemGroup>

<Target Name="RemoveInvariantGlobalization" BeforeTargets="_SetWasmBuildNativeDefaults">
Copy link
Member

Choose a reason for hiding this comment

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

The _SetWasmBuildNativeDefaults target won't be there for other RIDs

Suggested change
<Target Name="RemoveInvariantGlobalization" BeforeTargets="_SetWasmBuildNativeDefaults">
<Target Name="RemoveInvariantGlobalization" BeforeTargets="_SetWasmBuildNativeDefaults" Condition="'$(TargetArchitecture)' == 'wasm' and '$(TargetOS)' == 'browser'">

Copy link
Member

@maraf maraf Feb 15, 2024

Choose a reason for hiding this comment

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

Do the trimming tests run for wasi?
Probably checking TargetArchitecture is enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah TargetArchitecture will be enough.

<ItemGroup>
<_BoolPropertiesThatTriggerRelinking Remove="InvariantGlobalization" />
</ItemGroup>
</Target>
<PropertyGroup>
<PrepareInputsForWasmBuildDependsOn>
$(PrepareInputsForWasmBuildDependsOn);
RemoveInvariantGlobalization;
</PrepareInputsForWasmBuildDependsOn>
</PropertyGroup>

<Target Name="LocateNativeCompiler"
Condition="'$(PublishAot)' == 'true' and '$(_hostOS)' != 'win'"
BeforeTargets="SetupOSSpecificProps">
Expand Down
1 change: 0 additions & 1 deletion src/mono/browser/build/BrowserWasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@

<_BoolPropertiesThatTriggerRelinking Include="WasmEnableSIMD" DefaultValueInRuntimePack="true" />
<_BoolPropertiesThatTriggerRelinking Include="WasmEnableExceptionHandling" DefaultValueInRuntimePack="true" />
<_BoolPropertiesThatTriggerRelinking Include="WasmNativeStrip" DefaultValueInRuntimePack="true" />
</ItemGroup>

<Target Name="_GetWasmGenerateAppBundleDependencies">
Expand Down
1 change: 0 additions & 1 deletion src/mono/wasi/build/WasiApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<ItemGroup>
<_BoolPropertiesThatTriggerRelinking Include="WasmEnableSIMD" DefaultValueInRuntimePack="false" />
<!--<_BoolPropertiesThatTriggerRelinking Include="WasmEnableExceptionHandling" DefaultValueInRuntimePack="true" />-->
<_BoolPropertiesThatTriggerRelinking Include="WasmNativeStrip" DefaultValueInRuntimePack="true" />
</ItemGroup>

<Target Name="_GetWasiGenerateAppBundleDependencies">
Expand Down
23 changes: 16 additions & 7 deletions src/mono/wasm/build/WasmApp.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@
<UsingTask TaskName="MonoTargetsTasks.MarshalingPInvokeScanner" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />
<UsingTask TaskName="EmitBundleObjectFiles" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />

<ItemGroup>
<_BoolPropertiesThatTriggerRelinking Include="InvariantTimezone" DefaultValueInRuntimePack="false" />
<_BoolPropertiesThatTriggerRelinking Include="InvariantGlobalization" DefaultValueInRuntimePack="false" />
<_BoolPropertiesThatTriggerRelinking Include="WasmNativeStrip" DefaultValueInRuntimePack="true" />
<_BoolPropertiesThatTriggerRelinking Include="WasmSingleFileBundle" DefaultValueInRuntimePack="false" />
</ItemGroup>

<PropertyGroup>
<PrepareInputsForWasmBuildDependsOn>
$(PrepareInputsForWasmBuildDependsOn);
Expand Down Expand Up @@ -497,14 +504,18 @@
Text="$(_ToolchainMissingErrorMessage) SDK is required for AOT'ing assemblies." />

<ItemGroup>
<_BoolPropertiesThatTriggerRelinking Include="InvariantTimezone" DefaultValueInRuntimePack="false" />
<_BoolPropertiesThatTriggerRelinking Include="InvariantGlobalization" DefaultValueInRuntimePack="false" />
<_ChangedBoolPropertiesThatTriggerRelinking Include="%(_BoolPropertiesThatTriggerRelinking.Identity)" Condition="'$(%(_BoolPropertiesThatTriggerRelinking.Identity))' != '' and
'$(%(_BoolPropertiesThatTriggerRelinking.Identity))' != '%(_BoolPropertiesThatTriggerRelinking.DefaultValueInRuntimePack)'" />
</ItemGroup>
<PropertyGroup>
<_WasmBuildNativeRequired Condition="@(_ChangedBoolPropertiesThatTriggerRelinking->Count()) > 0">true</_WasmBuildNativeRequired>
</PropertyGroup>

<Error Condition="'$(WasmBuildNative)' == 'false' and '$(_WasmBuildNativeRequired)' == 'true'"
Text="WasmBuildNative is required because %(_ChangedBoolPropertiesThatTriggerRelinking.Identity)=$(%(_ChangedBoolPropertiesThatTriggerRelinking.Identity)), but WasmBuildNative is already set to 'false'." />
Copy link
Member

Choose a reason for hiding this comment

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

Test needed for this.


<PropertyGroup>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and
'$(%(_BoolPropertiesThatTriggerRelinking.Identity))' != '' and
'$(%(_BoolPropertiesThatTriggerRelinking.Identity))' != '%(_BoolPropertiesThatTriggerRelinking.DefaultValueInRuntimePack)'">true</WasmBuildNative>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(_WasmBuildNativeRequired)' == 'true'">true</WasmBuildNative>
</PropertyGroup>

<!-- When Building -->
Expand All @@ -513,15 +524,13 @@
<WasmBuildNative Condition="'$(RunAOTCompilation)' == 'true' and '$(RunAOTCompilationAfterBuild)' == 'true'">true</WasmBuildNative>

<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and @(NativeFileReference->Count()) > 0" >true</WasmBuildNative>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(WasmSingleFileBundle)' == 'true'">true</WasmBuildNative>
</PropertyGroup>

<!-- When Publishing -->
<PropertyGroup Condition="'$(WasmBuildingForNestedPublish)' == 'true'">
<!-- AOT==true overrides WasmBuildNative -->
<WasmBuildNative Condition="'$(RunAOTCompilation)' == 'true'">true</WasmBuildNative>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and @(NativeFileReference->Count()) > 0" >true</WasmBuildNative>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(WasmSingleFileBundle)' == 'true'">true</WasmBuildNative>

<!-- not aot, not trimmed app, no reason to relink -->
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(PublishTrimmed)' != 'true'">false</WasmBuildNative>
Expand Down
Loading