runtime icon indicating copy to clipboard operation
runtime copied to clipboard

[wasm][wasi] Throw error when WasmBuildNative is explicitly set to false during a single-file build

Open mkhamoyan opened this issue 1 year ago • 24 comments

WasmSingleFileBundle requires native build; therefore, explicitly setting WasmBuildNative to false is not allowed.

Fixes https://github.com/dotnet/runtime/issues/96863

mkhamoyan avatar Feb 07 '24 11:02 mkhamoyan

/azp run runtime-wasm

mkhamoyan avatar Feb 07 '24 11:02 mkhamoyan

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Feb 07 '24 11:02 azure-pipelines[bot]

Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.

Issue Details

WasmSingleFileBundle requires native build; therefore, explicitly setting WasmBuildNative to false is not allowed.

Fixes https://github.com/dotnet/runtime/issues/96863

Author: mkhamoyan
Assignees: mkhamoyan
Labels:

arch-wasm, area-Build-mono, os-wasi

Milestone: -

ghost avatar Feb 07 '24 11:02 ghost

I wonder if WasmSingleFileBundle should also be added to _BoolPropertiesThatTriggerRelinking instead of

That is a good idea. The error should happen everytime when _BoolPropertiesThatTriggerRelinking is triggered and the WasmBuildNative is explicitly set to false.

maraf avatar Feb 07 '24 11:02 maraf

I wonder if WasmSingleFileBundle should also be added to _BoolPropertiesThatTriggerRelinking instead of

https://github.com/dotnet/runtime/blob/97aba7843fbb033fdb02f9f25d52765e7c89bd02/src/mono/wasm/build/WasmApp.Common.targets#L524

Thanks! Updated.

mkhamoyan avatar Feb 07 '24 12:02 mkhamoyan

/azp run runtime-wasm

mkhamoyan avatar Feb 07 '24 12:02 mkhamoyan

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Feb 07 '24 12:02 azure-pipelines[bot]

I see few common _BoolPropertiesThatTriggerRelinking in BrowserWasmApp.targets and in WasiApp.targets could we have them in common place ?

Moved only WasmNativeStrip. WasmEnableSIMD has different default values on wasi/browser.

mkhamoyan avatar Feb 07 '24 16:02 mkhamoyan

/azp run runtime-wasm

mkhamoyan avatar Feb 07 '24 16:02 mkhamoyan

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Feb 07 '24 16:02 azure-pipelines[bot]

That is a good idea. The error should happen everytime when _BoolPropertiesThatTriggerRelinking is triggered and the WasmBuildNative is explicitly set to false.

Can we implement a general rule? For example setting WasmEnableSIMD=false and WasmBuildNative=false is also not supported combination.

maraf avatar Feb 07 '24 18:02 maraf

/azp run runtime-wasm

mkhamoyan avatar Feb 08 '24 13:02 mkhamoyan

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Feb 08 '24 13:02 azure-pipelines[bot]

Can we implement a general rule? For example setting WasmEnableSIMD=false and WasmBuildNative=false is also not supported combination.

Updated the rule.

mkhamoyan avatar Feb 08 '24 13:02 mkhamoyan

dotnet-linker-tests fail for some reason

pavelsavara avatar Feb 08 '24 16:02 pavelsavara

dotnet-linker-tests fail for some reason

yes , that's because we run these tests with WasmBuildNative=false https://github.com/dotnet/runtime/blob/e3165d613ff58466e3508114c20296777d378415/eng/pipelines/runtime-linker-tests.yml#L127 And artifacts/bin/trimmingTests/projects/System.Runtime.TrimmingTests/InvariantGlobalizationTrue/browser-wasm/project.csproj has InvariantGlobalization enabled. I'm thinking that test suite is not configured correctly, and we need to enable WasmBuildNative=true there.

@radical do you remember why this change was needed https://github.com/dotnet/runtime/commit/eceb5c8951ca3e5902a6eecdd594f82916ff4762 ?

mkhamoyan avatar Feb 08 '24 16:02 mkhamoyan

@radical do you remember why this change was needed https://github.com/dotnet/runtime/commit/eceb5c8951ca3e5902a6eecdd594f82916ff4762 ?

We didn't want native relinking for the linker tests. You can remove that WasmBuildNative=false from the command line, but then ensure that only the InvariantGlobalization* tests are being relinked on the dotnet-linker-tests pipeline.

radical avatar Feb 08 '24 17:02 radical

We didn't want native relinking for the linker tests. You can remove that WasmBuildNative=false from the command line, but then ensure that only the InvariantGlobalization* tests are being relinked on the dotnet-linker-tests pipeline.

Removed WasmBuildNative=false , will check if it affects build times.

mkhamoyan avatar Feb 09 '24 09:02 mkhamoyan

/azp run runtime-wasm

mkhamoyan avatar Feb 09 '24 09:02 mkhamoyan

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Feb 09 '24 09:02 azure-pipelines[bot]

Removed WasmBuildNative=false , will check if it affects build times.

This caused other failures like Could not find AOT cross compiler at $(_MonoAotCrossCompilerPath)=.

mkhamoyan avatar Feb 09 '24 10:02 mkhamoyan

Removed WasmBuildNative=false , will check if it affects build times.

This caused other failures like Could not find AOT cross compiler at $(_MonoAotCrossCompilerPath)=.

Make sure that WasmApp.InTree.targets is imported at https://github.com/dotnet/runtime/blob/ac149359907423b90513a8fa392b6977fd919a7c/eng/testing/tests.browser.targets . Check the binlog to see why it didn't get imported. It might be explicitly disabled somewhere for trimming tests.

radical avatar Feb 09 '24 19:02 radical

Make sure that WasmApp.InTree.targets is imported at https://github.com/dotnet/runtime/blob/ac149359907423b90513a8fa392b6977fd919a7c/eng/testing/tests.browser.targets . Check the binlog to see why it didn't get imported. It might be explicitly disabled somewhere for trimming tests.

From binlog WasmApp.InTree.targets is imported.

After executing this block https://github.com/dotnet/runtime/blob/9699f39112b2aea89a05a74199baf9049db85537/src/mono/browser/build/BrowserWasmApp.targets#L233 _MonoAotCrossCompilerPath is empty , which is strange as from binlog I see

MonoAotCrossCompiler
                       /__w/1/s/artifacts/bin/mono/browser.wasm.Release/cross/browser-wasm/mono-aot-cross
                           RuntimeIdentifier = browser-wasm

mkhamoyan avatar Feb 12 '24 11:02 mkhamoyan

Looking at the binlog the native build is being run for all the projects which is not what you want. And that is happening because of WasmNativeStrip is defaulting to true. Explicitly set that to false for the trimming projects.

Then you should have only the projects that do really want a native build like the ones with InvariantGlobalization.

which is strange as from binlog I see

MonoAotCrossCompiler
                      /__w/1/s/artifacts/bin/mono/browser.wasm.Release/cross/browser-wasm/mono-aot-cross
                          RuntimeIdentifier = browser-wasm

It is set only in the llvm-init project. src/mono/Directory.Build.props does set this up for in-tree builds, but it is not imported when the project is in artifacts because that is explicitly disabled with a custom Directory.Build.props. So, you would need to make the item available in the trimming project. You could do bring this in via eng/targetingpacks.targets.

radical avatar Feb 12 '24 21:02 radical

/azp run runtime-wasm

mkhamoyan avatar Feb 15 '24 15:02 mkhamoyan

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Feb 15 '24 15:02 azure-pipelines[bot]

/azp run runtime-wasm

mkhamoyan avatar Feb 15 '24 15:02 mkhamoyan

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Feb 15 '24 15:02 azure-pipelines[bot]

/azp run runtime-wasm

mkhamoyan avatar Feb 21 '24 09:02 mkhamoyan

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Feb 21 '24 09:02 azure-pipelines[bot]