Support arbitrary toolchain versions in build.rs
#843
Merged
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