Skip to content

ohos: add aarch64-unknown-linux-ohos support (fsext/hostid/date) - #14288

Open
YodonTan wants to merge 1 commit into
uutils:mainfrom
YodonTan:ohos-pr
Open

ohos: add aarch64-unknown-linux-ohos support (fsext/hostid/date)#14288
YodonTan wants to merge 1 commit into
uutils:mainfrom
YodonTan:ohos-pr

Conversation

@YodonTan

@YodonTan YodonTan commented Aug 30, 2026

Copy link
Copy Markdown

Add aarch64-unknown-linux-ohos (HarmonyOS) support

Closes #14287

Minimal patch set to build uutils/coreutils natively on HarmonyOS (aarch64-unknown-linux-ohos), verified on a HarmonyOS PC (kernel HongMeng 1.13.0, aarch64). All changes are #[cfg(target_env = "ohos")]-gated; non-OHOS code paths are untouched (musl allow(deprecated) attributes and glibc/musl branch behavior preserved).

This revision:

  • drops the utmpx changes and defers to uutests: gate by target support #14252, which disables utmpx on OHOS (no utmp data source there). utmpx.rs is identical to upstream in this PR.
  • syncs fuzz/Cargo.lock (via cargo fetch in fuzz/) to fix the CI --locked failure (Dependencies / MinRustV jobs).

Changes

File Root cause (verified) Change
src/uucore/src/lib/features/fsext.rs statfs.f_type is u64 on OHOS (musl-like libc) → E0308 Include OHOS in the musl try_into().unwrap() branch
src/uu/hostid/src/hostid.rs gethostid not exported by OHOS SDK libc OHOS-local impl: read /etc/hostid, else FNV-1a hostname hash (glibc semantics)
src/uu/date/src/date.rs jiff try_system() reads /etc/localtime/zoneinfo (absent on OHOS) → always UTC OHOS-only ohos_system_zone(): pass through the system time zone ID from OH_TimeService_GetTimeZone, resolve via embedded IANA tzdata (jiff-tzdb) with TimeZone::tzif, preserving DST rules/history. Call sites cfg-gated; non-OHOS paths byte-identical to upstream.
src/uu/date/Cargo.toml jiff needs tzdata to resolve the ID [target.'cfg(target_env = "ohos")'.dependencies] jiff-tzdb = "0.1" (OHOS-only)
Cargo.lock / fuzz/Cargo.lock new dependency + jiff-tzdb; fuzz lock synced via cargo fetch

Build

Standard upstream flow (unix default feat_os_unix; utmpx commands excluded on OHOS per #14252):

make build                 # per-command binaries
make build MULTICALL=y     # multi-call coreutils

Verification (on-device)

  • date "+%F %T %z %Z" matches system time: +0800 CST
  • date -d 1987-06-01 "+%z %Z"+0900 CDT (tzdata DST-era rule active; China DST 1986-1991)
  • hostid/b2sum/arch/numfmt work; builds pass on the non-utmpx feature set
  • Negative: OHOS builds exclude who/users/uptime/pinky (utmpx disabled by uutests: gate by target support #14252 — graceful degradation, no utmp data source)

Known limits (runtime degradation, documented in #14287)

Fork: YodonTan/coreutils, branch ohos-pr. Happy to add an aarch64-unknown-linux-ohos CI workflow mirroring android.yml/freebsd.yml if maintainers are interested.

@xtqqczze

Copy link
Copy Markdown
Contributor

These changes functionally conflict with #14252, so care should be taken when merging.

@YodonTan

Copy link
Copy Markdown
Author

These changes functionally conflict with #14252, so care should be taken when merging.

so how can I deal with it.

@xtqqczze

Copy link
Copy Markdown
Contributor

#14252 completely disables the utmpx feature on ohos, so you'll need to re-enable it if that PR is merged first.

@YodonTan

Copy link
Copy Markdown
Author

#14252 completely disables the utmpx feature on ohos, so you'll need to re-enable it if that PR is merged first.

I think it's ok to just disable utmpx on ohos, so I think I can just roll back changes about utmpx?

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/dd/misc. tests/dd/misc is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/df/over-mount-device. tests/df/over-mount-device is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/cat/splice is no longer failing!
Congrats! The gnu test tests/cp/cp-a-selinux is no longer failing!
Congrats! The gnu test tests/cut/cut is no longer failing!
Congrats! The gnu test tests/cut/mb-non-utf8 is no longer failing!
Congrats! The gnu test tests/dd/partial-write is no longer failing!
Congrats! The gnu test tests/expand/mb is no longer failing!
Congrats! The gnu test tests/ls/stat-free-symlinks is no longer failing!
Congrats! The gnu test tests/misc/close-stdout is no longer failing!
Congrats! The gnu test tests/mktemp/write-error is no longer failing!
Congrats! The gnu test tests/mv/dir2dir is no longer failing!
Congrats! The gnu test tests/mv/mv-exchange is no longer failing!
Congrats! The gnu test tests/nl/multibyte is no longer failing!
Congrats! The gnu test tests/od/od-float is no longer failing!
Congrats! The gnu test tests/od/od-j is no longer failing!
Congrats! The gnu test tests/ptx/ptx-overrun is no longer failing!
Congrats! The gnu test tests/sort/sort-merge-fdlimit is no longer failing!
Congrats! The gnu test tests/unexpand/mb is no longer failing!
Note: The gnu test tests/dd/fail-ftruncate-fstat was skipped on 'main' but is now failing.

@xtqqczze

Copy link
Copy Markdown
Contributor

I just disabled utmpx to quickly fix the build errors on ohos, your decision on whether you want to try to support it.

@sylvestre

Copy link
Copy Markdown
Contributor
Run ## Confirm MinSRV compatible '*/Cargo.lock'
error: the lock file /home/runner/work/coreutils/coreutils/fuzz/Cargo.lock needs to be updated but --locked was passed to prevent this
If you want to try to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.
Error: Incompatible (or out-of-date) 'fuzz/Cargo.lock' file; update using `cd 'fuzz' && cargo +1.88.0 update`
Error: Process completed with exit code 1.

@YodonTan

Copy link
Copy Markdown
Author
Run ## Confirm MinSRV compatible '*/Cargo.lock'
error: the lock file /home/runner/work/coreutils/coreutils/fuzz/Cargo.lock needs to be updated but --locked was passed to prevent this
If you want to try to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.
Error: Incompatible (or out-of-date) 'fuzz/Cargo.lock' file; update using `cd 'fuzz' && cargo +1.88.0 update`
Error: Process completed with exit code 1.

may be I should not add Cargo.lock into the Project?

@xtqqczze

xtqqczze commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

The lock file already exists in the repository so you need to fix it. The most minimal way is cd fuzz && cargo fetch, and then rebase.

Fixes required to build uutils/coreutils on HarmonyOS (aarch64-unknown-linux-ohos):

- uucore/fsext: statfs.f_type is u64 on OHOS; route it through the musl branch.
- hostid: implement gethostid locally (read /etc/hostid, else hash hostname)
  because the OHOS SDK libc dropped the symbol.
- date: pass through the system time zone ID from OH_TimeService_GetTimeZone
  and resolve it with embedded IANA tzdata (jiff-tzdb) via TimeZone::tzif,
  instead of relying on /etc/localtime or a POSIX-injected TZ. The OHOS-only
  helper is cfg-gated; non-OHOS code paths are byte-identical to upstream.

utmpx is intentionally left untouched: upstream uutils#14252 disables it on OHOS
(no utmp data source there), and this PR defers to that approach.

Also syncs fuzz/Cargo.lock after adding the jiff-tzdb dependency.

Verified on-device: date matches system time (+0800 CST; 1987-06-01 -> +0900 CDT),
hostid behaves, builds pass on the non-utmpx feature set.
@YodonTan YodonTan changed the title ohos: add aarch64-unknown-linux-ohos support (utmpx/fsext/hostid/date) ohos: add aarch64-unknown-linux-ohos support (fsext/hostid/date) Aug 31, 2026
@YodonTan

Copy link
Copy Markdown
Author

The Aggregate GNU test results job failed with 3 regressions vs main:

  • tests/dd/misc
  • tests/df/over-mount-device
  • tests/dd/fail-ftruncate-fstat

I believe these are environment-related and not caused by this PR:

  1. This PR does not touch dd at all (files changed: fsext.rs, hostid.rs, date.rs/date/Cargo.toml, both lockfiles).
  2. The fsext.rs change only extends the statfs.f_type cfg branches with target_env = "ohos"; on glibc Linux (not(any(musl, ohos))not(musl)) the compiled behavior is identical, so df semantics are unchanged.
  3. The previous revision of this same patch set passed this exact aggregate job (PASS +0 / FAIL 0 regressions), which points to intermittent environment flakiness (e.g. mount layout on the runner).
  4. tests/dd/fail-ftruncate-fstat is even newly-failing because it was previously skipped on main — an environment-dependent test.

I can't re-run the job myself (needs repo admin rights). Could a maintainer re-run the failed Aggregate GNU test results job, or confirm whether these tests are known to be flaky on main lately? Happy to rebase again if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support aarch64-unknown-linux-ohos (HarmonyOS): utmpx/fsext/hostid fixes and timezone pass-through

3 participants