Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fc4056e
Constify `ManuallyDrop::take`
nxsaken Nov 9, 2025
264c6d4
Constify `mem::take`
nxsaken Nov 9, 2025
1d9be66
Add tracking issue number
nxsaken Nov 10, 2025
63f4b36
provide an error if an autodiff user does not set in their Cargo.toml
ZuseZ4 Nov 12, 2025
c8bae8c
add a test to verify a good error for enabling autodiff without lto
ZuseZ4 Nov 12, 2025
4996edc
add note to `lines` docs about empty str behavior
msmoiz Nov 13, 2025
e628b05
update language from "no lines" to "empty iterator"
msmoiz Nov 14, 2025
4fd0dc1
move `NonNull` into `minicore`
folkertdev Nov 16, 2025
96c6427
`abi/compatibility`: test some additional targets
folkertdev Nov 16, 2025
02770b3
remote-test-server: make it build for Motor OS
lasiotus Nov 14, 2025
64f0579
Run wasm32-wasip1 codegen tests in PR CI
saethlin Nov 15, 2025
c287f6e
compiletest: Avoid race condition in file deletion
jamie-osec Nov 16, 2025
7194c92
add larger test for `proc_macro` `FromStr` implementations
cyrgani Nov 4, 2025
70a0af3
Remove jsha from notifications for rustdoc HTML
jsha Nov 17, 2025
31902f3
Remove the "wasm32-bare" alias for `wasm32-unknown-unknown`
Zalathar Nov 17, 2025
2fbdc8a
Rollup merge of #148505 - cyrgani:pm-tests, r=madsmtm
Zalathar Nov 17, 2025
dd9b8e6
Rollup merge of #148752 - nxsaken:const_manually_drop_take, r=scottmcm
Zalathar Nov 17, 2025
6fe5c1d
Rollup merge of #148757 - nxsaken:const_mem_take, r=scottmcm
Zalathar Nov 17, 2025
e34ef24
Rollup merge of #148855 - ZuseZ4:autodiff-lto-error, r=bjorn3
Zalathar Nov 17, 2025
47585c9
Rollup merge of #148912 - msmoiz:main, r=scottmcm
Zalathar Nov 17, 2025
08093e7
Rollup merge of #148958 - saethlin:32bit-codegen-pr, r=kobzol
Zalathar Nov 17, 2025
b979e1e
Rollup merge of #148994 - folkertdev:abi-compatibility-cleanup, r=jie…
Zalathar Nov 17, 2025
6ce31bf
Rollup merge of #148999 - moturus:remote-test-server, r=jieyouxu
Zalathar Nov 17, 2025
8a04951
Rollup merge of #149004 - clubby789:compiletest-delete-safe, r=jieyouxu
Zalathar Nov 17, 2025
0bcf820
Rollup merge of #149008 - jsha:jsha-unwatch-doc-html, r=jieyouxu
Zalathar Nov 17, 2025
06304ef
Rollup merge of #149010 - Zalathar:wasm32-bare, r=jieyouxu
Zalathar Nov 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/messages.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
codegen_llvm_autodiff_without_enable = using the autodiff feature requires -Z autodiff=Enable
codegen_llvm_autodiff_without_lto = using the autodiff feature requires setting `lto="fat"` in your Cargo.toml
codegen_llvm_copy_bitcode = failed to copy bitcode to object file: {$err}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for ParseTargetMachineConfig<'_> {
}
}

#[derive(Diagnostic)]
#[diag(codegen_llvm_autodiff_without_lto)]
pub(crate) struct AutoDiffWithoutLto;

#[derive(Diagnostic)]
#[diag(codegen_llvm_autodiff_without_enable)]
pub(crate) struct AutoDiffWithoutEnable;
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::abi::FnAbiLlvmExt;
use crate::builder::Builder;
use crate::builder::autodiff::{adjust_activity_to_abi, generate_enzyme_call};
use crate::context::CodegenCx;
use crate::errors::AutoDiffWithoutEnable;
use crate::errors::{AutoDiffWithoutEnable, AutoDiffWithoutLto};
use crate::llvm::{self, Metadata, Type, Value};
use crate::type_of::LayoutLlvmExt;
use crate::va_arg::emit_va_arg;
Expand Down Expand Up @@ -1146,6 +1146,9 @@ fn codegen_autodiff<'ll, 'tcx>(
if !tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::Enable) {
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutEnable);
}
if tcx.sess.lto() != rustc_session::config::Lto::Fat {
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto);
}

let fn_args = instance.args;
let callee_ty = instance.ty(tcx, bx.typing_env());
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,6 @@ impl Session {

/// Calculates the flavor of LTO to use for this compilation.
pub fn lto(&self) -> config::Lto {
// Autodiff currently requires fat-lto to have access to the llvm-ir of all (indirectly) used functions and types.
// fat-lto is the easiest solution to this requirement, but quite expensive.
// FIXME(autodiff): Make autodiff also work with embed-bc instead of fat-lto.
// Don't apply fat-lto to proc-macro crates as they cannot use fat-lto without -Zdylib-lto
if self.opts.autodiff_enabled() && !self.opts.crate_types.contains(&CrateType::ProcMacro) {
return config::Lto::Fat;
}

// If our target has codegen requirements ignore the command line
if self.target.requires_lto {
return config::Lto::Fat;
Expand Down
14 changes: 3 additions & 11 deletions compiler/rustc_target/src/spec/base/motor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@ use crate::spec::{

pub(crate) fn opts() -> TargetOptions {
let pre_link_args = TargetOptions::link_args(
LinkerFlavor::Gnu(Cc::No, Lld::No),
&[
"-e",
"motor_start",
"--no-undefined",
"--error-unresolved-symbols",
"--no-undefined-version",
"-u",
"__rust_abort",
],
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
&["-e", "motor_start", "-u", "__rust_abort"],
);
TargetOptions {
os: Os::Motor,
Expand All @@ -23,7 +15,7 @@ pub(crate) fn opts() -> TargetOptions {
// We use "OS level" TLS (see thread/local.rs in stdlib).
has_thread_local: false,
frame_pointer: FramePointer::NonLeaf,
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::No),
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
main_needs_argc_argv: true,
panic_strategy: PanicStrategy::Abort,
pre_link_args,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::{
Arch, CodeModel, LinkSelfContainedDefault, LldFlavor, RelocModel, RelroLevel, Target, base,
Arch, CodeModel, LinkSelfContainedDefault, RelocModel, RelroLevel, Target, base,
};

pub(crate) fn target() -> Target {
Expand All @@ -15,7 +15,6 @@ pub(crate) fn target() -> Target {
base.relro_level = RelroLevel::Full;
base.static_position_independent_executables = true;
base.relocation_model = RelocModel::Pic;
base.lld_flavor_json = LldFlavor::Ld;
base.link_self_contained = LinkSelfContainedDefault::True;
base.dynamic_linking = false;
base.crt_static_default = true;
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/mem/manually_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ impl<T> ManuallyDrop<T> {
///
#[must_use = "if you don't need the value, you can use `ManuallyDrop::drop` instead"]
#[stable(feature = "manually_drop_take", since = "1.42.0")]
#[rustc_const_unstable(feature = "const_manually_drop_take", issue = "148773")]
#[inline]
pub unsafe fn take(slot: &mut ManuallyDrop<T>) -> T {
pub const unsafe fn take(slot: &mut ManuallyDrop<T>) -> T {
// SAFETY: we are reading from a reference, which is guaranteed
// to be valid for reads.
unsafe { ptr::read(&slot.value) }
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,8 @@ pub const fn swap<T>(x: &mut T, y: &mut T) {
/// ```
#[inline]
#[stable(feature = "mem_take", since = "1.40.0")]
pub fn take<T: Default>(dest: &mut T) -> T {
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
pub const fn take<T: [const] Default>(dest: &mut T) -> T {
replace(dest, T::default())
}

Expand Down
11 changes: 11 additions & 0 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,8 @@ impl str {
/// ending will return the same lines as an otherwise identical string
/// without a final line ending.
///
/// An empty string returns an empty iterator.
///
/// # Examples
///
/// Basic usage:
Expand Down Expand Up @@ -1281,6 +1283,15 @@ impl str {
///
/// assert_eq!(None, lines.next());
/// ```
///
/// An empty string returns an empty iterator:
///
/// ```
/// let text = "";
/// let mut lines = text.lines();
///
/// assert_eq!(lines.next(), None);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn lines(&self) -> Lines<'_> {
Expand Down
8 changes: 8 additions & 0 deletions src/ci/docker/host-x86_64/pr-check-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
mingw-w64 \
&& rm -rf /var/lib/apt/lists/*

RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.tar.gz | \
tar -xz
ENV WASI_SDK_PATH=/wasi-sdk-27.0-x86_64-linux

ENV RUST_CONFIGURE_ARGS="--set rust.validate-mir-opts=3"

COPY scripts/sccache.sh /scripts/
Expand All @@ -30,6 +34,10 @@ ENV SCRIPT \
python3 ../x.py check && \
python3 ../x.py clippy ci --stage 2 && \
python3 ../x.py test --stage 1 core alloc std test proc_macro && \
# Elsewhere, we run all tests for the host. A number of codegen tests are sensitive to the target pointer
# width, for example because they mention a usize. wasm32-wasip1 in test-various, so using it here can't make
# PR CI more strict than full CI.
python3 ../x.py test --stage 1 tests/codegen-llvm --target wasm32-wasip1 && \
python3 ../x.py test --stage 1 src/tools/compiletest && \
python3 ../x.py doc bootstrap --stage 1 && \
# Build both public and internal documentation.
Expand Down
1 change: 0 additions & 1 deletion src/doc/rustc-dev-guide/src/tests/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ Some examples of `X` in `ignore-X` or `only-X`:
- OS: `android`, `emscripten`, `freebsd`, `ios`, `linux`, `macos`, `windows`,
...
- Environment (fourth word of the target triple): `gnu`, `msvc`, `musl`
- WASM: `wasm32-bare` matches `wasm32-unknown-unknown`.
- Pointer width: `32bit`, `64bit`
- Endianness: `endian-big`
- Stage: `stage1`, `stage2`
Expand Down
8 changes: 0 additions & 8 deletions src/tools/compiletest/src/directives/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,6 @@ fn parse_cfg_name_directive<'a>(
message: "when the target family is {name}"
}

// `wasm32-bare` is an alias to refer to just wasm32-unknown-unknown
// (in contrast to `wasm32` which also matches non-bare targets)
condition! {
name: "wasm32-bare",
condition: config.target == "wasm32-unknown-unknown",
message: "when the target is WASM"
}

condition! {
name: "thumb",
condition: config.target.starts_with("thumb"),
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/directives/directive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-wasi",
"ignore-wasm",
"ignore-wasm32",
"ignore-wasm32-bare",
"ignore-wasm32-unknown-unknown",
"ignore-wasm64",
"ignore-watchos",
"ignore-windows",
Expand Down Expand Up @@ -240,7 +240,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-unix",
"only-visionos",
"only-wasm32",
"only-wasm32-bare",
"only-wasm32-unknown-unknown",
"only-wasm32-wasip1",
"only-watchos",
"only-windows",
Expand Down
4 changes: 0 additions & 4 deletions src/tools/compiletest/src/directives/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,18 +710,14 @@ fn wasm_special() {
let ignores = [
("wasm32-unknown-unknown", "emscripten", false),
("wasm32-unknown-unknown", "wasm32", true),
("wasm32-unknown-unknown", "wasm32-bare", true),
("wasm32-unknown-unknown", "wasm64", false),
("wasm32-unknown-emscripten", "emscripten", true),
("wasm32-unknown-emscripten", "wasm32", true),
("wasm32-unknown-emscripten", "wasm32-bare", false),
("wasm32-wasip1", "emscripten", false),
("wasm32-wasip1", "wasm32", true),
("wasm32-wasip1", "wasm32-bare", false),
("wasm32-wasip1", "wasi", true),
("wasm64-unknown-unknown", "emscripten", false),
("wasm64-unknown-unknown", "wasm32", false),
("wasm64-unknown-unknown", "wasm32-bare", false),
("wasm64-unknown-unknown", "wasm64", true),
];
for (target, pattern, ignore) in ignores {
Expand Down
9 changes: 4 additions & 5 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2766,12 +2766,11 @@ impl<'test> TestCx<'test> {
.map_err(|err| format!("failed to load expected output from `{}`: {}", path, err))
}

/// Attempts to delete a file, succeeding if the file does not exist.
fn delete_file(&self, file: &Utf8Path) {
if !file.exists() {
// Deleting a nonexistent file would error.
return;
}
if let Err(e) = fs::remove_file(file.as_std_path()) {
if let Err(e) = fs::remove_file(file.as_std_path())
&& e.kind() != io::ErrorKind::NotFound
{
self.fatal(&format!("failed to delete `{}`: {}", file, e,));
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/tools/remote-test-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
//! themselves having support libraries. All data over the TCP sockets is in a
//! basically custom format suiting our needs.

#[cfg(not(windows))]
#[cfg(all(not(windows), not(target_os = "motor")))]
use std::fs::Permissions;
use std::fs::{self, File};
use std::io::prelude::*;
use std::io::{self, BufReader};
use std::net::{SocketAddr, TcpListener, TcpStream};
#[cfg(not(windows))]
#[cfg(all(not(windows), not(target_os = "motor")))]
use std::os::unix::prelude::*;
use std::path::{Path, PathBuf};
use std::process::{Command, ExitStatus, Stdio};
Expand Down Expand Up @@ -325,15 +325,15 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf
]));
}

#[cfg(not(windows))]
#[cfg(all(not(windows), not(target_os = "motor")))]
fn get_status_code(status: &ExitStatus) -> (u8, i32) {
match status.code() {
Some(n) => (0, n),
None => (1, status.signal().unwrap()),
}
}

#[cfg(windows)]
#[cfg(any(windows, target_os = "motor"))]
fn get_status_code(status: &ExitStatus) -> (u8, i32) {
(0, status.code().unwrap())
}
Expand All @@ -359,11 +359,11 @@ fn recv<B: BufRead>(dir: &Path, io: &mut B) -> PathBuf {
dst
}

#[cfg(not(windows))]
#[cfg(all(not(windows), not(target_os = "motor")))]
fn set_permissions(path: &Path) {
t!(fs::set_permissions(&path, Permissions::from_mode(0o755)));
}
#[cfg(windows)]
#[cfg(any(windows, target_os = "motor"))]
fn set_permissions(_path: &Path) {}

fn my_copy(src: &mut dyn Read, which: u8, dst: &Mutex<dyn Write>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//@ ignore-apple slightly different policy on stack protection of arrays
//@ ignore-msvc stack check code uses different function names
//@ ignore-nvptx64 stack protector is not supported
//@ ignore-wasm32-bare
//@ ignore-wasm32-unknown-unknown
//@ [all] compile-flags: -Z stack-protector=all
//@ [strong] compile-flags: -Z stack-protector=strong
//@ [basic] compile-flags: -Z stack-protector=basic
Expand Down
18 changes: 18 additions & 0 deletions tests/auxiliary/minicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,24 @@ pub struct ManuallyDrop<T: PointeeSized> {
}
impl<T: Copy + PointeeSized> Copy for ManuallyDrop<T> {}

#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
pub struct NonNull<T: ?Sized> {
pointer: *const T,
}
impl<T: ?Sized> Copy for NonNull<T> {}

#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
pub struct NonZero<T>(T);

pub struct Unique<T: ?Sized> {
pub pointer: NonNull<T>,
pub _marker: PhantomData<T>,
}

#[lang = "unsafe_cell"]
#[repr(transparent)]
pub struct UnsafeCell<T: PointeeSized> {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/wasm-exceptions-nostd/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ only-wasm32-bare
//@ only-wasm32-unknown-unknown

use std::path::Path;

Expand Down
30 changes: 12 additions & 18 deletions tests/ui/abi/compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
//@ revisions: arm
//@[arm] compile-flags: --target arm-unknown-linux-gnueabi
//@[arm] needs-llvm-components: arm
//@ revisions: thumb
//@[thumb] compile-flags: --target thumbv8m.main-none-eabi
//@[thumb] needs-llvm-components: arm
//@ revisions: aarch64
//@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu
//@[aarch64] needs-llvm-components: aarch64
Expand All @@ -31,12 +34,21 @@
//@ revisions: sparc64
//@[sparc64] compile-flags: --target sparc64-unknown-linux-gnu
//@[sparc64] needs-llvm-components: sparc
//@ revisions: powerpc
//@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
//@[powerpc] needs-llvm-components: powerpc
//@ revisions: powerpc64
//@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
//@[powerpc64] needs-llvm-components: powerpc
//@ revisions: aix
//@[aix] compile-flags: --target powerpc64-ibm-aix
//@[aix] needs-llvm-components: powerpc
//@ revisions: riscv
//@[riscv] compile-flags: --target riscv64gc-unknown-linux-gnu
//@[riscv] needs-llvm-components: riscv
//@ revisions: loongarch32
//@[loongarch32] compile-flags: --target loongarch32-unknown-none
//@[loongarch32] needs-llvm-components: loongarch
//@ revisions: loongarch64
//@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu
//@[loongarch64] needs-llvm-components: loongarch
Expand Down Expand Up @@ -87,31 +99,13 @@ mod prelude {
fn clone(&self) -> Self;
}

#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
pub struct NonNull<T: ?Sized> {
pointer: *const T,
}
impl<T: ?Sized> Copy for NonNull<T> {}

#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
pub struct NonZero<T>(T);

// This just stands in for a non-trivial type.
pub struct Vec<T> {
ptr: NonNull<T>,
cap: usize,
len: usize,
}

pub struct Unique<T: ?Sized> {
pub pointer: NonNull<T>,
pub _marker: PhantomData<T>,
}

#[lang = "global_alloc_ty"]
pub struct Global;

Expand Down
4 changes: 4 additions & 0 deletions tests/ui/autodiff/no_lto_flag.no_lto.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: using the autodiff feature requires setting `lto="fat"` in your Cargo.toml

error: aborting due to 1 previous error

Loading
Loading