Skip to content

Commit 3f0743c

Browse files
authored
Merge pull request rust-lang#1954 from rust-lang/rustc-pull
Rustc pull update
2 parents c781066 + 2da4b67 commit 3f0743c

File tree

576 files changed

+1971
-2434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

576 files changed

+1971
-2434
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ jobs:
3131
os: ubuntu-24.04-arm
3232
multiarch: armhf
3333
gcc_cross: arm-linux-gnueabihf
34-
# Disabled due to Ubuntu repo trouble
34+
# Ubuntu mirrors are not reliable enough for these architectures
35+
# (see <https://bugs.launchpad.net/ubuntu/+bug/2130309>).
3536
# - host_target: riscv64gc-unknown-linux-gnu
3637
# os: ubuntu-latest
3738
# multiarch: riscv64
@@ -68,7 +69,7 @@ jobs:
6869
- name: install multiarch
6970
if: ${{ matrix.multiarch != '' }}
7071
run: |
71-
# s390x, ppc64el, riscv64 need Ubuntu Ports to be in the mirror list
72+
# armhf, s390x, ppc64el, riscv64 need Ubuntu Ports to be in the mirror list
7273
sudo bash -c "echo 'https://ports.ubuntu.com/ priority:4' >> /etc/apt/apt-mirrors.txt"
7374
# Add architecture
7475
sudo dpkg --add-architecture ${{ matrix.multiarch }}

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ degree documented below):
220220
- `solaris` / `illumos`: maintained by @devnexen. Supports the entire test suite.
221221
- `freebsd`: maintained by @YohDeadfall and @LorrensP-2158466. Supports the entire test suite.
222222
- `android`: **maintainer wanted**. Support very incomplete, but a basic "hello world" works.
223-
- `wasi`: **maintainer wanted**. Support very incomplete, but a basic "hello world" works.
224223
- For targets on other operating systems, Miri might fail before even reaching the `main` function.
225224

226225
However, even for targets that we do support, the degree of support for accessing platform APIs
@@ -292,6 +291,9 @@ Try running `cargo miri clean`.
292291
Miri adds its own set of `-Z` flags, which are usually set via the `MIRIFLAGS`
293292
environment variable. We first document the most relevant and most commonly used flags:
294293

294+
* `-Zmiri-backtrace=<0|1|full>` configures how Miri prints backtraces: `1` is the default,
295+
where backtraces are printed in pruned form; `full` prints backtraces without pruning, and `0`
296+
disables backtraces entirely.
295297
* `-Zmiri-deterministic-concurrency` makes Miri's concurrency-related behavior fully deterministic.
296298
Strictly speaking, Miri is always fully deterministic when isolation is enabled (the default
297299
mode), but this determinism is achieved by using an RNG with a fixed seed. Seemingly harmless
@@ -373,6 +375,12 @@ environment variable. We first document the most relevant and most commonly used
373375
ensure alignment. (The standard library `align_to` method works fine in both modes; under
374376
symbolic alignment it only fills the middle slice when the allocation guarantees sufficient
375377
alignment.)
378+
* `-Zmiri-user-relevant-crates=<crate>,<crate>,...` extends the list of crates that Miri considers
379+
"user-relevant". This affects the rendering of backtraces (for user-relevant crates, Miri shows
380+
not just the function name but the actual code) and it affects the spans collected for data races
381+
and aliasing violations (where Miri will show the span of the topmost non-`#[track_caller]` frame
382+
in a user-relevant crate). When using `cargo miri`, the crates in the local workspace are always
383+
considered user-relevant.
376384

377385
The remaining flags are for advanced use only, and more likely to change or be removed.
378386
Some of these are **unsound**, which means they can lead
@@ -474,7 +482,8 @@ to Miri failing to detect cases of undefined behavior in a program.
474482
* `-Zmiri-track-alloc-id=<id1>,<id2>,...` shows a backtrace when the given allocations are
475483
being allocated or freed. This helps in debugging memory leaks and
476484
use after free bugs. Specifying this argument multiple times does not overwrite the previous
477-
values, instead it appends its values to the list. Listing an id multiple times has no effect.
485+
values, instead it appends its values to the list. Listing an ID multiple times has no effect.
486+
You can also add IDs at runtime using `miri_track_alloc`.
478487
* `-Zmiri-track-pointer-tag=<tag1>,<tag2>,...` shows a backtrace when a given pointer tag
479488
is created and when (if ever) it is popped from a borrow stack (which is where the tag becomes invalid
480489
and any future use of it will error). This helps you in finding out why UB is

cargo-miri/src/phases.rs

Lines changed: 8 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,6 @@ fn show_version() {
5252
println!();
5353
}
5454

55-
fn forward_patched_extern_arg(args: &mut impl Iterator<Item = String>, cmd: &mut Command) {
56-
cmd.arg("--extern"); // always forward flag, but adjust filename:
57-
let path = args.next().expect("`--extern` should be followed by a filename");
58-
if let Some(lib) = path.strip_suffix(".rlib") {
59-
// If this is an rlib, make it an rmeta.
60-
cmd.arg(format!("{lib}.rmeta"));
61-
} else {
62-
// Some other extern file (e.g. a `.so`). Forward unchanged.
63-
cmd.arg(path);
64-
}
65-
}
66-
6755
pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
6856
// Require a subcommand before any flags.
6957
// We cannot know which of those flags take arguments and which do not,
@@ -276,7 +264,7 @@ pub enum RustcPhase {
276264
Rustdoc,
277265
}
278266

279-
pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
267+
pub fn phase_rustc(args: impl Iterator<Item = String>, phase: RustcPhase) {
280268
/// Determines if we are being invoked (as rustc) to build a crate for
281269
/// the "target" architecture, in contrast to the "host" architecture.
282270
/// Host crates are for build scripts and proc macros and still need to
@@ -444,7 +432,6 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
444432
}
445433

446434
let mut cmd = miri();
447-
let mut emit_link_hack = false;
448435
// Arguments are treated very differently depending on whether this crate is
449436
// for interpretation by Miri, or for use by a build script / proc macro.
450437
if target_crate {
@@ -455,7 +442,7 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
455442
}
456443

457444
// Forward arguments, but patched.
458-
let emit_flag = "--emit";
445+
459446
// This hack helps bootstrap run standard library tests in Miri. The issue is as follows:
460447
// when running `cargo miri test` on libcore, cargo builds a local copy of core and makes it
461448
// a dependency of the integration test crate. This copy duplicates all the lang items, so
@@ -471,30 +458,7 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
471458
let replace_librs = env::var_os("MIRI_REPLACE_LIBRS_IF_NOT_TEST").is_some()
472459
&& !runnable_crate
473460
&& phase == RustcPhase::Build;
474-
while let Some(arg) = args.next() {
475-
// Patch `--emit`: remove "link" from "--emit" to make this a check-only build.
476-
if let Some(val) = arg.strip_prefix(emit_flag) {
477-
// Patch this argument. First, extract its value.
478-
let val =
479-
val.strip_prefix('=').expect("`cargo` should pass `--emit=X` as one argument");
480-
let mut val: Vec<_> = val.split(',').collect();
481-
// Now make sure "link" is not in there, but "metadata" is.
482-
if let Some(i) = val.iter().position(|&s| s == "link") {
483-
emit_link_hack = true;
484-
val.remove(i);
485-
if !val.contains(&"metadata") {
486-
val.push("metadata");
487-
}
488-
}
489-
cmd.arg(format!("{emit_flag}={}", val.join(",")));
490-
continue;
491-
}
492-
// Patch `--extern` filenames, since Cargo sometimes passes stub `.rlib` files:
493-
// https://github.com/rust-lang/miri/issues/1705
494-
if arg == "--extern" {
495-
forward_patched_extern_arg(&mut args, &mut cmd);
496-
continue;
497-
}
461+
for arg in args {
498462
// If the REPLACE_LIBRS hack is enabled and we are building a `lib.rs` file, and a
499463
// `lib.miri.rs` file exists, then build that instead.
500464
if replace_librs {
@@ -543,17 +507,6 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
543507
eprintln!("[cargo-miri rustc] target_crate={target_crate} runnable_crate={runnable_crate}");
544508
}
545509

546-
// Create a stub .rlib file if "link" was requested by cargo.
547-
// This is necessary to prevent cargo from doing rebuilds all the time.
548-
if emit_link_hack {
549-
for filename in out_filenames() {
550-
if verbose > 0 {
551-
eprintln!("[cargo-miri rustc] creating fake lib file at `{}`", filename.display());
552-
}
553-
File::create(filename).expect("failed to create fake lib file");
554-
}
555-
}
556-
557510
debug_cmd("[cargo-miri rustc]", verbose, &cmd);
558511
exec(cmd);
559512
}
@@ -624,17 +577,11 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
624577
cmd.arg("--sysroot").arg(env::var_os("MIRI_SYSROOT").unwrap());
625578
}
626579
// Forward rustc arguments.
627-
// We need to patch "--extern" filenames because we forced a check-only
628-
// build without cargo knowing about that: replace `.rlib` suffix by
629-
// `.rmeta`.
630-
// We also need to remove `--error-format` as cargo specifies that to be JSON,
580+
// We need to remove `--error-format` as cargo specifies that to be JSON,
631581
// but when we run here, cargo does not interpret the JSON any more. `--json`
632582
// then also needs to be dropped.
633-
let mut args = info.args.iter();
634-
while let Some(arg) = args.next() {
635-
if arg == "--extern" {
636-
forward_patched_extern_arg(&mut (&mut args).cloned(), &mut cmd);
637-
} else if let Some(suffix) = arg.strip_prefix("--error-format") {
583+
for arg in &info.args {
584+
if let Some(suffix) = arg.strip_prefix("--error-format") {
638585
assert!(suffix.starts_with('='));
639586
// Drop this argument.
640587
} else if let Some(suffix) = arg.strip_prefix("--json") {
@@ -668,23 +615,15 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
668615
}
669616
}
670617

671-
pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
618+
pub fn phase_rustdoc(args: impl Iterator<Item = String>) {
672619
let verbose = env::var("MIRI_VERBOSE")
673620
.map_or(0, |verbose| verbose.parse().expect("verbosity flag must be an integer"));
674621

675622
// phase_cargo_miri sets the RUSTDOC env var to ourselves, and puts a backup
676623
// of the old value into MIRI_ORIG_RUSTDOC. So that's what we have to invoke now.
677624
let rustdoc = env::var("MIRI_ORIG_RUSTDOC").unwrap_or("rustdoc".to_string());
678625
let mut cmd = Command::new(rustdoc);
679-
680-
while let Some(arg) = args.next() {
681-
if arg == "--extern" {
682-
// Patch --extern arguments to use *.rmeta files, since phase_cargo_rustc only creates stub *.rlib files.
683-
forward_patched_extern_arg(&mut args, &mut cmd);
684-
} else {
685-
cmd.arg(arg);
686-
}
687-
}
626+
cmd.args(args);
688627

689628
// Doctests of `proc-macro` crates (and their dependencies) are always built for the host,
690629
// so we are not able to run them in Miri.

cargo-miri/src/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub fn setup(
160160

161161
// Do the build.
162162
let status = SysrootBuilder::new(&sysroot_dir, target)
163-
.build_mode(BuildMode::Check)
163+
.build_mode(BuildMode::Build) // not a real build, since we use dummy codegen
164164
.rustc_version(rustc_version.clone())
165165
.sysroot_config(sysroot_config)
166166
.rustflags(rustflags)

cargo-miri/src/util.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ fn cargo_extra_flags() -> Vec<String> {
213213

214214
pub fn get_cargo_metadata() -> Metadata {
215215
// This will honor the `CARGO` env var the same way our `cargo()` does.
216-
MetadataCommand::new().no_deps().other_options(cargo_extra_flags()).exec().unwrap()
216+
MetadataCommand::new()
217+
.no_deps()
218+
.other_options(cargo_extra_flags())
219+
.exec()
220+
.unwrap_or_else(|err| show_error!("{}", err))
217221
}
218222

219223
/// Pulls all the crates in this workspace from the cargo metadata.

ci/ci.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ case $HOST_TARGET in
153153
BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator
154154
UNIX="hello panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
155155
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap random thread sync concurrency epoll eventfd
156-
TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC hello wasm
157156
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std
158157
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
159158
;;

genmc-sys/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ mod downloading {
2626
use super::GENMC_DOWNLOAD_PATH;
2727

2828
/// The GenMC repository the we get our commit from.
29-
pub(crate) const GENMC_GITHUB_URL: &str = "https://gitlab.inf.ethz.ch/public-plf/genmc.git";
29+
pub(crate) const GENMC_GITHUB_URL: &str = "https://github.com/MPI-SWS/genmc.git";
3030
/// The GenMC commit we depend on. It must be available on the specified GenMC repository.
31-
pub(crate) const GENMC_COMMIT: &str = "ce775ccd7866db820fa12ffca66463087a11dd96";
31+
pub(crate) const GENMC_COMMIT: &str = "d9527280bb99f1cef64326b1803ffd952e3880df";
3232

3333
/// Ensure that a local GenMC repo is present and set to the correct commit.
3434
/// Return the path of the GenMC repo and whether the checked out commit was changed.

genmc-sys/cpp/include/MiriInterface.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,27 +261,27 @@ namespace GenmcScalarExt {
261261
inline GenmcScalar uninit() {
262262
return GenmcScalar {
263263
.value = 0,
264-
.extra = 0,
264+
.provenance = 0,
265265
.is_init = false,
266266
};
267267
}
268268

269269
inline GenmcScalar from_sval(SVal sval) {
270270
return GenmcScalar {
271271
.value = sval.get(),
272-
.extra = sval.getExtra(),
272+
.provenance = sval.getProvenance(),
273273
.is_init = true,
274274
};
275275
}
276276

277277
inline SVal to_sval(GenmcScalar scalar) {
278278
ERROR_ON(!scalar.is_init, "Cannot convert an uninitialized `GenmcScalar` into an `SVal`\n");
279-
return SVal(scalar.value, scalar.extra);
279+
return SVal(scalar.value, scalar.provenance);
280280
}
281281

282282
inline std::optional<SVal> try_to_sval(GenmcScalar scalar) {
283283
if (scalar.is_init)
284-
return { SVal(scalar.value, scalar.extra) };
284+
return { SVal(scalar.value, scalar.provenance) };
285285
return std::nullopt;
286286
}
287287
} // namespace GenmcScalarExt

genmc-sys/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ pub fn create_genmc_driver_handle(
4545
}
4646

4747
impl GenmcScalar {
48-
pub const UNINIT: Self = Self { value: 0, extra: 0, is_init: false };
48+
pub const UNINIT: Self = Self { value: 0, provenance: 0, is_init: false };
4949

5050
pub const fn from_u64(value: u64) -> Self {
51-
Self { value, extra: 0, is_init: true }
51+
Self { value, provenance: 0, is_init: true }
5252
}
5353

5454
pub const fn has_provenance(&self) -> bool {
55-
self.extra != 0
55+
self.provenance != 0
5656
}
5757
}
5858

@@ -172,8 +172,9 @@ mod ffi {
172172
value: u64,
173173
/// This is zero for integer values. For pointers, this encodes the provenance by
174174
/// storing the base address of the allocation that this pointer belongs to.
175-
/// Operations on `SVal` in GenMC (e.g., `fetch_add`) preserve the `extra` of the left argument (`left.fetch_add(right, ...)`).
176-
extra: u64,
175+
/// Operations on `SVal` in GenMC (e.g., `fetch_add`) preserve the `provenance` of the left
176+
/// argument (`left.fetch_add(right, ...)`).
177+
provenance: u64,
177178
/// Indicates whether this value is initialized. If this is `false`, the other fields do not matter.
178179
/// (Ideally we'd use `std::optional` but CXX does not support that.)
179180
is_init: bool,

miri-script/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)