Skip to content

fix: replace nostd_detect with generated calls to std::arch:: macros#22

Open
Petrusion wants to merge 5 commits intoronnychevalier:mainfrom
Petrusion:remove-dependency-notstd-detect
Open

fix: replace nostd_detect with generated calls to std::arch:: macros#22
Petrusion wants to merge 5 commits intoronnychevalier:mainfrom
Petrusion:remove-dependency-notstd-detect

Conversation

@Petrusion
Copy link

Made based on discussions in #20 and #21. Fixes #20.

Summary:

  • The stable toolchain can now be used! (although using nightly is still beneficial because of build-std)
  • Builds having more target features than can be detected at runtime now results in a compilation error that can be fixed with --exclude-cpu-features
  • Changed CI toolchain to stable (to avoid having to keep up with which features to exclude on nightly)
  • Unlike fix: ignore target-features that are not supported by notstd_detect #21, this PR doesn't break cross compilation and doesn't require maintaining notstd_detect

It would be amazing if we could make it so that (on nightly) features unsupported by std::arch are filtered automatically. Maybe that can be solved later, but for now, reading a compilation error and adding --exclude-cpu-features is incomparably better than multivers silently not working.

Please let me know what you think.

@ronnychevalier
Copy link
Owner

You can also update the README:

  • +nightly is no longer needed
  • Same regarding the GitHub action section and nightly
  • You can mention the tip about --exclude-cpu-features in the Usage section for instance

@ronnychevalier
Copy link
Owner

Otherwise, it is indeed a good solution to the current issue, thanks for the PR!

@ronnychevalier ronnychevalier added bug Something isn't working enhancement New feature or request labels Mar 12, 2026
@ronnychevalier
Copy link
Owner

Also, when you update the PR, I would prefer if you could override old versions of commits by squashing your changes into the original commit, and force push the branch. The idea is to avoid in the same PR commits that revert or change what other commits did (for instance, you should not have refactor commits that refactor what you did in a previous commit in your PR).

@Petrusion Petrusion force-pushed the remove-dependency-notstd-detect branch from 64359d1 to b8a3563 Compare March 17, 2026 22:57
@Petrusion
Copy link
Author

I would prefer if you could override old versions of commits by squashing your changes into the original commit, and force push the branch

Ok, done. I hope I did that right.

Replaces the notstd_detect dependency, instead generating code (during multivers-runner build) that checks for the exact features that the builds were compiled with. This approach has two major advantages over notstd_detect: cargo-multivers now works on the stable toolchain, and builds having more target features than can be detected at runtime (which caused ronnychevalier#20) now results in a compilation error (raised by std::arch:: macro) instead of silently using the least optimized build.

Also adds a custom implementation of PartialEq for Build, since all_features_supported (a function pointer) shouldn't be compared for equality.

See discussions in ronnychevalier#20 and ronnychevalier#21. Unlike ronnychevalier#21, this commit doesn't break cross compilation.
Since multivers-runner no longer depends on notstd_detect, the nightly toolchain requirement can be dropped.
This test tries to find the sse feature, but that won't work when ran with 'cargo test' because there were no features in JSON loaded from MULTIVERS_BUILDS_DESCRIPTION_PATH. The test made sense in the past when the runner was detecting all available features, now it only detects features the builds were compiled with.
Since the project can now fail to build on nightly when nightly rustc prints more target cpu features than std::arch::is_ARCH_feature_detected!() supports (which is the case as of this moment). A user of cargo-multivers would simply use --exclude-cpu-features on features that are causing the compile time error, but using nightly in CI would mean keeping up with which features are supported by rustc but not std::arch:: macros.
Update readme to show that nightly is no longer needed (but recommended for build-std). Also added a tip about using --exclude-cpu-features to avoid compilation errors when std::arch:: macros are not caught up to rustc's supported features.
@Petrusion Petrusion force-pushed the remove-dependency-notstd-detect branch from b8a3563 to 5e0692d Compare March 18, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Binary uses generic x86_64 version of code even though additional target features are available

2 participants