Skip to content

Commit

Permalink
Rollup merge of #69608 - o01eg:expose-target-libdir-print, r=ehuss
Browse files Browse the repository at this point in the history
Expose target libdir information via print command

With custom libdir it is required to have an access to library placement.

See RazrFalcon/cargo-bloat#51
  • Loading branch information
Centril authored Mar 8, 2020
2 parents ff96178 + dbd1514 commit 5e9888e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/doc/rustc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ The valid types of print values are:
- `crate-name` — The name of the crate.
- `file-names` — The names of the files created by the `link` emit kind.
- `sysroot` — Path to the sysroot.
- `target-libdir` - Path to the target libdir.
- `cfg` — List of cfg values. See [conditional compilation] for more
information about cfg values.
- `target-list` — List of known targets. The target may be selected with the
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,10 @@ impl RustcDefaultCalls {
println!("{}", targets.join("\n"));
}
Sysroot => println!("{}", sess.sysroot.display()),
TargetLibdir => println!(
"{}",
sess.target_tlib_path.as_ref().unwrap_or(&sess.host_tlib_path).dir.display()
),
TargetSpec => println!("{}", sess.target.target.to_json().pretty()),
FileNames | CrateName => {
let input = input.unwrap_or_else(|| {
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ impl ExternEntry {
pub enum PrintRequest {
FileNames,
Sysroot,
TargetLibdir,
CrateName,
Cfg,
TargetList,
Expand Down Expand Up @@ -912,7 +913,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
"",
"print",
"Compiler information to print on stdout",
"[crate-name|file-names|sysroot|cfg|target-list|\
"[crate-name|file-names|sysroot|target-libdir|cfg|target-list|\
target-cpus|target-features|relocation-models|\
code-models|tls-models|target-spec-json|native-static-libs]",
),
Expand Down Expand Up @@ -1344,6 +1345,7 @@ fn collect_print_requests(
"crate-name" => PrintRequest::CrateName,
"file-names" => PrintRequest::FileNames,
"sysroot" => PrintRequest::Sysroot,
"target-libdir" => PrintRequest::TargetLibdir,
"cfg" => PrintRequest::Cfg,
"target-list" => PrintRequest::TargetList,
"target-cpus" => PrintRequest::TargetCPUs,
Expand Down

0 comments on commit 5e9888e

Please sign in to comment.