Skip to content

Compiling without min_specialization and stdsimd #117

@samueldotj

Description

@samueldotj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions