Skip to content

OpenHarmony: NativeAOT and pack integration - #136185

Merged
jkotas merged 11 commits into
dotnet:mainfrom
springmin:pr/ohos-batch-aot-packs
Oct 22, 2026
Merged

jkotas merged 11 commits into
dotnet:mainfrom
springmin:pr/ohos-batch-aot-packs

Conversation

@springmin

@springmin springmin commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Wire the openharmony-* RIDs through the NativeAOT, crossgen2, pack and
ILLink build paths: map openharmony to Linux in the shared target-OS parser,
keep the CoreLib and runtime packs ReadyToRun like the other Unix targets, use
the NDK's lld and ohos ABI, keep the musl libc flavor in the SingleEntry
layout, list the RIDs in the local pack graphs, and select the managed NTLM
implementation.

Changes

  • src/coreclr/tools/Common/CommandLineHelpers.cs: accept openharmony and
    map it to TargetOS.Linux, same as android.
  • src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets:
    select lld for openharmony, set CrossCompileAbi to ohos
    (aarch64-linux-ohos), and skip System.Net.Security.Native (no
    gssapi/krb5 in the sysroot).
  • .../Microsoft.DotNet.ILCompiler.SingleEntry.targets: keep the musl libc
    flavor for openharmony; the target OS name is accepted through the shared
    mapping.
  • eng/targetingpacks.targets: add openharmony-arm64 and openharmony-x64
    to the local runtime, NativeAOT and apphost RID lists; replace the
    SDK-provided apphost pack entry with the local one; scope the
    ResolvedRuntimePack local-pack override to the target RID on OpenHarmony.
  • src/native/eventpipe/ds-portable-rid.c: report openharmony as
    PORTABLE_RID_OS.
  • .../Microsoft.NET.ILLink.targets: use the managed NTLM implementation on
    OpenHarmony (no GSSAPI/krb5 in the sysroot), like linux-bionic.
  • Six files, 25 insertions and 6 deletions.

Impact

  • OpenHarmony only. The new conditions are inert for every other target; the
    existing linux, android/bionic, Apple and BSD paths are unchanged.
  • The CoreLib and runtime packs stay ReadyToRun like the other Unix targets;
    there is no IL-only special case.
  • The openharmony RIDs are listed on the CoreCLR and NativeAOT packs only, not
    on the Mono-labelled pack: the port is CoreCLR+NativeAOT.
  • No pack is shipped from this PR; it only teaches the local build graph about
    the RIDs.

Test

  1. Cross-build for openharmony-arm64: crossgen2 accepts
    --targetos openharmony (mapped to Linux) and the CoreLib/runtime pack are
    ReadyToRun.
  2. NativeAOT publish for openharmony-arm64: ilc invokes the NDK clang with
    --target=aarch64-linux-ohos and links with lld; the SingleEntry layout
    uses the musl libc flavor.
  3. Local-pack build for openharmony-arm64: runtime, apphost and ILCompiler
    artifacts are produced, and the ResolvedRuntimePack override is scoped to
    the target RID.
  4. ILLink on an openharmony-* RID selects the managed NTLM implementation.

Note

This PR was authored with AI assistance (agent tooling) under the author's direction.

@dotnet-policy-service dotnet-policy-service Bot added linkable-framework Issues associated with delivering a linker friendly framework community-contribution Indicates that the PR has been added by a community member labels Oct 20, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

springmin added a commit to springmin/runtime-ohos that referenced this pull request Oct 20, 2026
…6187)

A: NativeAOT and pack integration (7 files, 57+/7-)
B: libraries TFM groups and console support (7 files, 31+/6-)
C: System.Native avoid close_range (1 file, 171+/8-)
All three based on cf3fbf9; in flight: N3/N4/N8 + these three.
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

springmin added a commit to springmin/runtime-ohos that referenced this pull request Oct 21, 2026
springmin added a commit to springmin/runtime-ohos that referenced this pull request Oct 21, 2026
Rebased pr/ohos-native-robustness onto d267e98 (b3ddf1c,
11 files 123+/9-) and opened the PR. Runtime in flight: dotnet#136185,
dotnet#136186, dotnet#136194, dotnet#136198; SDK: dotnet#56732, dotnet#56733.
Comment thread src/coreclr/crossgen-corelib.proj Resolved
Comment thread src/native/eventpipe/ds-portable-rid.c Resolved
@springmin
springmin force-pushed the pr/ohos-batch-aot-packs branch from c2f3dcf to c70a766 Compare October 21, 2026 02:20
- target OS: map openharmony to Linux in the shared CommandLineHelpers parser,
  so crossgen2 and ilc accept the RID without local mappings.
- crossgen2/packs: keep the CoreLib and runtime packs ReadyToRun like the other
  Unix targets; drop the IL-only special case and its pdb dedup workaround.
- NativeAOT: use lld and the ohos clang ABI on OpenHarmony, and keep the musl
  libc flavor in the SingleEntry layout.
- packs: add openharmony-arm64/x64 to the local runtime, NativeAOT and apphost
  pack RID lists, and emit the openharmony portable RID.
- ILLink: use the managed NTLM implementation on OpenHarmony.
@springmin
springmin force-pushed the pr/ohos-batch-aot-packs branch from c70a766 to 7ce2047 Compare October 21, 2026 02:21
@springmin

Copy link
Copy Markdown
Contributor Author

All six points are addressed in 7ce2047: openharmony is mapped to Linux in the shared CommandLineHelpers parser, the CoreLib and runtime packs are ReadyToRun (no IL-only special case or pdb dedup target), and the comment / _targetOS nits are fixed. CI will validate the build.

Note

This comment was drafted with AI assistance (agent tooling) under the author's direction.

springmin added a commit to springmin/runtime-ohos that referenced this pull request Oct 21, 2026
Enabled R2R for the OpenHarmony CoreLib/runtime packs, added the shared
openharmony->Linux mapping, removed the local crossgen2 mappings and the
unneeded comments, and switched the linker condition to _targetOS. Head
7ce2047 (6 files 25+/6-); all six inline threads answered.
Comment thread eng/targetingpacks.targets Resolved
Comment thread eng/targetingpacks.targets Resolved
Comment thread eng/targetingpacks.targets Resolved
springmin added a commit to springmin/runtime-ohos that referenced this pull request Oct 21, 2026
Reverting the OpenHarmony TFM special casing leaves an empty diff; the
standard TargetOS TFM path works like FreeBSD. Replied to jkotas and
closed the PR. Runtime in flight: dotnet#136185, dotnet#136194, dotnet#136198.
springmin and others added 3 commits October 21, 2026 10:46
applied

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
…iler.SingleEntry.targets


applied

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Update the existing KnownAppHostPack entry with the local RIDs and version
instead of removing it, and scope ResolvedRuntimePack to the target RID for
every OS; only the Include fallback remains for SDKs without the entry.
@springmin

Copy link
Copy Markdown
Contributor Author

Updated in 127135f: the apphost pack uses Update (with the Include fallback when the SDK has no entry) and ResolvedRuntimePack is scoped to the target RID for every OS. The official RID lists (runtime OfficialBuildRID + the SDK list) remain the follow-up once the OpenHarmony cross-build image (dotnet-buildtools-prereqs-docker#1778) and the CI leg exist.

Note

This reply was drafted with AI assistance (agent tooling) under the author's direction.

Comment thread eng/targetingpacks.targets Resolved
Use _LocalAppHostRuntimeIdentifiers for the runtime, NativeAOT, ILCompiler,
Crossgen2 and apphost lists. The property holds the union of the local RIDs;
extra RIDs in a list are harmless.
Comment thread eng/targetingpacks.targets Resolved
The SDK's Mono KnownRuntimePack already lists wasi-wasm, so the update that
appended it is no longer needed. Keep the framework reference update, whose
SDK list still omits wasi-wasm.
Comment thread eng/targetingpacks.targets Resolved
Comment thread eng/targetingpacks.targets Resolved
Comment thread eng/targetingpacks.targets Resolved
The shared local list includes OpenHarmony RIDs, which are CoreCLR/NativeAOT
only; using it for the Mono runtime pack makes the Mono build fail. Keep the
Mono-specific list (with wasi-wasm added) and use the shared list in the
framework reference update.
Comment thread eng/targetingpacks.targets Resolved
Comment thread eng/targetingpacks.targets Resolved
…phost update

Move the KnownFrameworkReference update below its include and give the
KnownAppHostPack update the same identity/TFM filter as the framework
reference update.
@jkotas

jkotas commented Oct 21, 2026

Copy link
Copy Markdown
Member

There is still a build break on Mono: The runtime pack for Microsoft.NETCore.App.Runtime.Mono.browser-wasm was not downloaded. Try running a NuGet restore with the RuntimeIdentifier 'browser-wasm'.

Comment thread eng/targetingpacks.targets Resolved

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would this work?

Comment thread eng/targetingpacks.targets Resolved
Comment thread eng/targetingpacks.targets Resolved
Comment thread eng/targetingpacks.targets Resolved
Comment thread eng/targetingpacks.targets Resolved
Comment thread eng/targetingpacks.targets Resolved
@jkotas
jkotas merged commit 718e53e into dotnet:main Oct 22, 2026
158 of 160 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants