Skip to content

Commit d16304a

Browse files
authored
Rollup merge of rust-lang#69608 - o01eg:expose-target-libdir-print, r=ehuss
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
2 parents 9f7dab3 + dbd1514 commit d16304a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/doc/rustc/src/command-line-arguments.md

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ The valid types of print values are:
146146
- `crate-name` — The name of the crate.
147147
- `file-names` — The names of the files created by the `link` emit kind.
148148
- `sysroot` — Path to the sysroot.
149+
- `target-libdir` - Path to the target libdir.
149150
- `cfg` — List of cfg values. See [conditional compilation] for more
150151
information about cfg values.
151152
- `target-list` — List of known targets. The target may be selected with the

src/librustc_driver/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,10 @@ impl RustcDefaultCalls {
680680
println!("{}", targets.join("\n"));
681681
}
682682
Sysroot => println!("{}", sess.sysroot.display()),
683+
TargetLibdir => println!(
684+
"{}",
685+
sess.target_tlib_path.as_ref().unwrap_or(&sess.host_tlib_path).dir.display()
686+
),
683687
TargetSpec => println!("{}", sess.target.target.to_json().pretty()),
684688
FileNames | CrateName => {
685689
let input = input.unwrap_or_else(|| {

src/librustc_session/config.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ impl ExternEntry {
391391
pub enum PrintRequest {
392392
FileNames,
393393
Sysroot,
394+
TargetLibdir,
394395
CrateName,
395396
Cfg,
396397
TargetList,
@@ -912,7 +913,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
912913
"",
913914
"print",
914915
"Compiler information to print on stdout",
915-
"[crate-name|file-names|sysroot|cfg|target-list|\
916+
"[crate-name|file-names|sysroot|target-libdir|cfg|target-list|\
916917
target-cpus|target-features|relocation-models|\
917918
code-models|tls-models|target-spec-json|native-static-libs]",
918919
),
@@ -1344,6 +1345,7 @@ fn collect_print_requests(
13441345
"crate-name" => PrintRequest::CrateName,
13451346
"file-names" => PrintRequest::FileNames,
13461347
"sysroot" => PrintRequest::Sysroot,
1348+
"target-libdir" => PrintRequest::TargetLibdir,
13471349
"cfg" => PrintRequest::Cfg,
13481350
"target-list" => PrintRequest::TargetList,
13491351
"target-cpus" => PrintRequest::TargetCPUs,

0 commit comments

Comments
 (0)