Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo should be able to conditionally build targets #6617

Closed
asomers opened this issue Feb 1, 2019 · 3 comments
Closed

Cargo should be able to conditionally build targets #6617

asomers opened this issue Feb 1, 2019 · 3 comments
Labels
A-cross-compiling Area: using --target flag for other platforms C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@asomers
Copy link

asomers commented Feb 1, 2019

Describe the problem you are trying to solve
Some targets, especially [[test]] targets, don't make sense to run on every platform. Cargo should allow you to conditionally enable them in the manifest. On Nix this merely causes an annoyance; some tests must have their entire bodies #[cfg()]ed out. But on libc the problem is more severe; the s390x and sparc64 targets crash in the test harness before executing any tests. There's no way to fix that problem from within test code itself; a Cargo solution is required.

Describe the solution you'd like
It would be great if the [[test]] section could be conditionally enabled, like this:

[[test]]
name = "test-something"
only-on = 'cfg(target_os = "multics")'

or this:

[[test.'cfg(target_os = "multics")']]
name = "test-something"

Notes
Here's a PR that shows s390x and sparc64 failing early in the test harness.
rust-lang/libc#1235

@asomers asomers added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Feb 1, 2019
@andreeaflorescu
Copy link

We also have a similar problem and I think it is due to the fact that cargo downloads and compiles all the dependencies even though they're not used on the platform that we're building on. It looks to me that cargo is ignoring the targets & profiles specified in Cargo.toml. Is this the expected behaviour?
Should the dev dependencies be downloaded & compiled for a release build?

@tasogare3710
Copy link

I also having similar same problem.
However, in order to solve this, I think that concept like configuration of apache ivy which can be freely customized is necessary.

cargo profile may be replaced in this configuration concept?

@ehuss ehuss added the A-cross-compiling Area: using --target flag for other platforms label Apr 27, 2020
@epage
Copy link
Contributor

epage commented Oct 31, 2023

Looks like #9208 is a duplicate of this but it has more discussions, so I'm closing this in favor of that. If there is something I overlooked, let us know!

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross-compiling Area: using --target flag for other platforms C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

5 participants