@@ -168,22 +168,11 @@ impl TargetInfo {
168
168
loop {
169
169
let extra_fingerprint = kind. fingerprint_hash ( ) ;
170
170
171
- // Query rustc for supported -Csplit-debuginfo values
172
- let support_split_debuginfo = rustc
173
- . cached_output (
174
- rustc. workspace_process ( ) . arg ( "--print=split-debuginfo" ) ,
175
- extra_fingerprint,
176
- )
177
- . unwrap_or_default ( )
178
- . 0
179
- . lines ( )
180
- . map ( String :: from)
181
- . collect ( ) ;
182
-
183
171
// Query rustc for several kinds of info from each line of output:
184
172
// 0) file-names (to determine output file prefix/suffix for given crate type)
185
173
// 1) sysroot
186
- // 2) cfg
174
+ // 2) split-debuginfo
175
+ // 3) cfg
187
176
//
188
177
// Search `--print` to see what we query so far.
189
178
let mut process = rustc. workspace_process ( ) ;
@@ -213,6 +202,8 @@ impl TargetInfo {
213
202
}
214
203
215
204
process. arg ( "--print=sysroot" ) ;
205
+ process. arg ( "--print=split-debuginfo" ) ;
206
+ process. arg ( "--print=crate-name" ) ; // `___` as a delimiter.
216
207
process. arg ( "--print=cfg" ) ;
217
208
218
209
let ( output, error) = rustc
@@ -251,6 +242,26 @@ impl TargetInfo {
251
242
} ) ;
252
243
sysroot_target_libdir. push ( "lib" ) ;
253
244
245
+ let support_split_debuginfo = {
246
+ // HACK: abuse `--print=crate-name` to use `___` as a delimiter.
247
+ let mut res = Vec :: new ( ) ;
248
+ loop {
249
+ match lines. next ( ) {
250
+ Some ( line) if line == "___" => break ,
251
+ Some ( line) => res. push ( line. into ( ) ) ,
252
+ None => {
253
+ return error_missing_print_output (
254
+ "split-debuginfo" ,
255
+ & process,
256
+ & output,
257
+ & error,
258
+ )
259
+ }
260
+ }
261
+ }
262
+ res
263
+ } ;
264
+
254
265
let cfg = lines
255
266
. map ( |line| Ok ( Cfg :: from_str ( line) ?) )
256
267
. filter ( TargetInfo :: not_user_specific_cfg)
@@ -601,6 +612,20 @@ fn parse_crate_type(
601
612
Ok ( Some ( ( prefix. to_string ( ) , suffix. to_string ( ) ) ) )
602
613
}
603
614
615
+ /// Helper for creating an error message for missing output from a certain `--print` request.
616
+ fn error_missing_print_output < T > (
617
+ request : & str ,
618
+ cmd : & ProcessBuilder ,
619
+ stdout : & str ,
620
+ stderr : & str ,
621
+ ) -> CargoResult < T > {
622
+ let err_info = output_err_info ( cmd, stdout, stderr) ;
623
+ anyhow:: bail!(
624
+ "output of --print={request} missing when learning about \
625
+ target-specific information from rustc\n {err_info}",
626
+ )
627
+ }
628
+
604
629
/// Helper for creating an error message when parsing rustc output fails.
605
630
fn output_err_info ( cmd : & ProcessBuilder , stdout : & str , stderr : & str ) -> String {
606
631
let mut result = format ! ( "command was: {}\n " , cmd) ;
0 commit comments