Skip to content

Commit

Permalink
rustc: add --print target-spec option
Browse files Browse the repository at this point in the history
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 <cardoe@cardoe.com>
  • Loading branch information
cardoe committed Dec 2, 2016
1 parent 8285ab5 commit ff11264
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/librustc/session/config.rs
Expand Up @@ -308,6 +308,7 @@ pub enum PrintRequest {
TargetFeatures,
RelocationModels,
CodeModels,
TargetSpec,
}

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

vec![
opt::flag_s("h", "help", "Display this message"),
Expand Down Expand Up @@ -1471,6 +1475,8 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
"target-features" => PrintRequest::TargetFeatures,
"relocation-models" => PrintRequest::RelocationModels,
"code-models" => PrintRequest::CodeModels,
"target-spec-json" if nightly_options::is_unstable_enabled(matches)
=> PrintRequest::TargetSpec,
req => {
early_error(error_format, &format!("unknown print request `{}`", req))
}
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_driver/lib.rs
Expand Up @@ -80,6 +80,8 @@ use rustc_metadata::locator;
use rustc_metadata::cstore::CStore;
use rustc::util::common::time;

use serialize::json::ToJson;

use std::cmp::max;
use std::cmp::Ordering::Equal;
use std::default::Default;
Expand Down Expand Up @@ -584,6 +586,7 @@ impl RustcDefaultCalls {
println!("{}", targets.join("\n"));
},
PrintRequest::Sysroot => println!("{}", sess.sysroot().display()),
PrintRequest::TargetSpec => println!("{}", sess.target.target.to_json().pretty()),
PrintRequest::FileNames |
PrintRequest::CrateName => {
let input = match input {
Expand Down

0 comments on commit ff11264

Please sign in to comment.