11// Tests the -Zembed-metadata compiler flag.
22// Tracking issue: https://github.com/rust-lang/rust/issues/139165
33
4+ //@ needs-dynamic-linking
5+ //@ needs-crate-type: dylib
6+
47use run_make_support:: rfs:: { create_dir, remove_file, rename} ;
5- use run_make_support:: { Rustc , dynamic_lib_name, path, run_in_tmpdir, rust_lib_name, rustc} ;
8+ use run_make_support:: {
9+ Rustc , dynamic_lib_name, path, run_in_tmpdir, rust_lib_name, rustc, target,
10+ } ;
611
712#[ derive( Debug , Copy , Clone ) ]
813enum LibraryKind {
@@ -42,7 +47,7 @@ fn main() {
4247fn lookup_rmeta_in_lib_dir ( kind : LibraryKind ) {
4348 run_in_tmpdir ( || {
4449 build_dep_rustc ( kind) . run ( ) ;
45- rustc ( ) . input ( "foo.rs" ) . run ( ) ;
50+ rustc ( ) . target ( target ( ) ) . input ( "foo.rs" ) . run ( ) ;
4651 } ) ;
4752}
4853
@@ -54,6 +59,7 @@ fn lookup_rmeta_through_extern(kind: LibraryKind) {
5459 build_dep_rustc ( kind) . out_dir ( "deps" ) . run ( ) ;
5560
5661 let mut rustc = rustc ( ) ;
62+ rustc. target ( target ( ) ) ;
5763 kind. add_extern ( & mut rustc, "dep1" , "deps" ) ;
5864 rustc. extern_ ( "dep1" , path ( "deps" ) . join ( "libdep1.rmeta" ) ) ;
5965 rustc. input ( "foo.rs" ) . run ( ) ;
@@ -67,13 +73,15 @@ fn lookup_rmeta_missing(kind: LibraryKind) {
6773 build_dep_rustc ( kind) . out_dir ( "deps" ) . run ( ) ;
6874
6975 let mut rustc = rustc ( ) ;
76+ rustc. target ( target ( ) ) ;
7077 kind. add_extern ( & mut rustc, "dep1" , "deps" ) ;
7178 rustc. input ( "foo.rs" ) . run_fail ( ) . assert_stderr_contains ( "only metadata stub found" ) ;
7279 } ) ;
7380}
7481
7582fn build_dep_rustc ( kind : LibraryKind ) -> Rustc {
7683 let mut dep_rustc = rustc ( ) ;
84+ dep_rustc. target ( target ( ) ) ;
7785 dep_rustc
7886 . arg ( "-Zembed-metadata=no" )
7987 . crate_type ( kind. crate_type ( ) )
0 commit comments