Skip to content

ci: gate the musl and OpenHarmony targets - #210

Merged
caomengxuan666 merged 1 commit into
masterfrom
ci/cross-target-check
Oct 9, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
ci/cross-target-check

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

背景

cross-check 跑在 ubuntu-latest 和 macos-latest 上,这俩都是 x86_64 + glibc。musl 完全没人测,aarch64 一个都没有。 所以整类 libc 差异、整类架构差异,CI 是瞎的。

这不是假设,是刚发生的事:rubash 的 ulimit 把资源选择器写成了 libc::__rlimit_resource_t——只有 glibc 有这个名字。musl 和 OpenHarmony libc 收的是裸 c_int,于是两个目标各自炸 2 处 cannot find type,而 cross-check 一路绿灯。原因也简单:宿主是 glibc,而那层 cfg 守卫写的是 target_os = "linux"——ohos 恰好满足(它的 target_env 是 "ohos" 而不是 "gnu"),于是走进函数体然后找不到类型。

改动

加一个 cross-target-check job,对显式 target 跑 cargo check --workspace:

matrix:
  target:
    - x86_64-unknown-linux-musl
    - aarch64-unknown-linux-ohos

选这两个的理由:

target 覆盖什么
x86_64-unknown-linux-musl musl libc、静态链接 / Alpine 那条线
aarch64-unknown-linux-ohos HarmonyOS PC

aarch64-unknown-linux-ohos 是 Tier 2 with host tools,所以 check-only 构建不需要 OpenHarmony SDK,也不需要 clang wrapper,setup-rust-toolchain 的 target: 入参就够了。

两个 target 都是 unix,所以 rubash 兄弟检出和 [patch] override 的行为跟其他 job 完全一致——照旧不做 cargo update -p rubash,理由跟 build-and-test / cross-check 里已有的那段注释一样。

验证

本地按这个 job 的逻辑实测过(rubash 用配套修复的 unixwin/rubash#449):

target 修前 修后
aarch64-unknown-linux-ohos fail(2 errors) 绿
x86_64-unknown-linux-musl fail(2 errors) 绿

修后两次都是 Finished dev profile ... target(s) in 32~55s,niubash v1.3.4 和 niubash-runtime v1.3.4 都过。

顺带说一句:这是 niubash 本体第一次被证明能在 aarch64-unknown-linux-ohos 上编译通过,之前只验到 rubash 那一层。

依赖

配套 PR:unixwin/rubash#449,那个补丁才是让 ohos 变绿的修复。这个 CI job 只有在 #449 落地之后才会绿——在那之前它会红,这正是它存在的意义。


改动纯增量:.github/workflows/ci.yml +37 行,不动任何现有 job。

@caomengxuan666

Copy link
Copy Markdown
Member Author

配套 PR:unixwin/rubash#449 — ulimit 的 libc::__rlimit_resource_t → 按 target_env 分家的类型别名,+11/−2,只碰一个文件。

本地实测(按这个 job 的逻辑跑的)

rubash 用 #449 的版本,niubash 用当前 master:

target #449 之前 #449 之后
aarch64-unknown-linux-ohos fail(2 errors) 绿,32.59s
x86_64-unknown-linux-musl fail(2 errors) 绿,55.12s

修前的报错就是 cannot find type __rlimit_resource_t in crate libc 两处,could not compile rubash (lib) due to 2 previous errors。

合并顺序

#449 先落地,这个 PR 才会绿。 在那之前 cross-target-check 是红的——这是刻意留的,红就是在说「rubash 那边还没修」。两个 PR 互为配套,谁也不能单独说明问题。

@caomengxuan666 caomengxuan666 added the P1-high 高:核心语义或高频路径受损,影响日常使用/发布 label Oct 9, 2026
`cross-check` runs on ubuntu-latest and macos-latest, which are both
x86_64/glibc. Nothing covers musl, and nothing covers aarch64 at all, so
whole classes of libc and arch divergence are invisible to CI.

That is not hypothetical. rubash's `ulimit` typed its resource selector as
`libc::__rlimit_resource_t`, a typedef only glibc defines. musl and the
OpenHarmony libc take a plain `c_int`, so both targets failed with two
`cannot find type` errors each -- while `cross-check` stayed green,
because the host is glibc and the cfg guard was `target_os = "linux"`,
which ohos satisfies (`target_env = "ohos"`, not `"gnu"`).

Add a `cross-target-check` job that `cargo check --workspace` for an
explicit target:

  x86_64-unknown-linux-musl   - the musl libc, and the static/Alpine story
  aarch64-unknown-linux-ohos  - HarmonyOS PC

`aarch64-unknown-linux-ohos` is Tier 2 with host tools, so a check-only
build needs no OpenHarmony SDK or clang wrapper; `setup-rust-toolchain`'s
`target:` input is enough. Both targets are unix, so the sibling rubash
checkout and the `[patch]` override behave exactly as in the other jobs --
in particular no `cargo update -p rubash`, same reasoning as the comment
already carried by `build-and-test` and `cross-check`.

Depends on unixwin/rubash#449 (merged as 2b9c437), which is the fix that
makes ohos clean.
@caomengxuan666
caomengxuan666 merged commit 15bd2a0 into master Oct 9, 2026
6 checks passed
@caomengxuan666
caomengxuan666 deleted the ci/cross-target-check branch October 10, 2026 01:35
caomengxuan666 added a commit that referenced this pull request Oct 12, 2026
…l return + build.rs host-agnostic icon gate (#281)

* fix(highlighting): color REPL-only commands (self-update, update-niubash, logout) as builtins (niu#260)

self-update / update-niubash are intercepted by the REPL before engine
command resolution, so they never resolve on PATH and the highlighter
painted them as unknown tokens (red) even though they run fine (issue
screenshot: red 'self-update' at the prompt). Same class of problem for
'logout', which is also a REPL-exact-match word.

Add repl::is_repl_reserved_command as the shared predicate over REPL-
reserved first words (exit, logout, self-update, update-niubash) and
consult it from the highlighter's command-position classification, so
these words get builtin styling instead of UnknownToken. Case-sensitive
by design, matching the REPL's exact-match intercepts; argument
positions are unaffected.

Tests: highlighter repaints the three words as Builtin, argument
position stays Default, predicate unit test covers exact-match
semantics.

* ci: gate the aarch64-linux-android and armv7-linux-androideabi cross-checks (niu#207 step 1)

rubash#456 landed the bionic cfg fixes, so both android targets now
check clean through rubash; this exposes them on the niubash side of
the workspace check, same shape as the musl/ohos legs (#210/#221).
Both targets verified green locally: cargo check --workspace --locked
--target aarch64-linux-android and --target armv7-linux-androideabi.

Two blockers surfaced and are fixed here:

- arboard 3.6.1 (via reedline's system_clipboard feature) has no
  android backend and fails to compile for android targets. Gate the
  feature to non-android targets in Cargo.toml: Windows/macOS/Linux
  builds keep the system clipboard (arboard stays in their graphs),
  android loses Ctrl+V system paste behind a stub
  add_system_clipboard_keybindings, bracketed paste unaffected.

- build.rs gated the icon .res embedding on #[cfg(windows)] - a HOST
  predicate. Cross-checking an android target from a Windows dev box
  made it run the SDK's arm64 rc.exe, an arm64 binary that cannot
  launch on x64 (os error 216). Gate on CARGO_CFG_TARGET_OS instead;
  the resource only links into PE binaries anyway. Ubuntu-hosted CI
  legs are unaffected either way.

Part of niubash#207 (platform roadmap) step 1/2: make the compile
surface visible and honest. Android remains compile-verified only -
no release artifacts until a native smoke gate exists per
docs/release.md red line.

* fix(main): rc-0 one-shot exits return from main so the history session-end write runs

Pre-existing master red (host_contract::history_and_fc_use_the_host_history_provider,
failing on CI since 130598a): a one-shot 'niu -c history -c' left the
history file holding the pre-clear list instead of truncating it.

Root cause: 130598a routed every one-shot exit through
finish_one_shot -> piped_stdout::finish_and_exit -> std::process::exit,
which skips Rust destructors. RubashHistoryProvider::drop is the only
thing that carries a GNU 'history -c' to the file at session end
(niubash#265), so rc-0 -c sessions stopped flushing. 484dad3 (the
original fast path) returned Ok(()) on rc 0 and only diverged on
nonzero codes - the Drop ran and the test passed.

finish_one_shot now calls piped_stdout::finish() and exits only on
nonzero codes; rc 0 returns to the caller. Arms that previously relied
on the always-diverging call tail now 'return Ok(())' explicitly so
they cannot fall through into the script/REPL arms.

Verified: the manual -c sequence (history; fc 2 / -s / -d 2 / -c) ends
with an empty history file; 'exit 5' still propagates rc 5; host_contract
and cwd_state suites green; cwd-state recording (the #272 feature)
still runs before both exit forms.

* fix(build): compile embed_windows_icon on every host - the call site is runtime-gated on the target OS

3ea224e (#207 step 1) moved the call site from host #[cfg(windows)] to a
CARGO_CFG_TARGET_OS runtime check so a Windows host cross-checking an
android target no longer runs the SDK's arm64 rc.exe (os error 216), but
left the definition behind #[cfg(windows)]. On a linux/macOS host the
call site now compiles while the definition is cfg'd out: E0425 on every
non-Windows host (ubuntu/macos/android/ohos/armv7 cross-checks).

Drop the cfg from the definition - it is std-only and dead unless the
target is Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1-high 高:核心语义或高频路径受损,影响日常使用/发布

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant