@@ -83,7 +83,7 @@ fn release_profile_default_to_object() {
83
83
[COMPILING] foo v0.0.1 ([CWD])
84
84
[RUNNING] `rustc [..]\
85
85
-Zremap-path-scope=object \
86
- --remap-path-prefix=[CWD]= \
86
+ --remap-path-prefix=[CWD]=. \
87
87
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
88
88
[FINISHED] release [..]" ,
89
89
)
@@ -121,7 +121,7 @@ fn one_option() {
121
121
[COMPILING] foo v0.0.1 ([CWD])
122
122
[RUNNING] `rustc [..]\
123
123
-Zremap-path-scope={option} \
124
- --remap-path-prefix=[CWD]= \
124
+ --remap-path-prefix=[CWD]=. \
125
125
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
126
126
[FINISHED] dev [..]" ,
127
127
) )
@@ -158,7 +158,7 @@ fn multiple_options() {
158
158
[COMPILING] foo v0.0.1 ([CWD])
159
159
[RUNNING] `rustc [..]\
160
160
-Zremap-path-scope=diagnostics,macro,object \
161
- --remap-path-prefix=[CWD]= \
161
+ --remap-path-prefix=[CWD]=. \
162
162
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
163
163
[FINISHED] dev [..]" ,
164
164
)
@@ -193,7 +193,7 @@ fn profile_merge_works() {
193
193
[COMPILING] foo v0.0.1 ([CWD])
194
194
[RUNNING] `rustc [..]\
195
195
-Zremap-path-scope=diagnostics \
196
- --remap-path-prefix=[CWD]= \
196
+ --remap-path-prefix=[CWD]=. \
197
197
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
198
198
[FINISHED] custom [..]" ,
199
199
)
@@ -243,7 +243,7 @@ fn registry_dependency() {
243
243
[COMPILING] foo v0.0.1 ([CWD])
244
244
[RUNNING] `rustc [..]\
245
245
-Zremap-path-scope=object \
246
- --remap-path-prefix=[CWD]= \
246
+ --remap-path-prefix=[CWD]=. \
247
247
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
248
248
[FINISHED] dev [..]
249
249
[RUNNING] `target/debug/foo[EXE]`"
@@ -297,7 +297,7 @@ fn git_dependency() {
297
297
[COMPILING] foo v0.0.1 ([CWD])
298
298
[RUNNING] `rustc [..]\
299
299
-Zremap-path-scope=object \
300
- --remap-path-prefix=[CWD]= \
300
+ --remap-path-prefix=[CWD]=. \
301
301
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
302
302
[FINISHED] dev [..]
303
303
[RUNNING] `target/debug/foo[EXE]`"
@@ -338,12 +338,12 @@ fn path_dependency() {
338
338
[COMPILING] bar v0.0.1 ([..]/cocktail-bar)
339
339
[RUNNING] `rustc [..]\
340
340
-Zremap-path-scope=object \
341
- --remap-path-prefix=[CWD]= \
341
+ --remap-path-prefix=[CWD]=. \
342
342
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
343
343
[COMPILING] foo v0.0.1 ([CWD])
344
344
[RUNNING] `rustc [..]\
345
345
-Zremap-path-scope=object \
346
- --remap-path-prefix=[CWD]= \
346
+ --remap-path-prefix=[CWD]=. \
347
347
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
348
348
[FINISHED] dev [..]
349
349
[RUNNING] `target/debug/foo[EXE]`"
@@ -392,7 +392,7 @@ fn path_dependency_outside_workspace() {
392
392
[COMPILING] foo v0.0.1 ([CWD])
393
393
[RUNNING] `rustc [..]\
394
394
-Zremap-path-scope=object \
395
- --remap-path-prefix=[CWD]= \
395
+ --remap-path-prefix=[CWD]=. \
396
396
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
397
397
[FINISHED] dev [..]
398
398
[RUNNING] `target/debug/foo[EXE]`"
@@ -446,40 +446,73 @@ fn diagnostics_works() {
446
446
"\
447
447
[RUNNING] [..]rustc [..]\
448
448
-Zremap-path-scope=diagnostics \
449
- --remap-path-prefix=[CWD]= \
449
+ --remap-path-prefix=[CWD]=. \
450
450
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]",
451
451
)
452
452
. run ( ) ;
453
453
}
454
454
455
455
#[ cfg( target_os = "macos" ) ]
456
- #[ cargo_test( requires_nm, nightly, reason = "-Zremap-path-scope is unstable" ) ]
457
- fn object_works ( ) {
458
- object_works_helper ( |path| {
456
+ mod object_works {
457
+ use super :: * ;
458
+
459
+ fn inspect_debuginfo ( path : & std:: path:: Path ) -> Vec < u8 > {
459
460
std:: process:: Command :: new ( "nm" )
460
461
. arg ( "-pa" )
461
462
. arg ( path)
462
463
. output ( )
463
464
. expect ( "nm works" )
464
465
. stdout
465
- } )
466
+ }
467
+
468
+ #[ cargo_test( requires_nm, nightly, reason = "-Zremap-path-scope is unstable" ) ]
469
+ fn with_split_debuginfo_off ( ) {
470
+ object_works_helper ( "off" , inspect_debuginfo) ;
471
+ }
472
+
473
+ #[ cargo_test( requires_nm, nightly, reason = "-Zremap-path-scope is unstable" ) ]
474
+ fn with_split_debuginfo_packed ( ) {
475
+ object_works_helper ( "packed" , inspect_debuginfo) ;
476
+ }
477
+
478
+ #[ cargo_test( requires_nm, nightly, reason = "-Zremap-path-scope is unstable" ) ]
479
+ fn with_split_debuginfo_unpacked ( ) {
480
+ object_works_helper ( "unpacked" , inspect_debuginfo) ;
481
+ }
466
482
}
467
483
468
484
#[ cfg( target_os = "linux" ) ]
469
- #[ cargo_test( requires_readelf, nightly, reason = "-Zremap-path-scope is unstable" ) ]
470
- fn object_works ( ) {
471
- object_works_helper ( |path| {
485
+ mod object_works {
486
+ use super :: * ;
487
+
488
+ fn inspect_debuginfo ( path : & std:: path:: Path ) -> Vec < u8 > {
472
489
std:: process:: Command :: new ( "readelf" )
473
- . arg ( "-wi" )
490
+ . arg ( "--debug-dump=info" )
491
+ . arg ( "--debug-dump=no-follow-links" ) // older version can't recognized but just a warning
474
492
. arg ( path)
475
493
. output ( )
476
494
. expect ( "readelf works" )
477
495
. stdout
478
- } )
496
+ }
497
+
498
+ #[ cargo_test( requires_readelf, nightly, reason = "-Zremap-path-scope is unstable" ) ]
499
+ fn with_split_debuginfo_off ( ) {
500
+ object_works_helper ( "off" , inspect_debuginfo) ;
501
+ }
502
+
503
+ #[ cargo_test( requires_readelf, nightly, reason = "-Zremap-path-scope is unstable" ) ]
504
+ fn with_split_debuginfo_packed ( ) {
505
+ object_works_helper ( "packed" , inspect_debuginfo) ;
506
+ }
507
+
508
+ #[ cargo_test( requires_readelf, nightly, reason = "-Zremap-path-scope is unstable" ) ]
509
+ fn with_split_debuginfo_unpacked ( ) {
510
+ object_works_helper ( "unpacked" , inspect_debuginfo) ;
511
+ }
479
512
}
480
513
481
514
#[ cfg( unix) ]
482
- fn object_works_helper ( run : impl Fn ( & std:: path:: Path ) -> Vec < u8 > ) {
515
+ fn object_works_helper ( split_debuginfo : & str , run : impl Fn ( & std:: path:: Path ) -> Vec < u8 > ) {
483
516
use std:: os:: unix:: ffi:: OsStrExt ;
484
517
485
518
let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
@@ -495,14 +528,19 @@ fn object_works_helper(run: impl Fn(&std::path::Path) -> Vec<u8>) {
495
528
let p = project ( )
496
529
. file (
497
530
"Cargo.toml" ,
498
- r#"
531
+ & format ! (
532
+ r#"
499
533
[package]
500
534
name = "foo"
501
535
version = "0.0.1"
502
536
503
537
[dependencies]
504
538
bar = "0.0.1"
505
- "# ,
539
+
540
+ [profile.dev]
541
+ split-debuginfo = "{split_debuginfo}"
542
+ "#
543
+ ) ,
506
544
)
507
545
. file ( "src/main.rs" , "fn main() { bar::f(); }" )
508
546
. build ( ) ;
@@ -523,34 +561,21 @@ fn object_works_helper(run: impl Fn(&std::path::Path) -> Vec<u8>) {
523
561
524
562
p. cargo ( "clean" ) . run ( ) ;
525
563
526
- p. change_file (
527
- "Cargo.toml" ,
528
- r#"
529
- [package]
530
- name = "foo"
531
- version = "0.0.1"
532
-
533
- [dependencies]
534
- bar = "0.0.1"
535
-
536
- [profile.dev]
537
- trim-paths = "object"
538
- "# ,
539
- ) ;
540
-
541
564
p. cargo ( "build --verbose -Ztrim-paths" )
565
+ . arg ( "--config" )
566
+ . arg ( r#"profile.dev.trim-paths="object""# )
542
567
. masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
543
568
. with_stderr ( & format ! (
544
569
"\
545
570
[COMPILING] bar v0.0.1
546
- [RUNNING] `rustc [..]\
571
+ [RUNNING] `rustc [..]-C split-debuginfo={split_debuginfo} [..] \
547
572
-Zremap-path-scope=object \
548
573
--remap-path-prefix={pkg_remap} \
549
574
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
550
575
[COMPILING] foo v0.0.1 ([CWD])
551
- [RUNNING] `rustc [..]\
576
+ [RUNNING] `rustc [..]-C split-debuginfo={split_debuginfo} [..] \
552
577
-Zremap-path-scope=object \
553
- --remap-path-prefix=[CWD]= \
578
+ --remap-path-prefix=[CWD]=. \
554
579
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]
555
580
[FINISHED] dev [..]" ,
556
581
) )
@@ -560,31 +585,44 @@ fn object_works_helper(run: impl Fn(&std::path::Path) -> Vec<u8>) {
560
585
assert ! ( bin_path. is_file( ) ) ;
561
586
let stdout = run ( & bin_path) ;
562
587
assert ! ( memchr:: memmem:: find( & stdout, rust_src) . is_none( ) ) ;
563
- if cfg ! ( target_os = "macos" ) {
564
- for line in stdout. split ( |c| c == & b'\n' ) {
565
- let registry = memchr:: memmem:: find ( line, registry_src_bytes) . is_none ( ) ;
566
- let local = memchr:: memmem:: find ( line, pkg_root) . is_none ( ) ;
567
- if registry && local {
568
- continue ;
569
- }
588
+ for line in stdout. split ( |c| c == & b'\n' ) {
589
+ let registry = memchr:: memmem:: find ( line, registry_src_bytes) . is_none ( ) ;
590
+ let local = memchr:: memmem:: find ( line, pkg_root) . is_none ( ) ;
591
+ if registry && local {
592
+ continue ;
593
+ }
570
594
595
+ #[ cfg( target_os = "macos" ) ]
596
+ {
597
+ // `OSO` symbols can't be trimmed at this moment.
598
+ // See <https://github.com/rust-lang/rust/issues/116948#issuecomment-1793617018>
571
599
if memchr:: memmem:: find ( line, b" OSO " ) . is_some ( ) {
572
- // `OSO` symbols can't be trimmed at this moment.
573
- // See <https://github.com/rust-lang/rust/issues/116948#issuecomment-1793617018>
574
- // TODO: Change to `is_none()` once the issue is resolved.
575
600
continue ;
576
601
}
577
602
578
603
// on macOS `SO` symbols are embedded in final binaries and should be trimmed.
579
604
// See rust-lang/rust#117652.
580
- assert ! (
581
- memchr:: memmem:: find( line, b" SO " ) . is_some( ) ,
582
- "untrimmed `SO` symbol found"
583
- )
605
+ if memchr:: memmem:: find ( line, b" SO " ) . is_some ( ) {
606
+ continue ;
607
+ }
608
+ }
609
+
610
+ #[ cfg( target_os = "linux" ) ]
611
+ {
612
+ // There is a bug in rustc `-Zremap-path-scope`.
613
+ // See rust-lang/rust/pull/118518
614
+ if memchr:: memmem:: find ( line, b"DW_AT_comp_dir" ) . is_some ( ) {
615
+ continue ;
616
+ }
617
+ if memchr:: memmem:: find ( line, b"DW_AT_GNU_dwo_name" ) . is_some ( ) {
618
+ continue ;
619
+ }
584
620
}
585
- } else {
586
- assert ! ( memchr:: memmem:: find( & stdout, registry_src_bytes) . is_none( ) ) ;
587
- assert ! ( memchr:: memmem:: find( & stdout, pkg_root) . is_none( ) ) ;
621
+
622
+ panic ! (
623
+ "unexpected untrimmed symbol: {}" ,
624
+ String :: from_utf8( line. into( ) ) . unwrap( )
625
+ ) ;
588
626
}
589
627
}
590
628
@@ -700,7 +738,7 @@ fn lldb_works_after_trimmed() {
700
738
"\
701
739
[RUNNING] `rustc [..]\
702
740
-Zremap-path-scope=object \
703
- --remap-path-prefix=[CWD]= \
741
+ --remap-path-prefix=[CWD]=. \
704
742
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]",
705
743
)
706
744
. run ( ) ;
0 commit comments