Open jpalus opened 1 year ago
Cargo does more on its own --target
flag than simply passing down to rustc
, such as platform dependency activation, feature unification, and build cache management, and probably more. And yeah, it could be missing host tools leading to this issue.
To me, I would avoid passing RUSTFLAGS
unless there is no alternative in Cargo. It might mess up rustc invocations and some assumptions from Cargo perhaps.
Out of curious, is there anything hinder you from using cargo --target
?
Out of curious, is there anything hinder you from using cargo --target?
The boring story is:
rust
based software for rpm
based distribution. Majority of software is obviously cargo
based and hence so far I've had %cargo_build
macro that included both RUSTFLAGS
with some minor flags as well as cargo
invocation with --target
as cargo
argument. Everything worked fine obviously.mesa
incorporated rusticl
that is not cargo
based but instead uses meson
. So now I needed to pass --target
somewhere else and it seemed the only option was to pass it in RUSTFLAGS
. Hence --target
became part of RUSTFLAGS
as well.rustc
is no longer happy about --target
being passed twice, both by RUSTFLAGS
and cargo
(even though it has the same value, it would be cool if it did not complain in that case):
error: Option 'target' given more than once
cargo
to rely on RUSTFLAGS
only. And here we are.I guess it would be possible to provide RUSTFLAGS
and build tool arguments for each and every build system out there, but it would be really nice if it wasn't necessary. I wish rustc
did not fail for --target
passed more than once with same value and it would be awesome if cargo
could derive --target
from RUSTFLAGS
if it's present there and no --target
was passed in command line.
Thank you for your reply. It is an interesting use case. Let me tell the hard part from Cargo's perspective, and we then try to find a workaround maybe.
if
cargo
could derive--target
fromRUSTFLAGS
if it's present there and no--target
was passed in command line.
Cargo already learns RUSTFLAGS
from a variety of sources like cfg(…)
and platform triples. It would be more convoluted to converge the final RUSTFLAGS
if we go that way. See:
And if I understand correctly, looks like you're trying to cross-compile from armv7-unknown-linux-gnueabihf
to thumbv7neon-unknown-linux-gnueabihf
, right? RUSTFLAGS
for cargo is applied to every rustc invocation. That means things ought to run on your host platform, like build script and procedual macros, compile to target platform. I guess this might not be the behaviour you desire. I am not familiar with how rusticl
handles such tools, though.
Personally, I guess it is more likely to do it in reverse: when RUSTFLAGS
contains --target
, Cargo warns and ignores it. Maybe filter it from here or elsewhere. However, I believe there are more flags other than --target
required to remove from RUSTFLAGS
. It is a somewhat breaking change as well.
BTW, if you want the other environment variable to control target platform of Cargo, CARGO_BUILD_TARGET
may help.
And if I understand correctly, looks like you're trying to cross-compile from armv7-unknown-linux-gnueabihf to thumbv7neon-unknown-linux-gnueabihf, right?
Correct. Since thumbv7neon-unknown-linux-gnueabihf
(or mentioned x86_64-unknown-linux-gnux32
) lacks its own host tools there's no other way but to cross compile (at least as far as I understand rust toolchain).
I am not familiar with how rusticl handles such tools, though.
Just to clarify it's rather how meson
handles such tools (meson
is used to build rust based rusticl
).
Personally, I guess it is more likely to do it in reverse: when RUSTFLAGS contains --target, Cargo warns and ignores it.
Indeed that would work.
BTW, if you want the other environment variable to control target platform of Cargo, CARGO_BUILD_TARGET may help.
Yes I'm aware of it but it suffers from the same issue of defining --target
twice. The question really is if it's possible to have common shared RUSTFLAGS
between various build systems that contains --target
. But turning things around -- couldn't --target
in RUSTFLAGS
be treated same way as CARGO_BUILD_TARGET
but without passing additional --target
to rustc
?
Problem
Trying to build delta 0.15.1 with:
fails with:
However moving
--target
fromRUSTFLAGS
tocargo
command line makes build successful:This seems to affect platforms from tiers without hosts tools only? Managed to reproduce it for
thumbv7neon-unknown-linux-gnueabihf
andx86_64-unknown-linux-gnux32
but not onx86_64-unknown-linux-gnu
,i686-unknown-linux-gnu
,aarch64-unknown-linux-gnu
,arm-unknown-linux-gnueabihf
orarmv7-unknown-linux-gnueabihf
.Steps
No response
Possible Solution(s)
No response
Notes
No response
Version