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

Disable SIMD when targeting stable #105

Open
richarddd opened this issue Jun 19, 2024 · 0 comments
Open

Disable SIMD when targeting stable #105

richarddd opened this issue Jun 19, 2024 · 0 comments

Comments

@richarddd
Copy link

Hi,

It would be great if i can still use the simd feature, but disable its functionality when not building for nightly.

The simplest way to accomplish this would be in a build script call this:

fn set_nightly_cfg() {
    let rustc = std::env::var("RUSTC").unwrap();
    let version = std::process::Command::new(rustc)
        .arg("--version")
        .output()
        .unwrap();

    assert!(version.status.success());

    let stdout = String::from_utf8(version.stdout).unwrap();
    assert!(stdout.contains("rustc"));
    let nightly = stdout.contains("nightly") || stdout.contains("dev");
    if nightly {
        println!("cargo:rustc-cfg=rust_nightly");
        println!("cargo::rustc-check-cfg=cfg(rust_nightly)");
    }
}

And simd_portable + simd featues can then be feature gated like:

#![cfg_attr(rust_nightly, feature(portable_simd))]

Unfortunately cargo has no way to enable specific features on nightly only

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

1 participant