Skip to content

build(rust2): build the ffi staticlib for the C++ target arch (Refs #1552) - #1553

Merged
caomengxuan666 merged 1 commit into
mainfrom
fix/1552-arm64-bridge-symbols
Nov 10, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
fix/1552-arm64-bridge-symbols

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #1552

What changed

The rust2 command library (winuxcmd_ffi.lib) was built by cargo with no
target selection, so it always carried the host architecture. The arm64
legs of build-winuxcmd.yml cross-compile from an x64 host (vcvars
x64_arm64, /machine:ARM64 at link time), so they received an x86_64
staticlib whose objects cannot satisfy the bridge references, and the
link of winuxcmd.exe stopped with LNK2001 for winuxcmd_abi_version,
winuxcmd_run and winuxcmd_free_buf plus LNK1120. The x64 legs were
unaffected because host and link target agree there.

  • CMakeLists.txt: derive the Rust target triple from the C++ target
    arch (explicit package arch, then the vcvars target environment, then
    the processor; a cache variable WINUXCMD_RUST2_TARGET_TRIPLE can
    override), always pass it to cargo with --target, and consume the
    per-triple artifact path
    rust2-target/<triple>/release/winuxcmd_ffi.lib on both
    architectures. The symbol definitions, the ABI header and the bridge
    are untouched, and no library leaves the link.
  • .github/workflows/build-winuxcmd.yml: the arm64 legs install the
    aarch64-pc-windows-msvc std library before configuring, since the
    runner image only carries the host target.

本 PR 删除了什么

Nothing is deleted. The single replaced line is the previous
host-layout artifact path in CMakeLists.txt, superseded by the
per-triple path above.

Verification

Verified locally at source level: the derivation block was extracted
verbatim and exercised with cmake -P across five input shapes (CI
arm64, CI x64, local vcvars cross, local native, explicit override) and
resolved to the expected triple and artifact path each time; the
per-triple cargo artifact layout was confirmed with a minimal
staticlib crate. The MSVC build itself cannot run on this Linux host,
so the deciding evidence is this PR's own CI: the arm64 full leg is
expected to link winuxcmd.exe with no LNK2001 for the three bridge
symbols. Baseline infrastructure reds noted in the issue (pcre2
download HTTP 504 on some legs, gnulib HTTP 500 on the oracle leg) are
unrelated to this change.

No user-visible text changes; the i18n catalogs are not affected.

The cargo invocation for winuxcmd_ffi.lib never passed --target, so on
the x64 CI host the arm64 legs (vcvars x64_arm64) silently linked an
x86_64 staticlib whose objects cannot resolve the bridge ABI symbols
for an ARM64 link (LNK2001 x3 + LNK1120).

Derive the Rust target triple from the C++ target arch (package arch,
then the vcvars target environment, then the processor), always pass
--target, and consume the per-triple artifact path on both
architectures. The workflow installs the aarch64 std library for the
arm64 legs, which the runner image does not carry by default.

Refs #1552
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 10, 2026 05:47
@caomengxuan666
caomengxuan666 merged commit 606c263 into main Nov 10, 2026
21 of 22 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 10, 2026
…plets

Three CI findings from PR #1561's first run, each traced to root cause:

i18n-drift: the 25 new-drift rows are all stale zh-CN keys whose source
strings this PR deleted (the 10 C++ bodies + test_expr.hpp, incl.
command.readlink/realpath.error.file_name_too_long — the Rust
fsutil::reason statics replaced the keyed i18n::format calls). Verified
PR-introduced: main tip measures none of them (its CI is green), and the
catalog clone carries the keys for text my branch no longer produces.
Recorded as deliberate growth with check_i18n_drift.py
--update-baseline per the #1534/#1547 precedent; the eventual shrink is
the catalog cleanup batch in unixwin/winuxcmd-i18n.

baseline (GNU master differential), 2 real mismatches vs the live oracle:
- mkdir -m 888 printed the usage Try-hint; GNU mkdir.c:290 treats an
  invalid mode as a runtime operand error - one stderr line, no hint.
  mkdir.rs writes the line directly now.
- test -f /dev/null returned 0: the operand reaches the library as the
  NUL DOS device and metadata() succeeds on it; -f now rejects DOS char
  devices (GNU: char device is not a regular file, rc 1).

build-windows x64 ctest, 4 symlink rows the local runner skipped
(no symlink privilege) that the CI runner executes:
- readlink -f / realpath default / realpath -m on a dangling leaf link
  (dang -> z_absent_tgt) now resolve the leaf symlink to its target's
  path (<parent>/z_absent_tgt, rc 0) instead of echoing the link name -
  AllButLast splices the read_link target onto the canonical parent and
  folds it lexically; NoCheck does the same over the -m walk; -e keeps
  failing (probed GNU 9.4). canon unit test pins the class where
  symlinks are creatable, skips where they are not.
- realpath --relative-to: the common-prefix walk compared components
  case-sensitively, so the CI runner's lowercase-drive ctx.cwd ("d:\...")
  never matched the canonicalized target's "D:\..." and the output fell
  back to absolute. Component comparison is now case-insensitive
  (Windows path spellings are case-variants).

pgrep_inverse_excludes_matches failed once on CI and passes on rerun -
the #1553 pid-flake family, unrelated.

Refs #1488
caomengxuan666 added a commit that referenced this pull request Nov 10, 2026
…plets

Three CI findings from PR #1561's first run, each traced to root cause:

i18n-drift: the 25 new-drift rows are all stale zh-CN keys whose source
strings this PR deleted (the 10 C++ bodies + test_expr.hpp, incl.
command.readlink/realpath.error.file_name_too_long — the Rust
fsutil::reason statics replaced the keyed i18n::format calls). Verified
PR-introduced: main tip measures none of them (its CI is green), and the
catalog clone carries the keys for text my branch no longer produces.
Recorded as deliberate growth with check_i18n_drift.py
--update-baseline per the #1534/#1547 precedent; the eventual shrink is
the catalog cleanup batch in unixwin/winuxcmd-i18n.

baseline (GNU master differential), 2 real mismatches vs the live oracle:
- mkdir -m 888 printed the usage Try-hint; GNU mkdir.c:290 treats an
  invalid mode as a runtime operand error - one stderr line, no hint.
  mkdir.rs writes the line directly now.
- test -f /dev/null returned 0: the operand reaches the library as the
  NUL DOS device and metadata() succeeds on it; -f now rejects DOS char
  devices (GNU: char device is not a regular file, rc 1).

build-windows x64 ctest, 4 symlink rows the local runner skipped
(no symlink privilege) that the CI runner executes:
- readlink -f / realpath default / realpath -m on a dangling leaf link
  (dang -> z_absent_tgt) now resolve the leaf symlink to its target's
  path (<parent>/z_absent_tgt, rc 0) instead of echoing the link name -
  AllButLast splices the read_link target onto the canonical parent and
  folds it lexically; NoCheck does the same over the -m walk; -e keeps
  failing (probed GNU 9.4). canon unit test pins the class where
  symlinks are creatable, skips where they are not.
- realpath --relative-to: the common-prefix walk compared components
  case-sensitively, so the CI runner's lowercase-drive ctx.cwd ("d:\...")
  never matched the canonicalized target's "D:\..." and the output fell
  back to absolute. Component comparison is now case-insensitive
  (Windows path spellings are case-variants).

pgrep_inverse_excludes_matches failed once on CI and passes on rerun -
the #1553 pid-flake family, unrelated.

Refs #1488
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.

1 participant