Skip to content

Use lld for ASP.NET Core AOT musl tools - #6798

Merged
akoeplinger merged 2 commits into
mainfrom
damianedwards/fix-aot-build
May 24, 2026
Merged

akoeplinger merged 2 commits into
mainfrom
damianedwards/fix-aot-build

Conversation

@DamianEdwards

Copy link
Copy Markdown
Member

Fixes the VMR rolling build failure reported after #6720 where NativeAOT publishing for the ASP.NET Core bundled tools selected the Linux default bfd linker for linux-musl-* RIDs, but the cross-build containers do not provide ld.bfd.

This scopes the workaround to the ASP.NET Core tool NativeAOT publishes by setting LinkerFlavor=lld only when RuntimeIdentifier starts with linux-musl-. Non-musl Linux publishes continue to use the existing NativeAOT default.

Tagging @lewing and @am11 from the #6720 discussion.

Note

This PR description was generated by GitHub Copilot.

Validation:

  • Restored the repo-local ASP.NET Core SDK with src\aspnetcore\restore.cmd.
  • Evaluated LinkerFlavor via MSBuild for dotnet-user-secrets, dotnet-user-jwts, and dotnet-dev-certs: linux-musl-arm64=lld; linux-x64=bfd.

Force the linker flavor to lld when publishing ASP.NET Core bundled tools as NativeAOT for linux-musl RIDs. This avoids selecting the NativeAOT Linux default of bfd in VMR cross-build containers that do not provide ld.bfd.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings May 23, 2026 19:08
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team May 23, 2026 19:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Scopes a workaround for NativeAOT publishing of the ASP.NET Core bundled tools so that linux-musl-* publishes use the lld linker in VMR cross-build containers (which don’t include ld.bfd), while leaving non-musl Linux publishes on the default behavior.

Changes:

  • Set LinkerFlavor=lld during AOT publish when RuntimeIdentifier starts with linux-musl- and no LinkerFlavor is already specified.
  • Added an inline comment explaining why the musl-specific linker override is needed in VMR.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lewing

lewing commented May 23, 2026

Copy link
Copy Markdown
Member

This fixes the 3 Alpine/musl legs but 5 of 8 failing legs use non-musl RIDs and will still fail:

Leg RID Fixed?
Linux_Alpine_arm64 linux-musl-arm64 ✅
Linux_Alpine_x64 linux-musl-x64 ✅
Linux_Alpine_arm linux-musl-arm ✅
Linux_arm64 linux-arm64 ❌
Linux_arm linux-arm ❌
Linux_Pgo_x64 linux-x64 ❌
Linux_Pgo_arm64 linux-arm64 ❌
Linux_x64 linux-x64 ❌

These are cross-compiled inside AzureLinux containers that also don't have ld.bfd, but the RID check $(RuntimeIdentifier.StartsWith('linux-musl-')) doesn't match them.

The runtime solved this with environment detection instead of RID matching — the LocateNativeCompiler target in eng/toolAot.targets runs init-compiler.sh to probe which linker is actually available, then sets LinkerFlavor accordingly. That handles both musl and glibc cross-containers.

Replace the linux-musl-* RID check with the LocateNativeCompiler target
pattern from runtime/eng/toolAot.targets. This probes the actual build
environment for lld availability, which correctly handles both musl
containers AND glibc cross-build containers that also lack ld.bfd.

Co-authored-by: Copilot <[email protected]>
@am11

am11 commented May 23, 2026

Copy link
Copy Markdown
Member

As a side note, we could dedup this target in arcade/eng/common/native and reuse it in sdk, runtime and maybe more repos under dotnet/ org in the future. It is basically compatible with dotnet engineering infrastructure.

As an end-user of PublishAot, I may just install cross binutils for cross publishing or just use the actual linux-arm64 machine etc. to build native stuff on the target platform (which is publicly documented).

@akoeplinger
akoeplinger merged commit efab687 into main May 24, 2026
11 checks passed
@akoeplinger
akoeplinger deleted the damianedwards/fix-aot-build branch May 24, 2026 17:33
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team May 24, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants