Repository navigation
fix(android): compile against bionic for aarch64/armv7 android targets - #456
Merged
Merged
Conversation
4 tasks
caomengxuan666
added a commit
that referenced
this pull request
Oct 10, 2026
…#478) - Delete docs/{TASK-BOARD,TASKBOARD,QUEUE-PROMPTS,PERF-BASELINE,CORPUS-COVERAGE,COMPATIBILITY-STATUS,LINUX-RUN-STATUS}.md: dated status snapshots / session handoffs whose content lives in git history and the issue tracker. Still-valid baseline numbers (perf table, corpus coverage, 2026-10-02 compat ledger) are excerpted into issue #477. - AGENTS.md/README/README.zh-CN: repoint dangling references to the issue tracker. - CHANGELOG: record SIGPIPE semantics (#455), interactive input C0 normalization (#458), and android bionic targets (#456) under Unreleased. Co-authored-by: docs-audit <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
roadmap unixwin/niubash#207(多平台 release)的 Android 线。模板是 #449(musl/OH 的 libc 差异修复)+ unixwin/niubash#210(对应的 CI 门禁)。
check 通过的 target
aarch64-linux-androidcargo check绿(Finished dev profile in 3.8s)armv7-linux-androideabicargo check绿(Finished dev profile in 11.6s)均为 check-only、不链接(本机/runner 无 NDK);两个 target 都是 Tier 2,rustup 的 rust-std 就够。
修改的 cfg 面(+44 / −9,5 个文件)
修前两类报错:bionic 缺符号(
AT_EACCESS、confstr/_CS_PATH),以及 32 位 bionic 的类型宽度差异(st_mode/S_IFMTu16 vs u32、off_ti32)。src/builtins/test.rs:AT_EACCESS在 libc crate 的 android 模块没有 re-export,android 下改用本地常量0x200(bionic<fcntl.h>同值)。src/executor/path.rs:bionic 没有confstr(),confstr_cs_path()收窄为all(unix, not(target_os = "android")),android 直接走STANDARD_UTILS_PATH回退(/bin:/usr/bin:/sbin:/usr/sbin)。src/builtins/kill.rs:sigaction的sa_restorer字段从#[cfg(target_os = "linux")]放宽为any(linux, android)(bionic 同为Option,None即内核默认 restorer)。src/fd/unix.rs:st_mode & S_IFMT比较改为u32::from(...)双侧提升(armv7 上S_IFMT/S_IFREG是 u16);seek_absolute的pos as i64改为off_t::try_from(pos).unwrap_or(off_t::MAX)(armv7off_t是 i32,饱和截断而不是静默截断)。全部按 #449 的模式做最小 cfg 门,不动架构;glibc/darwin 路径行为不变。
验证
cargo build绿,cargo test --lib624 passed / 0 failed(parser 20、lexer 86、assignment 相关 20 全绿)。cargo fmt已过(pre-commit 钩子强制)。CI job
cross-target-checkjob 内新增两个 step(仿 #210 的门禁模式,纯增量,不动现有 step):ubuntu runner +dtolnay/rust-toolchain的targets:加aarch64-linux-android, armv7-linux-androideabi,各跑一次cargo check,不链接。遗留
aarch64-linux-android的完整cargo build需要 Android NDK 的 clang linker(后续可在 CI 用nttld/setup-ndk或 nbattery 装 NDK 配 ar cargo)。test -x的AT_EACCESS=0x200语义与seek_absolute的饱和截断需要在真机/模拟器上冒烟。cargo check --tests未对 android target 跑(test 代码里的 unix API 可能还需要单独一轮 cfg 清理)。