Repository navigation
Conversation
OpenHarmony uses the Linux ABI (musl), but TARGET_LINUX is not defined and OSPlatformName is "OPENHARMONY". RuntimeInformation.IsOSPlatform(OSPlatform.Linux) therefore returns false. MSBuild's NativeMethodsShared uses that check to choose Unix-like Exec behavior; with false it writes Windows-style .exec.cmd scripts on device, and the NativeAOT linker probe fails with "linker not found" even though clang++ is on PATH. Keep "OPENHARMONY" as the canonical platform name and accept "LINUX" as an alias under TARGET_OPENHARMONY, following the macOS alias precedent.
|
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-infrastructure-libraries |
| // OpenHarmony uses the Linux ABI (musl). Accept LINUX as an alias so | ||
| // callers that probe for Linux - e.g. MSBuild's | ||
| // IsOSPlatform(OSPlatform.Linux), which selects sh vs Windows-style | ||
| // Exec scripts - behave as on Linux, while OPENHARMONY stays the | ||
| // canonical name. | ||
| || platform.Equals("LINUX", StringComparison.OrdinalIgnoreCase) |
There was a problem hiding this comment.
I don't think this is a correct change. Android expliclty returns false for IsLinux.
Build scripts testing ONLY IsOSPlatform(OSPlatform.Linux) are obviously incorrect.
If we add some "is Linux-like" like IsApplePlatform, it can return true then.
There was a problem hiding this comment.
Agreed — IsOSPlatform(Linux) should not be true for OpenHarmony (Android follows the same rule). The problem is MSBuild's Unix-like detection, not the OS identity. I'll close this and move the fix to MSBuild's NativeMethodsShared (treat OPENHARMONY as Unix-like) rather than changing CoreLib.
Note
This reply was drafted with AI assistance (agent tooling) under the author's direction.
Summary
On OpenHarmony,
TARGET_LINUXis not defined andOSPlatformNameisOPENHARMONY, soRuntimeInformation.IsOSPlatform(OSPlatform.Linux)returnsfalse. MSBuild's
NativeMethodsShareduses that check to choose Unix-likeExecbehavior; with false, it writes Windows-style.exec.cmdscripts ondevice, and the NativeAOT linker probe fails with "linker not found" even
though
clang++is onPATH.Changes
Keep
OPENHARMONYas the canonical platform name and acceptLINUXas analias under
TARGET_OPENHARMONY, following the macOS alias precedent.One file, 8 insertions. The new branch is compiled only for
TARGET_OPENHARMONYand is inert on other platforms.Test
net11.0-openharmony26.0,PublishAot=true)builds and runs;
RuntimeInformation.IsOSPlatform(OSPlatform.Linux)reportstrue.
dotnet publish -c Release -r openharmony-arm64 -p:PublishAot=truereaches "Generatingnative code" and completes with
rc=0. Before the change, the same hostwrote
.exec.cmdand failed withPlatform linker ('clang' or 'gcc') not found.own OSPlatform value follows that pack. The host runtime used for the
publish contains this change.
OperatingSystemTestsasserts the LINUX alias on OpenHarmony;it returns early on other platforms. PR CI validates the CoreLib build.
Note
This PR was authored with AI assistance (agent tooling) under the author's direction.