-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
A-cross-compilingArea: using --target flag for other platformsArea: using --target flag for other platformsC-bugCategory: bugCategory: bugS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.Z-bindepsNightly: binary artifact dependenciesNightly: binary artifact dependencies
Description
I have a workspace with two crates:
- foo - cdylib library with
extern "C"functions - bar - application, that uses
foolibrary (as shared library)
The bar crate uses unstable bindeps feature of cargo to specify build dependency on artefact cdylib of foo library in Cargo.toml.
Everything works fine when built for native toolchain, but when I build bar with specifying a --target aarch64-unknown-linux-musl for cross compiling, then I get an error:
/work # cargo build --release --target aarch64-unknown-linux-musl -p bar
error: cannot produce cdylib for `foo v0.1.0 (/work/foo)` as the target `x86_64-unknown-linux-musl` does not support these crate typesIn the error above it says it can't produce cdylib for target x86_64, even though I specified aarch64.
If I build foo library, it compiled successfully:
/work # cargo build --release --target aarch64-unknown-linux-musl -p foo
Compiling foo v0.1.0 (/work/foo)
Finished `release` profile [optimized] target(s) in 0.14sI've attached a minimal example to reproduce that issue:
musl_cdylib.zip
It contains a workspace with foo and bar crates, Dockerfile to setup environment for cross compilation, and README.md with steps to build an image.
Meta
rustc --version --verbose:
rustc 1.86.0-nightly (419b3e2d3 2025-01-15)
binary: rustc
commit-hash: 419b3e2d3e350822550eee0e82eeded4d324d584
commit-date: 2025-01-15
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.6
Metadata
Metadata
Assignees
Labels
A-cross-compilingArea: using --target flag for other platformsArea: using --target flag for other platformsC-bugCategory: bugCategory: bugS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.Z-bindepsNightly: binary artifact dependenciesNightly: binary artifact dependencies