mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 13:05:18 +03:00
Pass cargo.target to rustc
This commit is contained in:
@@ -543,7 +543,7 @@ pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_rustc_cfg_options() -> CfgOptions {
|
||||
pub fn get_rustc_cfg_options(target: Option<&String>) -> CfgOptions {
|
||||
let mut cfg_options = CfgOptions::default();
|
||||
|
||||
// Some nightly-only cfgs, which are required for stdlib
|
||||
@@ -558,10 +558,18 @@ pub fn get_rustc_cfg_options() -> CfgOptions {
|
||||
|
||||
match (|| -> Result<String> {
|
||||
// `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here.
|
||||
let output = Command::new("rustc")
|
||||
.args(&["--print", "cfg", "-O"])
|
||||
.output()
|
||||
.context("Failed to get output from rustc --print cfg -O")?;
|
||||
let output = if let Some(target) = target {
|
||||
Command::new("rustc")
|
||||
.args(&["--print", "cfg", "-O", "--target", target.as_str()])
|
||||
.output()
|
||||
.context("Failed to get output from rustc --print cfg -O")?
|
||||
} else {
|
||||
Command::new("rustc")
|
||||
.args(&["--print", "cfg", "-O"])
|
||||
.output()
|
||||
.context("Failed to get output from rustc --print cfg -O")?
|
||||
};
|
||||
|
||||
if !output.status.success() {
|
||||
bail!(
|
||||
"rustc --print cfg -O exited with exit code ({})",
|
||||
|
||||
@@ -149,7 +149,7 @@ pub(crate) fn load(
|
||||
|
||||
// FIXME: cfg options?
|
||||
let default_cfg_options = {
|
||||
let mut opts = get_rustc_cfg_options();
|
||||
let mut opts = get_rustc_cfg_options(None);
|
||||
opts.insert_atom("test".into());
|
||||
opts.insert_atom("debug_assertion".into());
|
||||
opts
|
||||
|
||||
@@ -131,7 +131,7 @@ pub fn new(
|
||||
|
||||
// FIXME: Read default cfgs from config
|
||||
let default_cfg_options = {
|
||||
let mut opts = get_rustc_cfg_options();
|
||||
let mut opts = get_rustc_cfg_options(config.cargo.target.as_ref());
|
||||
opts.insert_atom("test".into());
|
||||
opts.insert_atom("debug_assertion".into());
|
||||
opts
|
||||
|
||||
Reference in New Issue
Block a user