-
Notifications
You must be signed in to change notification settings - Fork 107
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
Support arbitrary toolchain versions in build.rs
#843
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aab066c
to
e5c3b22
Compare
This is almost certainly a job for the |
e5c3b22
to
5d3c25e
Compare
My current solution (just pushed) is to just skip UI tests on toolchains other than MSRV, stable, and nightly. |
0365b68
to
66b2089
Compare
In order to lower our MSRV as far as we'd like, we will be losing access to some features that we currently use. Some of these features cannot be simply worked around, and impose limitations on what APIs we can support (for example, what trait bounds can exist on `const fn`s). This commit works around this problem by introducing a general-purpose framework for detecting the toolchain version at compile time, and conditionally compiling code based on whether or not the toolchain is recent enough. This ensures that no user code will break. In particular, at any given time, if our MSRV is version N, then all code we publish is compatible wtih version N. If, later, we lower our MSRV to M < N, we can ensure that all functionality from the old version of zerocopy is still present when compiling on versions at least as recent as N. We know that none of our old users had an MSRV lower than N since they were using zerocopy with an MSRV of N. Thus, publishing a new version in which some features are not available on versions lower than N is not problematic for existing users. This approach introduces a new degree of freedom that we need to be sure to test in CI. Previously, in CI, we tested on the MSRV, stable, and nightly toolchain versions. Now, our behavior can differ on an arbitrary number of toolchains, and we need to make sure to test on every such toolchain. To accomplish this, we put the source of truth for these versions in `Cargo.toml`. We introduce a `build.rs` file which parses these versions and emits `--cfg` variables which can be used by our Rust code. We update `cargo.sh` to be able to make use of these versions, and add every such version as a toolchain to test in CI. Finally, we add a CI job which parses `Cargo.toml` and `.github/workflows/ci.yml` to ensure that every version listed in `Cargo.toml` is tested in CI. In order to test this framework, this commit lowers our MSRV to 1.58.0. Makes progress on #554
66b2089
to
cb48f4d
Compare
build.rs
jswrenn
approved these changes
Feb 7, 2024
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In order to lower our MSRV as far as we'd like, we will be losing access
to some features that we currently use. Some of these features cannot be
simply worked around, and impose limitations on what APIs we can support
(for example, what trait bounds can exist on
const fn
s).This commit works around this problem by introducing a general-purpose
framework for detecting the toolchain version at compile time, and
conditionally compiling code based on whether or not the toolchain is
recent enough. This ensures that no user code will break. In particular,
at any given time, if our MSRV is version N, then all code we publish is
compatible wtih version N. If, later, we lower our MSRV to M < N, we can
ensure that all functionality from the old version of zerocopy is still
present when compiling on versions at least as recent as N. We know that
none of our old users had an MSRV lower than N since they were using
zerocopy with an MSRV of N. Thus, publishing a new version in which some
features are not available on versions lower than N is not problematic
for existing users.
This approach introduces a new degree of freedom that we need to be sure
to test in CI. Previously, in CI, we tested on the MSRV, stable, and
nightly toolchain versions. Now, our behavior can differ on an arbitrary
number of toolchains, and we need to make sure to test on every such
toolchain. To accomplish this, we put the source of truth for these
versions in
Cargo.toml
. We introduce abuild.rs
file which parsesthese versions and emits
--cfg
variables which can be used by our Rustcode. We update
cargo.sh
to be able to make use of these versions, andadd every such version as a toolchain to test in CI. Finally, we add a
CI job which parses
Cargo.toml
and.github/workflows/ci.yml
toensure that every version listed in
Cargo.toml
is tested in CI.In order to test this framework, this commit lowers our MSRV to 1.58.0.
Makes progress on #554