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

Expose rustc version to build.rs #2903

Closed
mitsuhiko opened this issue Jul 21, 2016 · 7 comments
Closed

Expose rustc version to build.rs #2903

mitsuhiko opened this issue Jul 21, 2016 · 7 comments
Labels
A-build-scripts Area: build.rs scripts S-triage Status: This issue is waiting on initial triage.

Comments

@mitsuhiko
Copy link
Contributor

mitsuhiko commented Jul 21, 2016

Currently the only way to find the rustc version is to invoke rustc. Which is for instance what the rustc_version crate does. It would be great if RUSTC_VERSION or something similar was set automatically so that build scripts could customize what happens based on the version of Rust it compiles with.

See also #4408

@steveklabnik steveklabnik added the A-features Area: features — conditional compilation label Jul 21, 2016
@alexcrichton
Copy link
Member

I"m a little wary of piling too much information onto build script environment variables. Right now we added exposing RUSTC unconditionally as the compiler being used, would that be enough?

@nagisa
Copy link
Member

nagisa commented Jul 21, 2016

Link to the crate for the lazy: https://crates.io/crates/rustc_version

@mitsuhiko
Copy link
Contributor Author

@alexcrichton that"s what I"m using currently to shell out to rustc. Just seems like not particularly the best idea to parse compiler output manually for something that I would assume is a common problem. Alternatively one could make the argument that rust itself should provide a macro maybe that exposes the version?

@alexcrichton
Copy link
Member

Yeah I guess a macro would perhaps be better, one day Cargo may not always run rustc ahead of compiling crates, so it may not even have this information on hand at all time.

@ehuss ehuss added A-build-scripts Area: build.rs scripts and removed A-features Area: features — conditional compilation labels Nov 18, 2018
@dwijnand
Copy link
Member

dwijnand commented Feb 1, 2019

#4408 tracks the more general idea of setting an env var for the rust version.

@epage epage added the S-triage Status: This issue is waiting on initial triage. label Sep 28, 2023
@epage
Copy link
Contributor

epage commented Sep 28, 2023

I wonder if rust-lang/rfcs#2523 would be more appropriate. I feel like we should at least have a cohesive plan between cargo/lang on how we should be handled version detection.

@epage
Copy link
Contributor

epage commented Oct 17, 2023

Considering rust-lang/rfcs#2523 is an approved RFC that is meant to target these kinds of use cases, I"m going to close in favor of that. If there is a reason we should reconsider this, let us know!

Note that we still have #4408 for gathering the rustc version for reporting purposes (like a --bugreport flag)./

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2023
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 S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

7 participants