Skip to content

Conversation

radical
Copy link
Member

@radical radical commented Dec 8, 2023

[wasm/wasi] Consolidate build targets

Current state of build files:

    wasm: WasmApp.props, WasmApp.targets, WasmApp.Native.targets
    wasi: WasiApp.props, WasiApp.targets, WasiApp.Native.targets

The wasm, and wasi build have lot of shared code but that is not
representative in the actual files, since the wasi targets started life
as a quick-copy-comment-out-bits of the wasm targets.

This commit consolidates these into:

    common: WasmApp.Common.props, WasmApp.Common.targets
    wasm : WasmApp.props, WasmApp.targets
    wasi : WasiApp.props, WasiApp.targets

WasmApp.Common.{props,targets}

This has all the common parts of the build for browser-wasm, and wasi,
and includes bits from WasmApp.{props,targets}, and
WasmApp.Native.{props,targets}.

  • The top level target remains the same - WasmBuildApp.

  • There are a few "public" targets that can be hooked into:

    • PrepareInputsForWasmBuild
    • WasmGenerateAppBundle
    • PrepareForWasmBuildNative
    • WasmLinkDotNet
  • all these public targets have corresponding *DependsOn properties
    which can be used for extending the build

note: this commit does not add a public target for AOT, but it might be
added in future.

WasmApp.{props,targets}

This is for browser-wasm projects. The file might be renamed in
future.

WasiApp.{props,targets}

This is for wasi-wasm projects. ILStrip becomes usable as a feature
for wasi-wasm because of this consolidation.

Current state of build files:
```
    wasm: WasmApp.props, WasmApp.targets, WasmApp.Native.targets
    wasi: WasiApp.props, WasiApp.targets, WasiApp.Native.targets
``

The wasm, and wasi build have lot of shared code but that is not
representative in the actual files, since the wasi targets started life
as a quick-copy-comment-out-bits of the wasm targets.

This commit consolidates these into:
```
    common: WasmApp.Common.props, WasmApp.Common.targets
    wasm : WasmApp.props, WasmApp.targets
    wasi : WasiApp.props, WasiApp.targets
```

 ## `WasmApp.Common.{props,targets}`

This has all the common parts of the build for browser-wasm, and wasi,
and includes bits from `WasmApp.{props,targets}`, and
`WasmApp.Native.{props,targets}`.

- The top level target remains the same - `WasmBuildApp`.
- There are a few "public" targets that can be hooked into:
    - `PrepareInputsForWasmBuild`
    - `WasmGenerateAppBundle`
    - `PrepareForWasmBuildNative`
    - `WasmLinkDotNet`

- all these public targets have corresponding `*DependsOn` properties
  which can be used for extending the build

note: this commit does not add a public target for AOT, but it might be
added in future.

 ## WasmApp.{props,targets}

This is for `browser-wasm` projects. The file might be renamed in
future.

 ## WasiApp.{props,targets}

This is for `wasi-wasm` projects. `ILStrip` becomes usable as a feature
for `wasi-wasm` because of this consolidation.
@radical radical added the arch-wasm WebAssembly architecture label Dec 8, 2023
@ghost ghost assigned radical Dec 8, 2023
@ghost ghost added the area-Build-mono label Dec 8, 2023
@ghost
Copy link

ghost commented Dec 8, 2023

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

Issue Details

[wasm/wasi] Consolidate build targets

Current state of build files:

    wasm: WasmApp.props, WasmApp.targets, WasmApp.Native.targets
    wasi: WasiApp.props, WasiApp.targets, WasiApp.Native.targets
``

The wasm, and wasi build have lot of shared code but that is not
representative in the actual files, since the wasi targets started life
as a quick-copy-comment-out-bits of the wasm targets.

This commit consolidates these into:
common: WasmApp.Common.props, WasmApp.Common.targets
wasm : WasmApp.props, WasmApp.targets
wasi : WasiApp.props, WasiApp.targets

 ## `WasmApp.Common.{props,targets}`

This has all the common parts of the build for browser-wasm, and wasi,
and includes bits from `WasmApp.{props,targets}`, and
`WasmApp.Native.{props,targets}`.

- The top level target remains the same - `WasmBuildApp`.
- There are a few "public" targets that can be hooked into:
    - `PrepareInputsForWasmBuild`
    - `WasmGenerateAppBundle`
    - `PrepareForWasmBuildNative`
    - `WasmLinkDotNet`

- all these public targets have corresponding `*DependsOn` properties
  which can be used for extending the build

note: this commit does not add a public target for AOT, but it might be
added in future.

 ## WasmApp.{props,targets}

This is for `browser-wasm` projects. The file might be renamed in
future.

 ## WasiApp.{props,targets}

This is for `wasi-wasm` projects. `ILStrip` becomes usable as a feature
for `wasi-wasm` because of this consolidation.


<table>
  <tr>
    <th align="left">Author:</th>
    <td>radical</td>
  </tr>
  <tr>
    <th align="left">Assignees:</th>
    <td>-</td>
  </tr>
  <tr>
    <th align="left">Labels:</th>
    <td>

`arch-wasm`

</td>
  </tr>
  <tr>
    <th align="left">Milestone:</th>
    <td>-</td>
  </tr>
</table>
</details>

@radical
Copy link
Member Author

radical commented Dec 8, 2023

dotnet/emsdk#621 is needed for this.

@radical
Copy link
Member Author

radical commented Dec 8, 2023

This is admittedly kinda hard to review, so I'm depending on the tests quite a bit. This does not change core specifics of the build, but moves around things, different public targets, and dependencies.

@radical
Copy link
Member Author

radical commented Dec 8, 2023

TODO before merge:

TODO for follow up PRs:

  • add wasi-sdk version check
  • runtime tests - move to using LocalBuild instead of InTree targets

@radical
Copy link
Member Author

radical commented Dec 8, 2023

/azp run runtime-wasm

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

<BundleFiles Include="$(RuntimeConfigFilePath)" TargetDir="publish" />

<BundleFiles Include="$(WasmSharedPath)data\aot-tests\*" TargetDir="publish" />
<!-- FIXME: what would be the correct place to do this? -->
Copy link
Member

Choose a reason for hiding this comment

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

should we rename wasm -> browser (OS) and use wasm for the (architecture) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I avoided those renames in this PR. We are following the pattern you suggested in most places now, like tests.{wasm,browser,wasi}.targets, and recently sendtohelix-{wasm,browser,wasi}.proj.

@radical
Copy link
Member Author

radical commented Dec 8, 2023

For review, for the wasm case I think we have pretty good test coverage to be reasonably confident. There will be likely be some cases missed, or small regressions, which we can be fixed in follow up PRs.
For wasi, we have limited build support right now anyway, and some of that is covered by tests, and this PR makes it possible to have the same kinda features as the wasm build - for example, ilstrip, singlefilebundle (tbd).

@vargaz
Copy link
Contributor

vargaz commented Dec 11, 2023

Would be nice to review/merge this quickly so it doesn't conflict with other PRs, i.e.
#95834

Copy link
Member

@fanyang-mono fanyang-mono left a comment

Choose a reason for hiding this comment

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

ILStrip test looks good to me.

Copy link
Member

@lewing lewing left a comment

Choose a reason for hiding this comment

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

Looks ready to merge then we will need to keep an eye on the builds

@lewing lewing merged commit a128c15 into dotnet:main Dec 11, 2023
@radical radical deleted the wasm-build-consolidate-targets branch December 11, 2023 20:46
radical added a commit to radical/runtime that referenced this pull request Dec 14, 2023
Blazor size regression was fixed by:

```
commit ec31705
Author: Ankit Jain <[email protected]>
Date:   Wed Dec 6 05:36:59 2023 -0500

    [wasm] Fix regressed file sizes for blazor (dotnet#92664)
```

.. but a subsequent PR created close to that undid some of the changes:

```
commit a128c15
Author: Ankit Jain <[email protected]>
Date:   Mon Dec 11 15:45:58 2023 -0500

    [wasm/wasi] Consolidate build targets (dotnet#95775)
```

Essentially, `-g` was being passed to the link, and compile-bc steps.

Found in dotnet/perf-autofiling-issues#25891 .
radical added a commit that referenced this pull request Dec 14, 2023
* [wasm/wasi] Fix size regression

Blazor size regression was fixed by:

```
commit ec31705
Author: Ankit Jain <[email protected]>
Date:   Wed Dec 6 05:36:59 2023 -0500

    [wasm] Fix regressed file sizes for blazor (#92664)
```

.. but a subsequent PR created close to that undid some of the changes:

```
commit a128c15
Author: Ankit Jain <[email protected]>
Date:   Mon Dec 11 15:45:58 2023 -0500

    [wasm/wasi] Consolidate build targets (#95775)
```

Essentially, `-g` was being passed to the link, and compile-bc steps.

Found in dotnet/perf-autofiling-issues#25891 .

* [wasm] Add flag missed in the consolidate PR
@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2024
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.

6 participants