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

Release update fixing no_std builds #55

Closed
lights0123 opened this issue Jun 2, 2019 · 4 comments
Closed

Release update fixing no_std builds #55

lights0123 opened this issue Jun 2, 2019 · 4 comments

Comments

@lights0123
Copy link

#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
Copy link
Member

cuviper commented Jun 2, 2019

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
Copy link
Author

@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
Copy link
Member

cuviper commented Jun 2, 2019

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
Copy link
Member

cuviper commented Jun 13, 2019

num-complex 0.2.2 and 0.2.3 have been published.

@cuviper cuviper closed this as completed Jun 13, 2019
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