Skip to content

Commit fddf201

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 475f788 commit fddf201

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/librustc/session/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ pub enum PrintRequest {
164164
CrateName,
165165
Cfg,
166166
TargetList,
167+
TargetSpec,
167168
}
168169

169170
pub enum Input {
@@ -905,7 +906,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
905906
"[asm|llvm-bc|llvm-ir|obj|link|dep-info]"),
906907
opt::multi_s("", "print", "Comma separated list of compiler information to \
907908
print on stdout",
908-
"[crate-name|file-names|sysroot|cfg|target-list]"),
909+
"[crate-name|file-names|sysroot|cfg|target-list|target-spec]"),
909910
opt::flagmulti_s("g", "", "Equivalent to -C debuginfo=2"),
910911
opt::flagmulti_s("O", "", "Equivalent to -C opt-level=2"),
911912
opt::opt_s("o", "", "Write output to <filename>", "FILENAME"),
@@ -1189,6 +1190,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
11891190
"sysroot" => PrintRequest::Sysroot,
11901191
"cfg" => PrintRequest::Cfg,
11911192
"target-list" => PrintRequest::TargetList,
1193+
"target-spec" => PrintRequest::TargetSpec,
11921194
req => {
11931195
early_error(error_format, &format!("unknown print request `{}`", req))
11941196
}

src/librustc_driver/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ use rustc_metadata::loader;
7676
use rustc_metadata::cstore::CStore;
7777
use rustc::util::common::time;
7878

79+
use serialize::json::ToJson;
80+
7981
use std::cmp::max;
8082
use std::cmp::Ordering::Equal;
8183
use std::default::Default;
@@ -560,6 +562,7 @@ impl RustcDefaultCalls {
560562
println!("{}", targets.join("\n"));
561563
},
562564
PrintRequest::Sysroot => println!("{}", sess.sysroot().display()),
565+
PrintRequest::TargetSpec => println!("{}", sess.target.target.to_json().pretty()),
563566
PrintRequest::FileNames |
564567
PrintRequest::CrateName => {
565568
let input = match input {

0 commit comments

Comments
 (0)