`get_host_triple()` hard-fails on HarmonyOS because `config.guess` cannot identify the system
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
## Summary
On HarmonyOS, `uname -s` reports `HarmonyOS` (not `Linux`), and the `config.guess` script cannot determine the system, so CMake configuration fails. The workaround is to hard-code the host triple.
This is fundamentally a `config.guess` gap, not an LLVM bug — the LLVM angle is just that `GetHostTriple.cmake` has no OHOS special-case to avoid `config.guess`.
## Detailed description
Configuring LLVM (`cmake -S llvm` and later `cmake -S runtimes`) on HarmonyOS 7 invokes `llvm/cmake/modules/GetHostTriple.cmake`, which then invokes `config.guess` to determine the system. However, `config.guess`'s attempt to create a dummy file for probing will be rejected by HarmonyOS's sandbox mechanisms. Even if we set `TMPDIR` to a safe place to avoid this issue, it still fails to recognize the `uname`'s outputs:
```
localhost ~ % TMPDIR=$(brew --cache)/tmp sh config.guess
config.guess: unable to guess system type
This script (version 2026-05-17), has failed to recognize the
operating system you are using. If your script is old, overwrite *all*
copies of config.guess and config.sub with the latest versions from:
https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
and
https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
If config.guess has already been updated, send the following data and any
information you think might be pertinent to config-patches@gnu.org to
provide the necessary information to handle your system.
config.guess timestamp = 2026-05-17
uname -m = aarch64
uname -r = HongMeng Kernel 1.13.0
uname -s = HarmonyOS
uname -v = #1 SMP Sat Aug 15 11:19:26 UTC 2026
/usr/bin/uname -p = unknown
/bin/uname -X =
hostinfo =
/bin/universe =
/usr/bin/arch -k =
/bin/arch =
/usr/bin/oslevel =
/usr/convex/getsysinfo =
UNAME_MACHINE = "aarch64"
UNAME_RELEASE = "HongMeng Kernel 1.13.0"
UNAME_SYSTEM = "HarmonyOS"
UNAME_VERSION = "#1 SMP Sat Aug 15 11:19:26 UTC 2026"
```
This is primarily a gap belonging to `config.guess`, not actually LLVM's problem. As a workaround, we simply overwrite the `get_host_triple` function to hardcode the value (`aarch64-unknown-linux-ohos`, which is obtained from `clang -dumpmachine`). But `GetHostTriple.cmake` could still special-case `OHOS` and `HarmonyOS` the same way it already special-cases Windows, MinGW, z/OS and AIX, i.e., returning `aarch64-*-linux-ohos` based on CMake variables instead of falling through to `config.guess`.
---
We used branch `release/22.x` commit `ca7933e47d3a3451d81e72ac174dcb5aa28b59d1`.
Environment: HarmonyOS 7.0.0.102, `uname -a`: `HarmonyOS localhost HongMeng Kernel 1.13.0 #1 SMP Sat Aug 15 11:19:26 UTC 2026 aarch64 GNU/Linux`
Contributor guide
Research direction
Start with llvm/cmake/modules/GetHostTriple.cmake and compare its existing platform-specific handling with the HarmonyOS and OHOS details in the report. Test configuration for both llvm and runtimes on HarmonyOS, using the reported aarch64 environment, and verify that host-triple detection no longer falls through to the failing config.guess path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100