Skip to content

Route get_toolchain() through ppbt.archive_for(triplet) for cross builds - #353

Merged
dwoz merged 1 commit into
mainfrom
switch-ppbt-archive-for-triplet
Nov 21, 2026
Merged

dwoz merged 1 commit into
mainfrom
switch-ppbt-archive-for-triplet

Conversation

@dwoz

@dwoz dwoz commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Switches relenv's get_toolchain() to look up the toolchain tarball via ppbt.common.archive_for(triplet) (ppbt 0.2.0+) so a cross-arch request on an x86_64 host picks the aarch64 tarball out of the sibling ppbt-cross-aarch64-linux-gnu package, and vice versa. Pre-0.2.0 ppbt only exposed ARCHIVE (host native only), so cross-arch requests silently extracted the host tarball and the downstream build ended up calling x86_64 gcc with an aarch64 target triplet — the root reason gh-37's cross-build path was never actually exercised end-to-end.

ppbt 0.2.0 is already on PyPI with the new sibling packages (ppbt-cross-aarch64-linux-gnu carries a manylinux_2_17_x86_64 wheel; ppbt-cross-x86_64-linux-gnu carries a manylinux_2_17_aarch64 wheel). Sibling packages register themselves via the ppbt.toolchains entry point.

Changes

  • relenv/common.py: use archive_for(triplet) when ppbt exposes it; fall back to ARCHIVE for compat with 0.1.x. Missing cross archive + no existing toolchain dir raises a helpful "pip install ppbt[cross-<triplet>]" message.
  • pyproject.toml: bump the toolchain extra to ppbt>=0.2.0, add toolchain-cross-aarch64-linux-gnu, toolchain-cross-x86_64-linux-gnu, toolchain-cross-all extras that forward the ppbt extras through.
  • tests/test_common.py: extend _mock_ppbt_module to simulate 0.2.0+ shape; add three new tests covering cross-triplet routing, missing-cross-archive error, and graceful fallback to an already-extracted dir.

Test plan

Pre-0.2.0 ppbt only exposed `ARCHIVE` which pointed at the host
native toolchain, so a cross-arch request on an x86_64 host silently
extracted the x86_64 tarball into `<data>/toolchain/aarch64-linux-gnu/`
and the downstream build used x86_64 gcc with an aarch64 target
triplet.  ppbt 0.2.0 adds `archive_for(triplet)` which resolves cross
triplets through the `ppbt.toolchains` entry point to the matching
`ppbt-cross-<triplet>` sibling package.

- Use `archive_for(triplet)` when the ppbt in use exposes it; fall
  back to `ARCHIVE` for compat with 0.1.x installs.
- If the resolved archive doesn't exist (user hasn't installed the
  `ppbt[cross-<triplet>]` extra), surface a clear error instead of
  silently extracting the host tarball — unless the target toolchain
  dir already exists from a prior run, in which case we return it.
- Expose matching extras in pyproject.toml so
  `pip install relenv[toolchain-cross-aarch64-linux-gnu]` pulls in
  the sibling package.
- Extend _mock_ppbt_module to simulate 0.2.0+ shape and cover three
  new cases: cross-triplet routed via archive_for, missing cross
  archive raises, missing archive + existing toolchain returns dir.
@dwoz
dwoz force-pushed the switch-ppbt-archive-for-triplet branch from bd1f1c4 to d6e129d Compare November 21, 2026 10:09
@dwoz
dwoz merged commit 0ea0426 into main Nov 21, 2026
89 checks passed
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