Skip to content

Commit ff11264

Browse files
committed
rustc: add --print target-spec option
This option provides the user the ability to dump the configuration that is in use by rustc for the target they are building for. Signed-off-by: Doug Goldstein <[email protected]>
1 parent 8285ab5 commit ff11264

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/librustc/session/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ pub enum PrintRequest {
308308
TargetFeatures,
309309
RelocationModels,
310310
CodeModels,
311+
TargetSpec,
311312
}
312313

313314
pub enum Input {
@@ -1141,6 +1142,9 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
11411142
let mut print_opts = vec!["crate-name", "file-names", "sysroot", "cfg",
11421143
"target-list", "target-cpus", "target-features",
11431144
"relocation-models", "code-models"];
1145+
if nightly_options::is_nightly_build() {
1146+
print_opts.push("target-spec-json");
1147+
}
11441148

11451149
vec![
11461150
opt::flag_s("h", "help", "Display this message"),
@@ -1471,6 +1475,8 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
14711475
"target-features" => PrintRequest::TargetFeatures,
14721476
"relocation-models" => PrintRequest::RelocationModels,
14731477
"code-models" => PrintRequest::CodeModels,
1478+
"target-spec-json" if nightly_options::is_unstable_enabled(matches)
1479+
=> PrintRequest::TargetSpec,
14741480
req => {
14751481
early_error(error_format, &format!("unknown print request `{}`", req))
14761482
}

src/librustc_driver/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ use rustc_metadata::locator;
8080
use rustc_metadata::cstore::CStore;
8181
use rustc::util::common::time;
8282

83+
use serialize::json::ToJson;
84+
8385
use std::cmp::max;
8486
use std::cmp::Ordering::Equal;
8587
use std::default::Default;
@@ -584,6 +586,7 @@ impl RustcDefaultCalls {
584586
println!("{}", targets.join("\n"));
585587
},
586588
PrintRequest::Sysroot => println!("{}", sess.sysroot().display()),
589+
PrintRequest::TargetSpec => println!("{}", sess.target.target.to_json().pretty()),
587590
PrintRequest::FileNames |
588591
PrintRequest::CrateName => {
589592
let input = match input {

0 commit comments

Comments
 (0)