MSRV and adopting new features. #220
Replies: 2 comments 8 replies
-
I might be misunderstanding your use case or constraints, but I don't believe the only option is to detect nightly vs non-nightly. In zerocopy, we have the same problem, and we solve it by also detecting the stable version (via Would that approach be viable for ahash? |
Beta Was this translation helpful? Give feedback.
-
Is that #183?
Why is it building on 1.60 but not on 1.71? That shouldn't usually happen, except if the build script detect 1.71 and uses that to enable more stuff. (memoffset does that, and then of course one has to have all the "threshold" versions where new stuff gets enabled on CI.) |
Beta Was this translation helpful? Give feedback.
-
In order to support LTS, many libraries work with a fixed version of the compiler not taking advantage of any new capability or feature. Specifically users do not like when the MSRV is increased in a patch release, and they would like to continue working with newer versions of the library without updating their compiler version.
Other users are very up to date, and nearly immediately after any relevant feature or capability lands in nightly there is someone opening an issue or a PR requesting it.
Right now if the code mentions or attempts to use a feature on a compiler version that is unaware of that feature results in a compile error. Ideally it would be possible to use
cfg
to only include code based if the feature is available. This way if a feature is released in one version, users running that version of the compiler can use it right away, while users of older compilers still get working code. This is currently not allowed.As a workaround, a hack was introduced. A
build.rs
file can be used to detect if the compiler is nightly. This is not as good, because a feature may be released, but if was introduced in a version above the MSRV only nightly users can use even though it is in stable. But this appears to be the best than can be done for now. The idea is people who are running nightly compilers which are up to date, and will use and want the newer and more advanced features. Everyone else will get only the features available as of the MSRV.Today aHash is effectively forked with one codepath that compiles with the latest and greatest for those who want the new capabilities, and one that is permanently tied to Rust 1.60.0. This was not so much planned but where things have ended up.
In that context here is a timeline of recent stdsimd breakage:
build.rs
trick to detect nightly. Everything works fine on all versions of Rust.build.rs
flag and replace it with a feature flag. This is done to prevent future breakage of nightly as the feature is planned to be renamed. (And it is successful at this)(Note that this is a build failure in stable Rust involving released features, and nightly has nothing to do with it)
stdsimd
feature which the originaly was introduced to prevent. Because the latest release was already working without the feature everything continued to work with the latest released versions. However there were people running against 0.7.6 which was 3 years old. (The difference between 0.7 and 0.8 only relates to very advanced features that would not affect 99% of users.) As a result builds failed for people specifically using the latest nightly with a very out of data ahash, but anyone affected could just bump the version and rebuild.The current status is that aHash builds everywhere but stable features are being hidden behind nightly flags to avoid compile errors. The current plan is to release a 1.0.0 version which bumps the MSRV to 1.72.0 which removes the feature flag.
In the longer term it would be much better if this could be handled with conditional compilation. This would avoid not only the need to have flags and document them to users, but this would also have avoided the whole category of breakage on stable that occured in steps 2, 3, and 4 above. Additionally even if the PR in 1 were never created in the first place no code would have ever been broken because when the rename of the feature occured it would have simply disabled the codepath. This would be MUCH better than what we have now.
Beta Was this translation helpful? Give feedback.
All reactions