Hello,

config.sub already accepts 'ohos' and 'linux-ohos*' (thank you!), and the
ohos targets are well established in LLVM ('aarch64-linux-ohos') and Rust
('aarch64-unknown-linux-ohos').  However, config.guess cannot detect
HarmonyOS devices, where uname -s reports "HarmonyOS", so native builds
on these systems fall through to "unknown".

This patch adds the missing detection:

  * uname -s = HarmonyOS (HongMeng Kernel, musl-based OHOS variant)
  * maps uname -m to aarch64/arm/x86_64/riscv64
  * outputs $CPU-unknown-linux-ohos, matching the LLVM/Rust triplets and
    the already-accepted config.sub 'linux-ohos*' kernel combination

It also adds HarmonyOS to the libc-detection group (HarmonyOS uses musl),
so the existing musl heuristics apply.

Verified on HarmonyOS PC (aarch64, HongMeng Kernel 1.13.0):

    $ sh config.guess
    aarch64-unknown-linux-ohos

Related history: a config.sub-only OpenHarmony patch was posted here in
Feb 2024 ("[PATCH] config.sub: Recognize OpenHarmony OS" by Jonathan
Schwender); the sub side has since landed.  An earlier submission of a
HarmonyOS variant was mistakenly sent to bug-gnulib in March 2026 --
apologies for the noise; this is the corrected resubmission to the right
list.

Background: this detection unblocks native builds of autotools-based
software on OpenHarmony/HarmonyOS PC devices, where currently every
port has to carry a local config.guess/config.sub patch (our community
porting archive alone carries 2268 such patches across 1031 packages).

--- a/config.guess
+++ b/config.guess
@@ -150,7 +150,7 @@
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown

 case $UNAME_SYSTEM in
-Ironclad|Linux|GNU|GNU/*)
+Ironclad|Linux|GNU|GNU/*|HarmonyOS)
        LIBC=unknown

        set_cc_for_build
@@ -1432,6 +1432,15 @@
     *:Haiku:*:*)       # Haiku modern gcc (not bound by BeOS compat)
        GUESS=$UNAME_MACHINE-unknown-haiku
        ;;
+    *:HarmonyOS:*:*)   # HarmonyOS (HongMeng Kernel), musl-based OHOS variant
+       case $UNAME_MACHINE in
+           aarch64|arm64) UNAME_MACHINE=aarch64 ;;
+           armv7*|arm*)   UNAME_MACHINE=arm ;;
+           x86_64|amd64)  UNAME_MACHINE=x86_64 ;;
+           riscv64)       UNAME_MACHINE=riscv64 ;;
+       esac
+       GUESS=$UNAME_MACHINE-unknown-linux-ohos
+       ;;
     SX-4:SUPER-UX:*:*)
        GUESS=sx4-nec-superux$UNAME_RELEASE
        ;;

Best regards,
goblinrs
OpenHarmony PC Developer community


Reply via email to