Skip to content

Disable SIMD when targeting stable #105

@richarddd

Description

@richarddd

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

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