Repository navigation
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. |
|
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 |
Re-measured the merge dry-run at the current feature tip: 67 conflicted files (replaces the earlier 52), with 32 under src/libraries and 19 under eng/pipelines; the four version/Darc files match the aspnetcore conflict set. Key finding for sequencing: the 67-file conflict surface has an EMPTY file-level intersection with all 20 pr/ohos-* branches (they are anchored on upstream/main and their deltas live in eng/build.sh, eng/native, coreclr/pal, native/corehost, libraries TFM - none of which rc2 touches). The 09-28 rehearsal (merge-tree 39/39 CLEAN, rebase 20/21 CLEAN) therefore stays valid across the migration, and dotnet#132827/dotnet#132953/N1-N16 need no rework. Also records the parallel execution mode (shadow branch + ref-dispatched CI with upload_release=false), the CI cost (a runtime_ref change always cold-starts the runtime stage), and the kit dotnet#31 ordering note.
OpenBSD median 1.7d (mean 3.7, max 21.1) - the 6.5-month span came from batch pacing, not slow reviews; Haiku 21.8d median / 379d max and SunOS 10.1d / 544d show the long feature-PR tail. OHOS: dotnet#134670 landed in 1.1d, while dotnet#132827 (34.5d) and dotnet#132953 (31.5d) are still open and are the current pacing bottleneck.
All three precedents merged their first PR the same/next day (OpenBSD 0.73d, Haiku 1.33d, SunOS 0.81d) - the small-seed fast-acceptance signal. OHOS's first PR (dotnet#132827, opened 2026-08-27T09:33Z) is still open at ~34.1 days, a stark contrast; dotnet#132953 likewise ~31.2 days.
dotnet#132953 unchanged at be8e6f6 with every review item addressed and the arcade prerequisite merged on 09-24 - idle 10 days, with a status update prepared; dotnet#132827 approved and idle 5 days (no nag); dotnet#134670 merged; dotnet#132866 quiet for 17 days. Also fix dotnet#132827's file count (3 files, +19/-2).
…tion Reading the full dotnet#132953/dotnet#132827 threads surfaces three waiting items: B1 jkoritzinsky's in-progress shared-memory design (the actual reason for the blocked label and possibly his review silence), B2 akoeplinger's merge lane, B3 the external dotnet#132866 answer. Our highest-value action is A1: split dotnet#132827 so the non-shared-mutex parts (NamedMutex + tests) can merge now per jkotas's explicit suggestion; A2 is to ask a second reviewer for dotnet#132953 rather than ping the busy reviewer again. The 09-24 conflict is already fixed (head 4c3b303 merges cleanly into upstream/main).
The split (only NamedMutex.Unix.cs, +3/-1, based on fresh main b08c345) landed as dotnet#135321; during the split the MutexTests hunk turned out to be shared-memory directory work and stays in dotnet#132827, which now holds only the parked shared-memory/TMPDIR portion. The notify-comment draft for dotnet#132827 is ready and awaits permission.
|
As suggested in the review, I split out the named-mutex part into #135321, which is independent of the shared-memory changes. What remains here is the shared-memory |
The named-mutex split from dotnet#132827 was re-approved by jkotas and merged about 18.6 hours after creation (net diff 2 lines); his note records the Build Analysis failure as the known issue dotnet#135348. The upstream state, the findings register and the fast-lane datapoint are all updated.
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.