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 provide builtin support to let build.rs detect feature is supported #12872

Closed
loynoir opened this issue Oct 24, 2023 · 4 comments
Closed
Labels
A-build-scripts Area: build.rs scripts C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@loynoir
Copy link

loynoir commented Oct 24, 2023

Problem

There is a

  • 1 ~ 2 weeks project, with 1 ~ 2 weeks cache

  • recent RA v0.3.1705

  • deep dependency tree have recent version, thiserror-1.0.50 anyhow-1.0.75, same author dtolnay

I encounter same old bug on thiserror-1.0.50 anyhow-1.0.75.

  • #![feature] may not be used on the stable release channel`

This bug was happening one year ago, but then fix.

In conclusion, this is maybe a mix problem of

  • build.rs workaround to detect feature, such as error_generic_member_access, is supported

  • RA rustc wrapper for performance

  • sccache

  • cargo build cache

And I think the core problem is

  • cargo does not provide builtin support to let build.rs detect feature is supported, so dev invent themself.

Proposed Solution

cargo should provide builtin support to let build.rs detect feature is supported

Notes

Related

dtolnay/thiserror#192

https://github.com/dtolnay/thiserror/blob/e9ea67c7e251764c3c2d839b6c06d9f35b154647/build.rs#L12

https://github.com/dtolnay/anyhow/blob/05e413219e97f101d8f39a90902e5c5d39f951fe/build.rs#L17

rust-lang/rust-analyzer#15057

@loynoir loynoir added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Oct 24, 2023
@epage
Copy link
Contributor

epage commented Oct 24, 2023

Cargo has no knowledge of #![feature]s and doing something regarding this would be more of a language-level feature, like rust-lang/rust#64797. With this in mind, I'm going to close this issue. If there is something I missed, let us know and we can reconsider opening this. If you are looking for next steps, maybe try posting about this idea on internals.rust-lang.org/.

Personally, I think auto-detecting nightly features is a mistake and instead feature flags should be used to enable them explicitly.

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2023
@epage epage added the A-build-scripts Area: build.rs scripts label Oct 24, 2023
@loynoir
Copy link
Author

loynoir commented Oct 25, 2023

Generally, I think implement which makes less assumption is better than implement which makes more assumption.

So, personally, I agree with @epage .

According to my understanding, epage suggest

Personally, I think auto-detecting nightly features is a mistake and instead feature flags should be used to enable them explicitly.

anyhow = { version = "xxx", features = ["nightly"] }

But, @dtolnay does not agree.

So, I still insist

  • rustc or cargo should provide builtin support to let build.rs detect feature is supported

Which will make build system robust, with less assumption.

@epage
Copy link
Contributor

epage commented Oct 25, 2023

Note that I did not close this because of my opinion but that cargo isn't in a place to solve this.

@loynoir
Copy link
Author

loynoir commented Oct 26, 2023

Tired. Leave it for next one who fall into cargo clean workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-scripts Area: build.rs scripts C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants