rust-num / num-complex

Complex numbers for Rust
Apache License 2.0
232 stars 50 forks source link

Release update fixing no_std builds #55

Closed lights0123 closed 5 years ago

lights0123 commented 5 years ago

54 was merged, which should allow for fixing no_std builds. rust-num/num-traits#115 released 0.2.8 of num-traits, fixing that. I currently cannot build no_std projects depending on num. Can we release a new version of num-complex that includes this change?

cuviper commented 5 years ago

If you already updated num-traits with the problematic autocfg, can't you just update those again? There's nothing strictly necessary about bumping the version here, just a little extra assurance.

lights0123 commented 5 years ago

@cuviper The currently published version (0.2.1) does not even use autocfg at all—it is still using the old probe function. Here's the build.rs file from the currently published version:

use std::env;
use std::io::Write;
use std::process::{Command, Stdio};

fn main() {
    if probe("fn main() { 0i128; }") {
        println!("cargo:rustc-cfg=has_i128");
    } else if env::var_os("CARGO_FEATURE_I128").is_some() {
        panic!("i128 support was not detected!");
    }
}

/// Test if a code snippet can be compiled
fn probe(code: &str) -> bool {
    let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
    let out_dir = env::var_os("OUT_DIR").expect("environment variable OUT_DIR");

    let mut child = Command::new(rustc)
        .arg("--out-dir")
        .arg(out_dir)
        .arg("--emit=obj")
        .arg("-")
        .stdin(Stdio::piped())
        .spawn()
        .expect("rustc probe");

    child
        .stdin
        .as_mut()
        .expect("rustc stdin")
        .write_all(code.as_bytes())
        .expect("write rustc stdin");

    child.wait().expect("rustc probe").success()
}
cuviper commented 5 years ago

Sure, but doesn't the currently published build.rs work with no_std? AFAIK the problem was only with the initial change to autocfg, as that had problems with forcing the target in probes.

If that's not working, please share what versions you're using and the error messages.

(I should publish a new version here anyway, but I won't be able to do that today.)

cuviper commented 5 years ago

num-complex 0.2.2 and 0.2.3 have been published.