Conversation
|
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. |
|
Tagging subscribers to this area: @dotnet/area-system-io |
|
@dotnet-policy-service agree |
CI failure classification (run 2)The latest push fixes the only PR-caused failures: the four Three legs still fail, all unrelated to this PR:
Note This comment was drafted with AI assistance (Copilot/agent tooling) under the repository owner's direction. |
|
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. |
|
Tracking issue for the overall OpenHarmony (HarmonyOS) porting effort: #132866 Note This comment was drafted with AI assistance (Copilot/agent tooling) under the repository owner's direction. |
|
This PR is ready for review. It is the first PR of a series adding OpenHarmony (HarmonyOS) support to the runtime (tracking issue: #132866). The changes are guarded by The PR spans three areas, so I'm pinging the respective owners:
CI status: the only PR-caused failures (four Happy to split the GC change into a separate PR if preferred. Note This comment was drafted with AI assistance (Copilot/agent tooling) under the repository owner's direction. |
|
Is HarmonyOS only used in tablet/mobile/IOT scenarios or is it used in desktop scenarios as well? Would it be reasonable to use the in-process-only NamedMutex implementation like we do for Android, iOS, and MacCatalyst? |
|
Good questions. HarmonyOS NEXT is used across phones, tablets, and IoT devices, but it also targets desktop-class devices (HarmonyOS NEXT for PC), so cross-process synchronization is a real scenario for applications ported from Linux/Windows. Now,I am porting the dotnet runtime to harmonyos by AI in HarmonyOS PC.
If the maintainers prefer the in-process-only Note This comment was drafted with AI assistance (Copilot/agent tooling) under the repository owner's direction. |
Reflects jkotas' TargetsLinuxOhos -> TargetsOhos rename (already applied in 602a5b1/955126211cc) and records the reviewer feedback from dotnet#132827 (jkotas rename + jkoritzinsky TMPDIR scoping).
602a5b1 renamed the property in 7 files but missed the three most critical ones: RuntimeIdentifier.props (property definition + TargetsLinuxGlibc exclusion), Subsets.props (DefaultSubsets + _BuildAnyCrossArch), and liveBuilds.targets (CoreCLRArtifactsPath). Without these, TargetsOhos would be defined but never consumed. Renames complete the jkotas feedback from dotnet#132827.
Rebases the remaining OHOS porting work (30 files) into 3 PRs after the sandbox-fix PR dotnet#132827 (tracking issue dotnet#132866). Includes exact file inventories per PR, the TargetsOhos naming convention (jkotas feedback), no-op guarantees, validation checklist, and A→C→B submission rationale.
|
There are no named event wait handles on non-Windows, your AI assessment is incorrect there. Also, it looks like HarmonyOS is shifting to its own kernel instead of Linux. Can we change the RID to be ohos instead of linux-ohos since it's not guaranteed to be Linux based? |
|
Thanks for the feedback — you're right on both points. I've verified in the code that there are no named event wait handles or named semaphores on non-Windows (both throw PlatformNotSupportedException on Unix), so shared memory files are used exclusively by the cross-process NamedMutex path — my earlier statement was incorrect. On the RID: HarmonyOS PC currently ships with two kernel variants — linux-ohos (Linux kernel) and harmony-ohos (the HarmonyOS native kernel) — across both arm and x86. Since the kernel is not guaranteed to be Linux-based, I agree ohos is the right RID going forward. The property and define names in this PR (TargetsOhos / TARGET_OHOS) are already kernel-agnostic, and the follow-up build-infrastructure PR will use the ohos RID. On NamedMutex: The primary target for this port right now is HarmonyOS PC — running the .NET runtime on desktop-class devices to develop .NET applications for Harmony devices. The current design references Apple's macOS implementation: cross-process named mutexes backed by shared memory files, with the shared directory resolved via TMPDIR because the HarmonyOS sandbox mounts /tmp read-only. Inspired by this discussion, I've refined the design to also cover non-PC devices that don't need cross-process mutexes: the cross-process path becomes selectable per device class through the existing build configuration (FeatureCrossProcessMutex, the same mechanism that gates iOS/Android). PC builds keep the macOS-style shared-memory-file implementation; builds for non-PC devices simply leave the feature disabled, which automatically excludes the shared-memory files code from compilation and falls back to the in-process named-mutex implementation — exactly like iOS and Android. Concretely, this is a one-line condition on FeatureCrossProcessMutex in System.Private.CoreLib.Shared.projitems plus a TargetsOhosMobile property set by the build for non-PC targets (e.g. the ohos-mobile-arm64 RID). No other mobile behaviors (such as AssemblyDependencyResolver or PosixSignalRegistration) are affected, and the current PR itself stays unchanged — it provides the PC path. Does this design sound reasonable? If you'd prefer not to have this variability, I can fall back to disabling the cross-process path for OHOS entirely (the simpler, iOS-aligned approach). |
|
You can ask your AI model to analyze the merge commits of OpenBSD PRs, which we have recently ported: https://github.com/dotnet/runtime/pulls?q=is:pr+label:os-openbsd. Then ask it to start porting the code. Once you have full set of changes in a branch; cross building, infra, coreclr, tools, r2r, aot, libraries, corehost, installer, you can create smaller branches with substantial work then upstream them sequentially like infra+coreclr changes in one PR, each library changes in a separate PR, dotnet/arcade upstreamed there and so on. This way reviewer can make sense of what's going on, we can test what's being upstreamed etc. which is better than starting off of a random point and using undefined stuff like |
|
Thanks for the guidance — the OpenBSD port's pattern (e.g. #130761 CI leg, #129906 NativeAOT stubs, #130478 exepath — small, focused PRs) is exactly the model we intend to follow, and it's how this effort is already structured. The full OHOS integration is staged on a dedicated branch (43 files in the runtime repo + 19 in the SDK repo) and split into sequential upstream PRs, tracked in #132866:
On the RID: both OpenHarmony and HarmonyOS currently ship Linux-based ( On "undefined Note This comment was drafted with AI assistance (Copilot/agent tooling) under the repository owner's direction. |
|
The point was this is not the good
You could use stacked PR approach for this port, it would help the future platforms port: https://docs.github.com/pull-requests/how-tos/stacked-pull-requests When we started OpenBSD port few months ago, stacked PR concept didn't exist. I'd have definitely opted for it. |
|
Thanks — I've applied all three renames in the latest push (cc9ccb3): On the ordering: agreed. The build infrastructure PR is now up as #132953 ( Since this is a fork-based contribution, the PRs are submitted sequentially (each against Note This comment was drafted with AI assistance (Copilot/agent tooling) under the repository owner's direction. |
|
CI note: the only failing check is Review checklist status (all addressed):
Note This comment was drafted with AI assistance (agent tooling) under the reporter's direction; the merge and CI runs were performed by the reporter. |
…exclusion, fix test shm path
…exclusion, fix test shm path
|
Two updates for this PR: RID naming — settled as Follow-up commit
No runtime behavior changes beyond the test path; the reviewed guards are unchanged. Ready for re-review. |
…refresh - Added N14 (tryrun.cmake, was in no PR and not in dotnet#132953), N15 (libraries TFM mapping: Directory.Build.props/targets + sfx x3 + shims), N16 (System.Console PNSE/CA1416); N8/N9 content refreshed to the current branch state; N13 to be submitted without the OpenHarmonyInTreeR2R experiment gate. - Marked the in-tree-R2R A/B gate, the dotnet selfsign CLI and the CI overlay/PGO scripts as fork-local-only (never in PRs). - Status: dotnet#132953 jkotas-approved awaiting maintainer merge; dotnet#132827 follow-up pushed + comment posted; 36ef/dotnet#133296 resolved on the fork; total runtime PRs N1-N16.
|
Small fork-side housekeeping note — no action needed, and nothing here changes this PR:
This PR's head is unchanged ( |
|
Friendly ping on this one — is there anything else needed before it can merge? Current state on head
Context: the follow-up runtime-port PRs are prepared. It would help to know whether |
|
looks good to me. there is a merge conflict in src/libraries/System.Private.CoreLib/src/System/Threading/NamedMutex.Unix.cs that needs to be handled before this can be merged |
|
Conflict resolved — the branch is now merged with current // On Linux arm and arm64, we do not use PThread mutex-backed named mutexes for compatibility with previous .NET versions.
// On OpenHarmony, the musl sysroot does not provide the robust mutex APIs
// (pthread_mutexattr_setrobust / pthread_mutex_consistent).
private static bool UsePThreadMutexes =>
#if (TARGET_ARM || TARGET_ARM64)
!OperatingSystem.IsLinux() &&
#endif
!OperatingSystem.IsApplePlatform() && !OperatingSystem.IsFreeBSD() && !OperatingSystem.IsOpenBSD() && !OperatingSystem.IsHaiku() && !OperatingSystem.IsOpenHarmony();CI is re-running on the new head Note for context: an on-device build check on OpenHarmony is currently blocked by an unrelated toolchain gap (the local SDK bundle is on the 11.x line while @akoeplinger @jkotas PTAL. |
2511c98 to
091f575
Compare
…enHarmony Split per review: the NUMA and platform-identity changes moved to a separate PR. This PR now only contains the shared-memory / named-mutex changes: - SharedMemoryManager: use the TMPDIR-based shared files path (read-only /tmp) - NamedMutex: do not use pthread robust mutexes on OpenHarmony - MutexTests: derive the shared memory directory the same way the runtime does
091f575 to
4c3b303
Compare
|
Tagging subscribers to this area: @JulieLeeMSFT, @VSadov |
Summary
HarmonyOS (OpenHarmony) app sandboxes differ from a plain Linux environment in
three ways that break .NET at startup or at runtime. This PR adds the
TARGET_OPENHARMONYplatform guard and the three runtime fixes required to run onHarmonyOS. All changes are no-ops on existing platforms (see "Impact" below).
This is the second PR of the series adding
ohos(HarmonyOS) support tothe runtime (tracking issue: #132866). It depends on the build infrastructure
PR #132953, which defines
TargetOpenHarmony/TARGET_OPENHARMONY; until thatlands, this PR is a compile-time no-op on every platform. The split keeps the
sandbox fixes reviewable independently of the build infrastructure.
Changes
1. Skip the GC NUMA probe on HarmonyOS (
numasupport.cpp)get_mempolicy/mbindare blocked by the HarmonyOS seccomp policy, so the NUMAprobe SIGSYS-crashes the process at startup. The syscalls are compiled out for
TARGET_OPENHARMONY; the GC falls back to single-node, which is correct for phones.2. Honor TMPDIR for shared-memory files on HarmonyOS (
SharedMemoryManager.Unix.cs)/tmpis mounted read-only in the HarmonyOS app sandbox, so shared-memory files(named mutexes, memory-mapped files) must not be placed under a hardcoded
/tmp/. OnTARGET_OPENHARMONYthe shared-memory files directory is now derived fromPath.GetTempPath(), which honorsTMPDIRand matches how the rest of theruntime resolves the temp directory. All other platforms keep the existing
hardcoded
/tmp/behavior unchanged.3. Fall back from pthread mutexes for
NamedMutex(NamedMutex.Unix.cs)The HarmonyOS sysroot's pthread lacks robust-mutex support.
NamedMutexfallsback to the shared-memory-file implementation (already the path for
OpenBSD/Haiku).
Supporting:
OperatingSystem.IsOpenHarmony()+TARGET_OPENHARMONYOperatingSystem.IsOpenHarmony()—internal, compile-timeTARGET_OPENHARMONY, mirrorsIsHaiku(). No public API change in this PR.System.Private.CoreLib.Shared.projitems—TARGET_OPENHARMONYdefine constant fromTargetOpenHarmony(mirroringTargetsAndroid/TARGET_ANDROID).Tests (
MutexTests.cs)The
NamedMutex_*shared-memory tests derive the global shared-memory directorythe same way the runtime does (
{SharedFilesPath}/.dotnet/shm/global), mirroringthe platform-conditional selection in change 2, so they stay in sync with the
runtime on every platform.
Impact on existing platforms
None:
TARGET_OPENHARMONYis only defined whenTargetsLinuxOhos == 'true', which noexisting build sets.
IsOpenHarmony()returnsfalseon every existing platform.numasupport.cppguards are additive (&& !defined(TARGET_OPENHARMONY)); withTARGET_OPENHARMONYundefined the behavior is byte-identical.(
/tmp/); theTMPDIR-honoring path is compiled in only forTARGET_OPENHARMONY.Validation
clr.native+libs+host+packs -os ohos -arch arm64 --crosscross-buildsucceeds:
0 Warning(s) 0 Error(s).libcoreclr.soforohos-arm64contains zero references toget_mempolicy/mbind(verified viaobjdump).IntermediatesDirpath fix verified in the full build.MutexTests.NamedMutex_*on the Unix legs because theshared-memory path change was not yet scoped to
TARGET_OPENHARMONY; that is fixed bythe latest push (the runtime path on non-HarmonyOS platforms is
/tmp/again,which the tests target). On the re-run, all previously failing Unix legs pass.
The remaining failures are unrelated to this PR:
CompositeMLDsa*on theWindows legs (the Helix Windows queues' CNG provider reports "The requested
operation is not supported" for Composite ML-DSA; the same tests pass on the
osx-arm64-NativeAOT leg in this run) and a browser-wasm
WasmTestOnChrometime-out on the LibraryTests_EAT leg (an infrastructure flake — a different
test work item failed on each run).
Notes for reviewers
-os ohos, RID graph, NDK toolchainplumbing) is intentionally not in this PR — it will follow so each PR is
independently reviewable. Without it,
TARGET_OPENHARMONYis simply never defined.ohoscross legs mirroringlinux-bionic.Note
This PR was authored with AI assistance (Copilot/agent tooling) under the
repository owner's direction.