Skip to content

Commit 7770002

Browse files
committed
Fix everything
1 parent 2d3b388 commit 7770002

File tree

11 files changed

+22
-11
lines changed

11 files changed

+22
-11
lines changed

compiler/rustc_codegen_cranelift/build_system/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ impl<'a> TestRunner<'a> {
475475
cmd.arg("-Zunstable-options");
476476
cmd.arg("--check-cfg=cfg(no_unstable_features)");
477477
cmd.arg("--check-cfg=cfg(jit)");
478+
cmd.arg("--emit=metadata,link");
478479
cmd.args(args);
479480
cmd
480481
}

compiler/rustc_metadata/src/rmeta/encoder.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::errors::{FailCreateFileEncoder, FailWriteFile};
1+
use crate::errors::{FailCreateFileEncoder, FailWriteFile, FailedCreateFile};
22
use crate::rmeta::*;
33

44
use rustc_ast::Attribute;
@@ -2247,6 +2247,10 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path, ref_path: &Path) {
22472247
});
22482248
header.position.get()
22492249
});
2250+
} else {
2251+
std::fs::File::create(&ref_path).unwrap_or_else(|err| {
2252+
tcx.dcx().emit_fatal(FailedCreateFile { filename: &ref_path, err });
2253+
});
22502254
}
22512255
}
22522256

src/bootstrap/src/core/build_steps/compile.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,12 @@ pub fn run_cargo(
19541954
let file_stem = parts.next().unwrap().to_owned();
19551955
let extension = parts.next().unwrap().to_owned();
19561956

1957-
toplevel.push((file_stem, extension, expected_len));
1957+
if extension == "so" || extension == "dylib" {
1958+
// FIXME workaround for the fact that cargo doesn't understand `-Zsplit-metadata`
1959+
toplevel.push((file_stem.clone(), "rmeta".to_owned(), None));
1960+
}
1961+
1962+
toplevel.push((file_stem, extension, Some(expected_len)));
19581963
}
19591964
});
19601965

@@ -1975,7 +1980,7 @@ pub fn run_cargo(
19751980
.collect::<Vec<_>>();
19761981
for (prefix, extension, expected_len) in toplevel {
19771982
let candidates = contents.iter().filter(|&&(_, ref filename, ref meta)| {
1978-
meta.len() == expected_len
1983+
expected_len.map_or(true, |expected_len| meta.len() == expected_len)
19791984
&& filename
19801985
.strip_prefix(&prefix[..])
19811986
.map(|s| s.starts_with('-') && s.ends_with(&extension[..]))
@@ -1986,6 +1991,7 @@ pub fn run_cargo(
19861991
});
19871992
let path_to_add = match max {
19881993
Some(triple) => triple.0.to_str().unwrap(),
1994+
None if extension == "rmeta" => continue, // cfg(not(bootstrap)) remove this once -Zsplit-metadata is passed for all stages
19891995
None => panic!("no output generated for {prefix:?} {extension:?}"),
19901996
};
19911997
if is_dylib(path_to_add) {

tests/ui/duplicate_entry_error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// normalize-stderr-test "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib"
1+
// normalize-stderr-test "loaded from .*libstd-.*.rmeta" -> "loaded from SYSROOT/libstd-*.rmeta"
22
// note-pattern: first defined in crate `std`.
33

44
// Test for issue #31788 and E0152

tests/ui/duplicate_entry_error.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | | }
88
| |_^
99
|
1010
= note: the lang item is first defined in crate `std` (which `duplicate_entry_error` depends on)
11-
= note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
11+
= note: first definition in `std` loaded from SYSROOT/libstd-*.rmeta
1212
= note: second definition in the local crate (`duplicate_entry_error`)
1313

1414
error: aborting due to 1 previous error

tests/ui/error-codes/E0152.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// normalize-stderr-test "loaded from .*liballoc-.*.rlib" -> "loaded from SYSROOT/liballoc-*.rlib"
1+
// normalize-stderr-test "loaded from .*liballoc-.*.rmeta" -> "loaded from SYSROOT/liballoc-*.rmeta"
22
#![feature(lang_items)]
33

44
#[lang = "owned_box"]

tests/ui/error-codes/E0152.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | struct Foo<T>(T);
55
| ^^^^^^^^^^^^^^^^^
66
|
77
= note: the lang item is first defined in crate `alloc` (which `std` depends on)
8-
= note: first definition in `alloc` loaded from SYSROOT/liballoc-*.rlib
8+
= note: first definition in `alloc` loaded from SYSROOT/liballoc-*.rmeta
99
= note: second definition in the local crate (`E0152`)
1010

1111
error: aborting due to 1 previous error

tests/ui/lang-items/duplicate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// normalize-stderr-test "loaded from .*libcore-.*.rlib" -> "loaded from SYSROOT/libcore-*.rlib"
1+
// normalize-stderr-test "loaded from .*libcore-.*.rmeta" -> "loaded from SYSROOT/libcore-*.rmeta"
22
#![feature(lang_items)]
33

44
#[lang = "sized"]

tests/ui/lang-items/duplicate.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | trait Sized {}
55
| ^^^^^^^^^^^^^^
66
|
77
= note: the lang item is first defined in crate `core` (which `std` depends on)
8-
= note: first definition in `core` loaded from SYSROOT/libcore-*.rlib
8+
= note: first definition in `core` loaded from SYSROOT/libcore-*.rmeta
99
= note: second definition in the local crate (`duplicate`)
1010

1111
error: aborting due to 1 previous error

tests/ui/panic-handler/panic-handler-std.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// normalize-stderr-test "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib"
1+
// normalize-stderr-test "loaded from .*libstd-.*.rmeta" -> "loaded from SYSROOT/libstd-*.rmeta"
22
// error-pattern: found duplicate lang item `panic_impl`
33

44

tests/ui/panic-handler/panic-handler-std.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | | }
77
| |_^
88
|
99
= note: the lang item is first defined in crate `std` (which `panic_handler_std` depends on)
10-
= note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
10+
= note: first definition in `std` loaded from SYSROOT/libstd-*.rmeta
1111
= note: second definition in the local crate (`panic_handler_std`)
1212

1313
error: aborting due to 1 previous error

0 commit comments

Comments
 (0)