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

Compiling without min_specialization and stdsimd #117

Closed
samueldotj opened this issue May 13, 2022 · 1 comment
Closed

Compiling without min_specialization and stdsimd #117

samueldotj opened this issue May 13, 2022 · 1 comment

Comments

@samueldotj
Copy link

We are using nightly channel but with limited features which results in compilation failure.

$ export RUSTFLAGS=-Zallow-features=
$ rustup run nightly cargo build

Error message:

error[E0725]: the feature `min_specialization` is not in the list of allowed features                                                                                                
  --> src/lib.rs:42:45                                                                                                                                                               
   |                                                                                                                                                                                 
42 | #![cfg_attr(feature = "specialize", feature(min_specialization))]                                                                                                               
   |                                             ^^^^^^^^^^^^^^^^^^                       
                                                                                                                                                                                     
error[E0725]: the feature `stdsimd` is not in the list of allowed features                                                                                                           
  --> src/lib.rs:43:42                       
   |                                                                                                                                                                                 
43 | #![cfg_attr(feature = "stdsimd", feature(stdsimd))]

https://docs.rs/version_check/latest/version_check/fn.supports_feature.html was proposed by one my colleague to solve this. I tried it and it seems to work.

diff --git a/build.rs b/build.rs
index 8be4964..0738275 100644
--- a/build.rs
+++ b/build.rs
@@ -4,11 +4,11 @@ use std::env;
 
 fn main() {
     println!("cargo:rerun-if-changed=build.rs");
-    if let Some(channel) = version_check::Channel::read() {
-        if channel.supports_features() {
-            println!("cargo:rustc-cfg=feature=\"specialize\"");
-            println!("cargo:rustc-cfg=feature=\"stdsimd\"");
-        }
+    if let Some(true) = version_check::supports_feature("specialize") {
+        println!("cargo:rustc-cfg=feature=\"specialize\"");
+    }
+    if let Some(true) = version_check::supports_feature("stdsimd") {
+        println!("cargo:rustc-cfg=feature=\"stdsimd\"");
     }
     let os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS was not set");
     if os.eq_ignore_ascii_case("linux")

Please make changes to avoid this failure.

tkaitchuck added a commit that referenced this issue May 26, 2022
@tkaitchuck
Copy link
Owner

Merged: 76dd8d2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants