Repository navigation
audit(platform-cfg): full platform-gate inventory; fix android signal-table legs (kill/trap) - #492
Merged
Merged
Conversation
…or android too The kill(1) number table gated its Linux legs on target_os = linux and trap's SIGNALS table sent every non-Linux unix target to the BSD-family positional table, so an aarch64-linux-android build (a CI cross-target) resolved neither: kill -l 17 printed nothing on bionic and trap -l listed the BSD names (7=EMT, 20=CHLD) that bionic does not use. Bionic resolves the Linux kernel numbering for signals 1..31 (libc's android module pins SIGBUS=7, SIGUSR1=10, SIGSTKFLT=16, SIGPWR=30, SIGSYS=31, ...), so: - kill.rs: extend the twelve 1..31 Linux-leg cfg attrs to any(target_os = linux, target_os = android). The 34..64 RT literal block stays Linux-only: glibc's SIGRTMIN contract is 34, while bionic's __libc_current_sigrtmin() is 32, so the literal numbering would be wrong there. - trap.rs: give android its own 64-slot table (1..31 Linux names, RT slots empty) instead of the BSD table; the BSD gate narrows to not(any(linux, android)). Empty RT slots keep in-range numeric specifiers silently accepted (the Linux 32/33-hole shape) instead of advertising a wrong RTMIN base, and the existing cross-checks (positional_slots_match_libc, trap_table_agrees_with_kill_table) pin the table on any future android test runner. No Windows/macOS/linux-gnu behavior change: every touched arm compiles out on those targets (cargo test --lib: same 636 passed / 2 pre-existing environmental failures before and after). aarch64-apple-darwin and linux-gnu are untouched by construction; android arms verified with cargo check on aarch64-linux-android and armv7-linux-androideabi.
caomengxuan666
added a commit
that referenced
this pull request
Oct 10, 2026
#499) Non-cfg-layer Windows-hardcode audit (sister of the cfg-gate audit #492). b-class fixes (wrong on non-Windows builds): - tilde.rs home_value(): the USERPROFILE fallback (env_vars lookup + process env) ran un-gated, so a stray USERPROFILE exported by cross-platform tooling would hijack `~` on unix once HOME is unset. Now cfg(windows)-gated; unix keeps the empty default it always had. - main.rs identity disclosure/report: on non-Windows builds the persona is always native, but --help/--identity still advertised "unset RUBASH_IDENTITY to return to msys". Platform-split so unix prints an n/a switch line instead of an impossible instruction. c-class fixes (stale/dangling copy): - build_info.rs --version note pointed to docs/platform-support.md, which does not exist; repointed to the README identity section (both anchoring assertions updated). - README.md/README.zh-CN.md Quick Start still claimed "full functionality requires Windows today", contradicting the Platform status section (Linux native runs, macOS CI-green). - README.md identity section now states non-Windows builds always report the honest-native identity. Windows behavior is byte-identical (all edits are unix-arm additions or cfg(windows)-scoped text). Verified: cargo check --lib + cargo test --lib (642 passed; 2 pre-existing environment-dependent failures also failing on pristine origin/master) + cargo check --lib --target x86_64-unknown-linux-gnu.
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.
背景
#487(login shell)初版把平台门写成
target_os = "linux"、漏掉 release matrix 的 macOS 两腿。本 PR 是对 src/ 全部平台 cfg 门的平台门审计:全量盘点 + 分类判定,只提交无争议修复。结论先行:没有发现 #487 同类的「漏 macOS 腿」问题。 所有
target_os = "linux"独用门都是真 Linux 专属(内核/libc API 或编号契约),macOS 要么有显式 macos 腿、要么被 unix 全家门覆盖;#468(procsub fd)全程cfg(unix),macOS 正确。真正发现的同类问题是 android 腿被 kill/trap 信号表排除——#456 修了sa_restorer的门,但漏了信号编号表本体。已修。修复(本次提交,b 类无争议)
kill -l 17在 android(CI cross-target)上当前打印空、trap -l列出 bionic 不用的 BSD 名(7=EMT, 20=CHLD)。原因:kill 表的 Linux 腿target_os = "linux"不含 android,trap 表把所有非 Linux unix 送进 BSD 位置表。libc 0.2.186 android 模块实证 bionic 1..31 与 Linux 内核编号逐值一致(SIGBUS=7、SIGUSR1=10、SIGSTKFLT=16、SIGPWR=30、SIGSYS=31…):target_os = "linux"→any(target_os = "linux", target_os = "android")。RT 字面量块(34..64)保持 Linux 专属——glibc 契约 SIGRTMIN=34,bionic__libc_current_sigrtmin()=32,字面量在 android 上会是错的。not(any(linux, android))。空 RT 槽让越段数字 spec 静默接受(Linux 32/33 洞的形状),而不是宣传错误的 RTMIN 基数。现有positional_slots_match_libc/trap_table_agrees_with_kill_table交叉测试在 android 测试运行器下自动钉住新表。全量盘点表
统计口径:src/ 下含平台键的 cfg 共 511 处;
target_os族(排除 windows 专用)92 处、集中于 8 个文件;其余为unix/windows/not(windows)/cfg!运行时宏。判定为 a 类(真 Linux 专属 / 平台设计正确,保留)
target_os = "linux"sa_restorerany(linux, android)any(macos, freebsd)target_os = "linux"trap -l与 GNU signames 一致any(not(unix), target_os = "linux")all(unix, not(...))target_os = "linux"ulimit -a)逐行核对的 glibc 资源集(RTTIME/NICE/MSGQUEUE 等)target_env = "gnu"/ 非 gnu__rlimit_resource_tvs musl/OHOSc_int的编译正确性;OHOS(target_os="linux", target_env="ohos")天然被 linux 腿覆盖not(any(linux, macos))target_os = "android"cfg!)uname -p的 APPLE arm、GNU/Linux -o 等),平台差异均有 GNU 源码行号注释;macOS 腿显式存在target_env = "gnu"cfg(unix)面unixall(unix, not(android))/all(unix, android)target_os = "linux"/not(...)windows/unix/not(windows)判定为 b 类(门写窄了,已修)
target_os = "linux"any(target_os = "linux", target_os = "android")src/unix/linux_like/android/mod.rs:950-969逐值核对all(unix, not(linux))BSD 表all(unix, target_os = "android")64 槽表;BSD 门收窄近期 PR 复核(owner 点名的六条)
any(linux, android)(sa_restorer)、all(unix, not(android))(confstr)、test.rs AT_EACCESScfg(unix)存疑表(d 类,不动代码,需真机 oracle)
bash ulimit -aoracle 核对描述文案,维持保守集无害。pipe2,not(linux)腿可收窄为not(any(linux, android))省两次 fcntl;纯性能、语义等价,不动。__libc_current_sigrtmin()=32 运行时生成(const 表做不到,glibc 是函数、bionic 同),需真机验证。验证
cargo check(x86_64-pc-windows-msvc):通过cargo check --target aarch64-linux-android/armv7-linux-androideabi:通过(修复的 compile-level 证明)cargo check --target aarch64-apple-darwin:本机 rustup 拉取该 target std 失败(网络),待 CI cross-target check 腿;本次改动未触碰任何 macos/freebsd/unix 通用臂(diff 只在 linux/android 门与新 android 表),darwin 编译不受影响cargo test --lib:636 passed / 2 failed,与基线 a7cce03 完全一致(2 个失败为预存环境问题:pwd::logical_mode_reports_posix_drive_pwd_by_default、path::virtual_system_root_operand_resolution_keeps_option_b_and_legacy_verbatim,stash 后基线复跑同样失败)cargo fmt --check:通过Windows / macOS / linux-gnu 语义零变化:所有改动臂在这些 target 上编译排除。