-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[release/6.0][wasm] Add support for native relinking after Build, and AOT after publish #58913
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fix build really fix the build
- And add extra checks for verifying that
Partially fixes dotnet#58826
Renames the temporary folder used for native files built after *Build* target, from `relink` to `for-build`, to be consistent with publish.
When publishing with AOT (`RunAOTCompilation=true`), the assemblies get trimmed by the linker, and copied to a single `linked/` folder. Then `MonoAOTCompiler` runs `mono-aot-cross` on those assemblies. Since, all the assemblies have their dependencies in the same folder too, `mono-aot-cross` can resolve them from there. But when trimming is disabled (`PublishTrimmed=false`), `MonoAOTCompiler` gets paths to assemblies from different folders. For example, some might be from `obj`, nugets etc. Which means that `mono-aot-cross` might not always be able to find dependencies for the assemblies being AOTed. To fix this, if all the input assemblies are not in the same directory, then we copy them to a temporary one, and then run `mono-aot-cross` on them. Fixes dotnet#53804
When publishing with VS, it builds with `$(DeployOnBuild)=true`. That causes `DotNetPublish` to run, which runs `Publish` after `Build`. Wasm targets run `WasmTriggerPublishApp`, that then uses the MSBuild task to invoke `WasmNestedPublishApp, which depends on `Publish`, which depends on `Build`. And that causes `DotNetPublish` again, which results in: ``` sdk/6.0.100-rc.2.21459.15/Sdks/Microsoft.NET.Sdk.Publish/targets/CopyTargets/Microsoft.NET.Sdk.Publish.CopyFiles.targets(80,5): error MSB4006: There is a circular dependency in the target dependency graph involving target "Publish". Since "_CopyAspNetCoreFilesToIntermediateOutputPath" has "DependsOn" dependence on "Publish", the circular is "Publish<-_CopyAspNetCoreFilesToIntermediateOutputPath<-CorePublish<-DotNetPublish<-_PublishBuildAlternative<-Publish". ``` Fix is to unset `DeployOnBuild` for the nested build (`WasmNestedPublishApp`).
This reverts commit a93db63.
This was
linked to
issues
Sep 11, 2021
This reverts commit 1e67f3e.
`DefaultTemplate_AOT_OnlyWithPublishCommandLine_Then_PublishNoAOT` This test runs build thrice: 1. simple build (no relinking) 2. publish+aot 3. publish-no-aot (relinking) This causes the publish folder to have more than one `dotnet*hash*js` files, which breaks the test since we don't know which one is the "current" one.
radical
force-pushed
the
build-publish-6.0
branch
from
September 14, 2021 18:00
0693336
to
eb4ef84
Compare
marek-safar
approved these changes
Sep 15, 2021
radical
added a commit
to radical/runtime
that referenced
this pull request
Sep 15, 2021
… AOT after publish (dotnet#58913) (cherry picked from commit f38d58f)
This was referenced Sep 15, 2021
radical
added a commit
to radical/runtime
that referenced
this pull request
Sep 15, 2021
… AOT after publish (dotnet#58913) (cherry picked from commit f38d58f)
radical
added a commit
to radical/runtime
that referenced
this pull request
Sep 15, 2021
…ild, and AOT after publish (dotnet#58913)" This reverts commit 00859ec. This will be ported in a separate PR.
radical
added a commit
that referenced
this pull request
Sep 16, 2021
ghost
locked as resolved and limited conversation to collaborators
Nov 3, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Wasm app build can run in two scenarios:
dotnet build foo.csproj
A dotnet wasm app has some native wasm files (
dotnet.wasm
, anddotnet.js
). How these files are obtained, or generated:Build
Publish
RunAOTCompilation=true
, then the relinking includes AOT'ed assembliesBuild
Implementation:
Target
WasmBuildApp
runs after
Build
by default$(DisableAutoWasmBuildApp)
$(WasmBuildAppAfterThisTarget)
To run a custom target
$(WasmBuildAppDependsOn)
, and prepend your target name to thatAfterTargets="WasmBuildApp"
on that targetAvoid depending on this target, because it is available only when the workload is installed. Use
$(WasmNativeWorkload)
to check if it is installed.Publish
Implementation:
This part runs as a nested build using a
MSBuild
task, which means that the project gets reevaluated. So, if there were any changes made to items/properties in targets before this, then they won't be visible in the nested build.By default
WasmTriggerPublishApp
runs after thePublish
target, and that triggers the nested buildWasmNestedPublishApp
, which causesBuild
, andPublish
targets to be runBuild
to be run again, if you have any targets that get triggered by that, then they will be running twice.$(WasmBuildingForPublish)
WasmTriggerPublishApp
essentially just invokes the nested publishThis runs after
Publish
$(DisableAutoWasmPublishApp)
$(WasmTriggerPublishAppAfterThisTarget)
To influence the wasm build for publish, use
WasmNestedPublishApp
$(WasmNestedPublishAppDependsOn)
AfterTargets="WasmNestedPublishApp"
If you want to dependsOn on this, then use
DependsOnTargets="WasmTriggerPublishApp"
Fixes [net6.0][BlazorWasmSdk] build does not link native files #56783
Fixes If you build with trimming enabled, future builds with it disabled will produce incorrect output #53612
Fixes [wasm] Avoid unnecessary linking after
Build
, when publishing from VS #58973Also fixes building for AOT with trimming disabled
Fixes Cannot AOT compile with trimming disabled #53804