cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.49k stars 365 forks source link

cross build --target-dir does not behave the same as cargo build --target-dir #1326

Closed jasonsewall closed 1 year ago

jasonsewall commented 1 year ago

Checklist

Describe your issue

cargo build --target-dir=<dir> will use <dir> instead of any target-specific prefix. So:

$ cargo build --target-dir=mytargets/linux-amd64 -q
$ ls mytargets/linux-amd64
CACHEDIR.TAG debug
$ ls mytargets/linux-amd64/debug
build deps examples incremental <my libs> <my exes>

cross appears to do something quite different that I don't understand.

$ cross build --target-dir=mytargets/linux-arm64 --target=aarch64-unknown-linux-gnu -q
$ ls mytargets/linux-arm64
aarch64-unknown-linux-gnu CACHEDIR.TAG debug
$ ls mytargets/linux-arm64/debug
build deps examples incremental # nothing else
$ ls mytargets/linux-arm64/aarch64-unknown-linux-gnu
CACHEDIR.TAG debug
$ ls mytargets/linux-arm64/aarch64-unknown-linux-gnu/debug
build deps examples incremental <my libs> <my exes>

So it still creates the target dir of its choosing, just inside whatever target-dir I specify. Furthermore, it appears to copy some of the build artifacts (but not the final products) among /.

I'd expect this instead to work the way cargo does. This makes target-dir pretty unusable.

What target(s) are you cross-compiling for?

aarch64-unknown-linux-gnu

Which operating system is the host (e.g computer cross is on) running?

What architecture is the host?

What container engine is cross using?

cross version

cross 0.2.5 (a599f20 2023-08-23)

Example

See the description.

Additional information / notes

No response

jasonsewall commented 1 year ago

This might just be a symptom of cargo itself exhibiting this behavior, upon further experimentation.

Emilgardis commented 1 year ago

Yes, this is how cargo works, you'll get the same behaviour when using cargo build --target target --target-dir target-dir