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] Fix up conditions to trigger relink, and require wasm-tools workload #89754

Merged
merged 15 commits into from
Aug 11, 2023

Conversation

radical
Copy link
Member

@radical radical commented Aug 1, 2023

  • Trigger relinking (WasmBuildNative=true) if:

    • WasmNativeStrip=false
    • WasmEnableSIMD=false
    • WasmEnableExceptionHandling=false
    • The above are in addition to the existing conditions
  • Also, trigger "workload required" when:

    • WasmNativeStrip=false
    • WasmEnableExceptionHandling=true
    • InvariantGlobalization=true
    • InvariantTimeZone=true
    • The above are in addition to the existing conditions
  • Rationalize WasmNativeDebugSymbols, and WasmNativeStrip

    • WasmNativeDebugSymbols will cause symbols to be included
      (essentially -g)
    • WasmNativeStrip will cause these to be stripped with wasm-opt --strip-dwarf ...

Fixes #85778 .

@radical radical added the arch-wasm WebAssembly architecture label Aug 1, 2023
@ghost ghost assigned radical Aug 1, 2023
@ghost
Copy link

ghost commented Aug 1, 2023

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

Issue Details

null

Author: radical
Assignees: -
Labels:

arch-wasm

Milestone: -

@radical radical changed the title wip [wasm] Trigger native build when some properties have a different value than the runtime pack Aug 1, 2023
- `WasmNativeStrip=false` - this will trigger a relink. Runtime pack is
  built with `WasmNativeStrip=true`.
- Also, honor `WasmEnableSIMD=false`, and `WasmEnableExceptionHandling=false` for
  publish to trigger a relink.
…voids unnecessary relinking for the no-aot case
.. and don't set `WasmNativeStrip=false` by default, as it triggers
relinking now.
…ativeStrip

- `WasmNativeDebugSymbols` will cause symbols to be included
  (essentially `-g`)
- `WasmNativeStrip` will cause these to be stripped with `wasm-opt
  --strip-dwarf ...`
@radical radical changed the title [wasm] Trigger native build when some properties have a different value than the runtime pack [wasm] Fix up conditions to trigger relink, and require wasm-tools workload Aug 8, 2023
@radical radical requested review from pavelsavara, brickgeorge, kg and radekdoulik and removed request for brickgeorge August 8, 2023 06:01
@radical
Copy link
Member Author

radical commented Aug 8, 2023

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@radical radical marked this pull request as ready for review August 8, 2023 17:29
@radical radical requested a review from lewing as a code owner August 8, 2023 17:29
<_WasmNativeWorkloadNeeded Condition="'$(RunAOTCompilation)' == 'true' or '$(WasmEnableSIMD)' == 'true' or '$(WasmEnableLegacyJsInterop)' == 'false' or '$(WasmBuildNative)' == 'true' or
'$(WasmGenerateAppBundle)' == 'true' or '$(_UsingBlazorOrWasmSdk)' != 'true'" >true</_WasmNativeWorkloadNeeded>
<!-- Keep in sync with WasmApp.Native.targets -->
<_WasmNativeWorkloadNeeded Condition="
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this get evaluated late enough that defaults have already been applied for all these properties? If not, shouldn't most of these be of the form != 'false' instead of == 'true'?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question! Setting _WasmNativeWorkloadNeeded will cause the build to fail if the user does not have the wasm-tools workload installed.

  • The workload is needed for doing any native build, which is when:

    • If the various settings don't match, what the bits in the runtime pack were built with (for example WasmEnableLegacyJsInterop=false)
    • Using native references, or AOT
    • Explicitly asked for, by setting WasmBuildNative=true
  • But without the workload the targets for these native builds are not available at all, so essentially, the user will be expecting a native build but nothing would happen.

  • To prompt the user to install the the workload we set _WasmNativeWorkloadNeeded=true here, and essentially try to determine whether a native build might be needed.

  • We don't want it to get triggered by default

  • So, most of these properties are for settings different from the runtime pack build.

But, having said that, I'm now curious about WasmEnableSIMD, and WasmEnableExceptionHandling, which are true for the runtime pack, and thus AFAIU, the conditions should be inverted. I will check this more, and get back to you.

Copy link
Member Author

Choose a reason for hiding this comment

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

And to answer the original question, we want to explicitly checking for a value that is not the default. And that's why this list needs to be in sync with what we have WasmApp.Native.targets, what wasm.proj` uses for building the runtime pack bits.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, the WasmEnableSIMD, and WasmEnableExceptionHandling were incorrect. Apparently, we hadn't changed them since they were made the default.

</ItemGroup>

<PropertyGroup>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really clever 👍

Copy link
Contributor

@kg kg left a comment

Choose a reason for hiding this comment

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

The parts I understand all look good

This was not changed after `WasmEnableSIMD=true` became the default for
the runtime pack. And update the tests to match.

Effectively:
- `WasmEnableSIMD=true` will not trigger requiring a workload
- `WasmEnableSIMD=false` *will* trigger requiring a workload

Thanks to @kg for the prompt to check all this.
@radical
Copy link
Member Author

radical commented Aug 11, 2023

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@radical
Copy link
Member Author

radical commented Aug 11, 2023

The failure is unrelated, and known.

@radical radical merged commit 26ae097 into dotnet:main Aug 11, 2023
41 of 43 checks passed
@radical radical deleted the wasm-strip-native branch August 11, 2023 03:39
radical added a commit to radical/runtime that referenced this pull request Aug 11, 2023
The following commit caused workload to be required for a blazor app
when `InvariantGlobalization==true`, but this is not required.

```
commit 26ae097
Author: Ankit Jain <radical@gmail.com>
Date:   Thu Aug 10 23:39:10 2023 -0400

    [wasm] Fix up conditions to trigger relink, and require `wasm-tools` workload (dotnet#89754)
```

And this broke some sdk tests.
radical added a commit that referenced this pull request Aug 11, 2023
The following commit caused workload to be required for a blazor app
when `InvariantGlobalization==true`, but this is not required.

```
commit 26ae097
Author: Ankit Jain <radical@gmail.com>
Date:   Thu Aug 10 23:39:10 2023 -0400

    [wasm] Fix up conditions to trigger relink, and require `wasm-tools` workload (#89754)
```

And this broke some sdk tests.
@ghost ghost locked as resolved and limited conversation to collaborators Sep 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Build-mono
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[browser] do native build when preserving native symbols
4 participants