← Back to issue list

rust plugin does not cross-compile

View original Github issue

Metadata

Project
craft-parts
Number
#1015
Type
issue
State
open
Author
lengau
Labels
Status: Triaged Type: Bug
Created
Updated
Closed

Current evaluation

Rust plugin builds for host arch instead of target arch when cross-compiling. Triaged by maintainer with a fix plan (map arch to rust triple, rustup target add, set CARGO_BUILD_TARGET); a working PR branch was shared Aug 2025, but no fix has landed in craft-parts yet.

Suggested action: keep open

Reason: The issue is labelled Status: Triaged and the maintainer (lengau) actively worked it: on 2025-02-13 they outlined the fix (map target arch to rust triple, run `rustup target add`, set `CARGO_BUILD_TARGET`/`--target`), noted remaining linking issues, and on 2025-08-15 pointed to a working PR branch (lengau/uv-snap#9). The current rust_plugin.py still has no CARGO_BUILD_TARGET or target-triple handling, so the bug is unfixed and the issue remains actionable.

Impact: 65 Quick Win: 26.0 Staleness: 45 Complexity: 60 Confidence: 70 Support Request: 5

Issue body

### Bug Description The `rust` plugin does correctly handle cross-compiling, instead still building for the host architectures. ### To Reproduce 1. Use the `rust` plugin with a different target architecture from the host architecture 2. Examine the output `elf` file(s) ### part yaml ```shell parts: uv: plugin: rust source: https://github.com/astral-sh/uv.git source-tag: $SNAPCRAFT_PROJECT_VERSION build-packages: - cmake build-attributes: - enable-patchelf organize: uv: bin/uv uvx: bin/uvx lib*.so: lib/ ``` ### Relevant log output ```shell $ unsquashfs astral-uv_0.5.29_armhf.snap Parallel unsquashfs: Using 16 processors 5 inodes (321 blocks) to write [==========================================================================================================|] 326/326 100% created 5 files created 4 directories created 0 symlinks created 0 devices created 0 fifos created 0 sockets created 0 hardlinks lengau@ratel:~/Projects/uv-snap$ file squashfs-root/bin/uv squashfs-root/bin/uv: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /snap/core24/current/lib64/ld-linux-x86-64.so.2, BuildID[sha1]=5ea30677c06472fa51db130472ba4f97b74a1786, for GNU/Linux 3.2.0, stripped ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 65
Quick Win: 26.0
Staleness: 45
Complexity: 60
Confidence: 70
Support Request: 5
keep open Rust plugin builds for host arch instead of target arch when cross-compiling. Triaged by maintainer with a fix plan (map arch to rust triple, rustup target add, set CARGO_BUILD_TARGET); a working PR branch was shared Aug 2025, but no fix has landed in craft-parts yet.
qwen/qwen3.6-35b-a3b
Staleness: 75
Complexity: 60
Confidence: 85
Support Request: 5
keep open The rust plugin incorrectly builds for the host architecture instead of cross-compiling to the target. Triaged by a maintainer who outlined a fix and linked a working PR, but has seen no activity for over 11 months.
qwen3.6-35b-a3b-mtp-q6
Staleness: 68
Complexity: 45
Confidence: 85
Support Request: 0
keep open Rust plugin fails to cross-compile, building for host architecture instead. Triaged bug with maintainer-proposed fix and a working PR branch, but inactive for over 10 months.
qwen3.6-35b-a3b-mtp-q6
Staleness: 78
Complexity: 55
Confidence: 80
Support Request: 5
keep open rust plugin ignores cross-compilation targets, building host binaries. Triaged bug. Author proposed mapping architectures to rust triplets and setting CARGO_BUILD_TARGET, but hit linker errors. A functional PR branch exists. Awaiting review.

Update history

No update history recorded yet.

Related work

  • Related To: canonical/snapcraft#1350 (confidence 55%)

    Merged snapcraft PR adding cross-compilation support to the Rust plugin; likely the upstream counterpart, but this issue targets craft-parts and no craft-parts fix commit was found.

Related issues

Issue Project State Summary Similarity
#1350 rust plugin: Add support for cross-compilation snapcraft merged Cross-compilation support added to the Rust plugin for snapcraft's --target-arch flag. Approved and merged despite unresolved comments and lack of ARM hardware testing.
75%
#2158 rust plugin: fix cargo builds and run tests snapcraft closed Changes to fix cargo builds and add tests to the Rust plugin were closed and superseded by PR #2170 after the author discovered cargo test conflicts with cross-compilation, requiring a rework.
73%
#2264 Fix issue where Rust cross compile target is ignored snapcraft merged Merged fix for Rust cross-compilation target being ignored. The plugin now only generates a .cargo/config file if one is missing, preserving existing project configs while fixing cross-compile paths.
72%