Skip to content

Commit b53da99

Browse files
committed
Auto merge of #150190 - matthiaskrgr:rollup-tjdmcar, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #146747 (rustc_codegen_llvm: Tidying of `update_target_reliable_float_cfg`) - #148499 (Nvptx: Use llbc as default linker) - #148991 (miri genmc: fix exit() handling) - #150172 (Handle remapped paths correctly when generating "Source" links) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d0835ad + 6c0e803 commit b53da99

File tree

19 files changed

+203
-38
lines changed

19 files changed

+203
-38
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -364,25 +364,25 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
364364
let target_abi = &sess.target.options.abi;
365365
let target_pointer_width = sess.target.pointer_width;
366366
let version = get_version();
367-
let lt_20_1_1 = version < (20, 1, 1);
368-
let lt_21_0_0 = version < (21, 0, 0);
367+
let (major, _, _) = version;
369368

370369
cfg.has_reliable_f16 = match (target_arch, target_os) {
371-
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (fixed in llvm20)
370+
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (fixed in LLVM 20.1.1)
372371
(Arch::AArch64, _)
373-
if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 =>
372+
if !cfg.target_features.iter().any(|f| f.as_str() == "neon")
373+
&& version < (20, 1, 1) =>
374374
{
375375
false
376376
}
377377
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
378378
(Arch::Arm64EC, _) => false,
379379
// Selection failure <https://github.com/llvm/llvm-project/issues/50374> (fixed in llvm21)
380-
(Arch::S390x, _) if lt_21_0_0 => false,
380+
(Arch::S390x, _) if major < 21 => false,
381381
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
382382
(Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false,
383383
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
384384
(Arch::CSky, _) => false,
385-
(Arch::Hexagon, _) if lt_21_0_0 => false, // (fixed in llvm21)
385+
(Arch::Hexagon, _) if major < 21 => false, // (fixed in llvm21)
386386
(Arch::PowerPC | Arch::PowerPC64, _) => false,
387387
(Arch::Sparc | Arch::Sparc64, _) => false,
388388
(Arch::Wasm32 | Arch::Wasm64, _) => false,
@@ -393,23 +393,23 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
393393
};
394394

395395
cfg.has_reliable_f128 = match (target_arch, target_os) {
396+
// Unsupported https://github.com/llvm/llvm-project/issues/121122
397+
(Arch::AmdGpu, _) => false,
396398
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
397399
(Arch::Arm64EC, _) => false,
398-
// Selection bug <https://github.com/llvm/llvm-project/issues/96432> (fixed in llvm20)
399-
(Arch::Mips64 | Arch::Mips64r6, _) if lt_20_1_1 => false,
400+
// Selection bug <https://github.com/llvm/llvm-project/issues/96432> (fixed in LLVM 20.1.0)
401+
(Arch::Mips64 | Arch::Mips64r6, _) if version < (20, 1, 0) => false,
400402
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>. This issue is closed
401403
// but basic math still does not work.
402404
(Arch::Nvptx64, _) => false,
403-
// Unsupported https://github.com/llvm/llvm-project/issues/121122
404-
(Arch::AmdGpu, _) => false,
405405
// ABI bugs <https://github.com/rust-lang/rust/issues/125109> et al. (full
406406
// list at <https://github.com/rust-lang/rust/issues/116909>)
407407
(Arch::PowerPC | Arch::PowerPC64, _) => false,
408408
// ABI unsupported <https://github.com/llvm/llvm-project/issues/41838>
409409
(Arch::Sparc, _) => false,
410410
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
411411
// not fail if our compiler-builtins is linked. (fixed in llvm21)
412-
(Arch::X86, _) if lt_21_0_0 => false,
412+
(Arch::X86, _) if major < 21 => false,
413413
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
414414
(Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false,
415415
// There are no known problems on other platforms, so the only requirement is that symbols

compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
561561
if fn_abi.can_unwind { unwind } else { mir::UnwindAction::Unreachable },
562562
)?;
563563
// Sanity-check that `eval_fn_call` either pushed a new frame or
564-
// did a jump to another block.
565-
if self.frame_idx() == old_stack && self.frame().loc == old_loc {
564+
// did a jump to another block. We disable the sanity check for functions that
565+
// can't return, since Miri sometimes does have to keep the location the same
566+
// for those (which is fine since execution will continue on a different thread).
567+
if target.is_some() && self.frame_idx() == old_stack && self.frame().loc == old_loc
568+
{
566569
span_bug!(terminator.source_info.span, "evaluating this call made no progress");
567570
}
568571
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,11 +2956,6 @@ impl Target {
29562956
matches!(self.linker_flavor, LinkerFlavor::Bpf),
29572957
"`linker_flavor` must be `bpf` if and only if `arch` is `bpf`"
29582958
);
2959-
check_eq!(
2960-
self.arch == Arch::Nvptx64,
2961-
matches!(self.linker_flavor, LinkerFlavor::Ptx),
2962-
"`linker_flavor` must be `ptc` if and only if `arch` is `nvptx64`"
2963-
);
29642959

29652960
for args in [
29662961
&self.pre_link_args,

compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ pub(crate) fn target() -> Target {
1919
options: TargetOptions {
2020
os: Os::Cuda,
2121
vendor: "nvidia".into(),
22-
linker_flavor: LinkerFlavor::Ptx,
23-
// The linker can be installed from `crates.io`.
24-
linker: Some("rust-ptx-linker".into()),
22+
linker_flavor: LinkerFlavor::Llbc,
2523

2624
// With `ptx-linker` approach, it can be later overridden via link flags.
2725
cpu: "sm_30".into(),

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ impl Step for Miri {
722722
// miri tests need to know about the stage sysroot
723723
cargo.env("MIRI_SYSROOT", &miri_sysroot);
724724
cargo.env("MIRI_HOST_SYSROOT", &host_sysroot);
725-
cargo.env("MIRI", &miri.tool_path);
726725

727726
// Set the target.
728727
cargo.env("MIRI_TEST_TARGET", target.rustc_target_arg());

src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ platform.
1212

1313
## Requirements
1414

15-
This target is `no_std` and will typically be built with crate-type `cdylib` and `-C linker-flavor=llbc`, which generates PTX.
15+
This target is `no_std`, and uses the `llvm-bitcode-linker` by default. For PTX output, build with crate-type `cdylib`.
1616
The necessary components for this workflow are:
1717

1818
- `rustup toolchain add nightly`
@@ -38,7 +38,7 @@ While the compiler accepts `#[target_feature(enable = "ptx80", enable = "sm_89")
3838
A `no_std` crate containing one or more functions with `extern "ptx-kernel"` can be compiled to PTX using a command like the following.
3939

4040
```console
41-
$ RUSTFLAGS='-Ctarget-cpu=sm_89' cargo +nightly rustc --target=nvptx64-nvidia-cuda -Zbuild-std=core --crate-type=cdylib -- -Clinker-flavor=llbc -Zunstable-options
41+
$ RUSTFLAGS='-Ctarget-cpu=sm_89' cargo +nightly rustc --target=nvptx64-nvidia-cuda -Zbuild-std=core --crate-type=cdylib
4242
```
4343

4444
Intrinsics in `core::arch::nvptx` may use `#[cfg(target_feature = "...")]`, thus it's necessary to use `-Zbuild-std=core` with appropriate `RUSTFLAGS`. The following components are needed for this workflow:

src/librustdoc/html/render/context.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_hir::def_id::{DefIdMap, LOCAL_CRATE};
1414
use rustc_middle::ty::TyCtxt;
1515
use rustc_session::Session;
1616
use rustc_span::edition::Edition;
17-
use rustc_span::{BytePos, FileName, Symbol};
17+
use rustc_span::{BytePos, FileName, RemapPathScopeComponents, Symbol};
1818
use tracing::info;
1919

2020
use super::print_item::{full_path, print_item, print_item_path};
@@ -365,7 +365,10 @@ impl<'tcx> Context<'tcx> {
365365

366366
// We can safely ignore synthetic `SourceFile`s.
367367
let file = match span.filename(self.sess()) {
368-
FileName::Real(ref path) => path.local_path()?.to_path_buf(),
368+
FileName::Real(ref path) => path
369+
.local_path()
370+
.unwrap_or(path.path(RemapPathScopeComponents::MACRO))
371+
.to_path_buf(),
369372
_ => return None,
370373
};
371374
let file = &file;
@@ -499,10 +502,12 @@ impl<'tcx> Context<'tcx> {
499502
} = options;
500503

501504
let src_root = match krate.src(tcx) {
502-
FileName::Real(ref p) => match p.local_path().map(|p| p.parent()).flatten() {
503-
Some(p) => p.to_path_buf(),
504-
None => PathBuf::new(),
505-
},
505+
FileName::Real(ref p) => {
506+
match p.local_path().unwrap_or(p.path(RemapPathScopeComponents::MACRO)).parent() {
507+
Some(p) => p.to_path_buf(),
508+
None => PathBuf::new(),
509+
}
510+
}
506511
_ => PathBuf::new(),
507512
};
508513
// If user passed in `--playground-url` arg, we fill in crate name here

src/tools/miri/src/shims/foreign_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
538538
code,
539539
crate::concurrency::ExitType::ExitCalled,
540540
)?;
541-
todo!(); // FIXME(genmc): Add a way to return here that is allowed to not do progress (can't use existing EmulateItemResult variants).
541+
return interp_ok(EmulateItemResult::AlreadyJumped);
542542
}
543543
throw_machine_stop!(TerminationInfo::Exit { code, leak_check: false });
544544
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ compile-flags: -Zmiri-genmc -Zmiri-disable-stacked-borrows
2+
3+
fn main() {
4+
std::thread::spawn(|| {
5+
unsafe { std::hint::unreachable_unchecked() }; //~ERROR: entering unreachable code
6+
});
7+
// If we exit immediately, we might entirely miss the UB in the other thread.
8+
std::process::exit(0);
9+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
Running GenMC Verification...
2+
warning: GenMC currently does not model spurious failures of `compare_exchange_weak`. Miri with GenMC might miss bugs related to spurious failures.
3+
--> RUSTLIB/std/src/thread/mod.rs:LL:CC
4+
|
5+
LL | match COUNTER.compare_exchange_weak(last, id, Ordering::Relaxed, Ordering::Relaxed) {
6+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GenMC might miss possible behaviors of this code
7+
|
8+
= note: BACKTRACE:
9+
= note: inside `std::thread::ThreadId::new` at RUSTLIB/std/src/thread/mod.rs:LL:CC
10+
= note: inside closure at RUSTLIB/std/src/thread/current.rs:LL:CC
11+
= note: inside `std::thread::current::id::get_or_init` at RUSTLIB/std/src/thread/current.rs:LL:CC
12+
= note: inside `std::thread::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
13+
= note: inside `std::rt::init` at RUSTLIB/std/src/rt.rs:LL:CC
14+
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
15+
= note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC
16+
= note: inside `std::panicking::catch_unwind::<isize, {closure@std::rt::lang_start_internal::{closure#0}}>` at RUSTLIB/std/src/panicking.rs:LL:CC
17+
= note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC
18+
= note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC
19+
= note: inside `std::rt::lang_start::<()>` at RUSTLIB/std/src/rt.rs:LL:CC
20+
21+
warning: GenMC currently does not model the failure ordering for `compare_exchange`. Due to success ordering 'Acquire', the failure ordering 'Relaxed' is treated like 'Acquire'. Miri with GenMC might miss bugs related to this memory access.
22+
--> RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC
23+
|
24+
LL | || self
25+
| ________________^
26+
LL | | .state
27+
LL | | .compare_exchange_weak(state, state + READ_LOCKED, Acquire, Relaxed)
28+
| |____________________________________________________________________________________^ GenMC might miss possible behaviors of this code
29+
|
30+
= note: BACKTRACE:
31+
= note: inside `std::sys::sync::PLATFORM::futex::RwLock::read` at RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC
32+
= note: inside `std::sync::RwLock::<()>::read` at RUSTLIB/std/src/sync/poison/rwlock.rs:LL:CC
33+
= note: inside `std::sys::env::PLATFORM::env_read_lock` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC
34+
= note: inside closure at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC
35+
= note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr_stack::<std::option::Option<std::ffi::OsString>>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC
36+
= note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr::<std::option::Option<std::ffi::OsString>>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC
37+
= note: inside `std::sys::env::PLATFORM::getenv` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC
38+
= note: inside `std::env::_var_os` at RUSTLIB/std/src/env.rs:LL:CC
39+
= note: inside `std::env::var_os::<&str>` at RUSTLIB/std/src/env.rs:LL:CC
40+
= note: inside closure at RUSTLIB/std/src/thread/mod.rs:LL:CC
41+
note: inside `main`
42+
--> tests/genmc/fail/shims/exit.rs:LL:CC
43+
|
44+
LL | / std::thread::spawn(|| {
45+
LL | | unsafe { std::hint::unreachable_unchecked() };
46+
LL | | });
47+
| |______^
48+
49+
warning: GenMC currently does not model spurious failures of `compare_exchange_weak`. Miri with GenMC might miss bugs related to spurious failures.
50+
--> RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC
51+
|
52+
LL | || self
53+
| ________________^
54+
LL | | .state
55+
LL | | .compare_exchange_weak(state, state + READ_LOCKED, Acquire, Relaxed)
56+
| |____________________________________________________________________________________^ GenMC might miss possible behaviors of this code
57+
|
58+
= note: BACKTRACE:
59+
= note: inside `std::sys::sync::PLATFORM::futex::RwLock::read` at RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC
60+
= note: inside `std::sync::RwLock::<()>::read` at RUSTLIB/std/src/sync/poison/rwlock.rs:LL:CC
61+
= note: inside `std::sys::env::PLATFORM::env_read_lock` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC
62+
= note: inside closure at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC
63+
= note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr_stack::<std::option::Option<std::ffi::OsString>>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC
64+
= note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr::<std::option::Option<std::ffi::OsString>>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC
65+
= note: inside `std::sys::env::PLATFORM::getenv` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC
66+
= note: inside `std::env::_var_os` at RUSTLIB/std/src/env.rs:LL:CC
67+
= note: inside `std::env::var_os::<&str>` at RUSTLIB/std/src/env.rs:LL:CC
68+
= note: inside closure at RUSTLIB/std/src/thread/mod.rs:LL:CC
69+
note: inside `main`
70+
--> tests/genmc/fail/shims/exit.rs:LL:CC
71+
|
72+
LL | / std::thread::spawn(|| {
73+
LL | | unsafe { std::hint::unreachable_unchecked() };
74+
LL | | });
75+
| |______^
76+
77+
warning: GenMC currently does not model spurious failures of `compare_exchange_weak`. Miri with GenMC might miss bugs related to spurious failures.
78+
--> RUSTLIB/std/src/rt.rs:LL:CC
79+
|
80+
LL | / CLEANUP.call_once(|| unsafe {
81+
LL | | // Flush stdout and disable buffering.
82+
LL | | crate::io::cleanup();
83+
... |
84+
LL | | });
85+
| |______^ GenMC might miss possible behaviors of this code
86+
|
87+
= note: BACKTRACE:
88+
= note: inside `std::rt::cleanup` at RUSTLIB/std/src/rt.rs:LL:CC
89+
= note: inside `std::process::exit` at RUSTLIB/std/src/process.rs:LL:CC
90+
note: inside `main`
91+
--> tests/genmc/fail/shims/exit.rs:LL:CC
92+
|
93+
LL | std::process::exit(0);
94+
| ^^^^^^^^^^^^^^^^^^^^^
95+
96+
warning: GenMC currently does not model the failure ordering for `compare_exchange`. Due to success ordering 'Acquire', the failure ordering 'Relaxed' is treated like 'Acquire'. Miri with GenMC might miss bugs related to this memory access.
97+
--> RUSTLIB/std/src/sys/exit_guard.rs:LL:CC
98+
|
99+
LL | match EXITING_THREAD_ID.compare_exchange(ptr::null_mut(), this_thread_id, Acquire, Relaxed) {
100+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GenMC might miss possible behaviors of this code
101+
|
102+
= note: BACKTRACE:
103+
= note: inside `std::sys::exit_guard::unique_thread_exit` at RUSTLIB/std/src/sys/exit_guard.rs:LL:CC
104+
= note: inside `std::sys::pal::PLATFORM::os::exit` at RUSTLIB/std/src/sys/pal/PLATFORM/os.rs:LL:CC
105+
= note: inside `std::process::exit` at RUSTLIB/std/src/process.rs:LL:CC
106+
note: inside `main`
107+
--> tests/genmc/fail/shims/exit.rs:LL:CC
108+
|
109+
LL | std::process::exit(0);
110+
| ^^^^^^^^^^^^^^^^^^^^^
111+
112+
error: Undefined Behavior: entering unreachable code
113+
--> tests/genmc/fail/shims/exit.rs:LL:CC
114+
|
115+
LL | unsafe { std::hint::unreachable_unchecked() };
116+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
117+
|
118+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
119+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
120+
121+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
122+
123+
note: add `-Zmiri-genmc-print-genmc-output` to MIRIFLAGS to see the detailed GenMC error report
124+
125+
error: aborting due to 1 previous error; 5 warnings emitted
126+

0 commit comments

Comments
 (0)