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

[Build-script] unable to determine target details for custom target-spec #329

Open
boozook opened this issue Jul 1, 2024 · 1 comment
Open

Comments

@boozook
Copy link

boozook commented Jul 1, 2024

There is autocfg can't determine target details for custom target-spec (json file).

Error:

[num-traits 0.2.19] error: Error loading target specification: Could not find specification for target "my-custom-target". Run `rustc --print target-list` for a list of built-in targets
[num-traits 0.2.19] warning: autocfg could not probe for `std`
@boozook
Copy link
Author

boozook commented Jul 1, 2024

As an ugly workaround I could suggest something like this:

// save original to restore later:
let orig_target = std::env::var_os("TARGET")?;
// choose one of "override" or "by cargo":
let target = std::env::var_os("AUTOCONF_TARGET").or_else(|| env::var_os("TARGET"))?;
// override target for current use for autocfg:
std::env::set_var("TARGET", target);
let mut ac = autocfg::new();
ac.emit_expression_cfg("1f64.total_cmp(&2f64)", "has_total_cmp"); // 1.62
// do some needed...
autocfg::rerun_path("build.rs");
// restore original target for future use:
std::env::set_var("TARGET", orig_target);

And so we can override the target passed to autoconf with env AUTOCONF_TARGET.

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