Skip to content

Rollup of 16 pull requests #136367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 38 commits into from
Closed
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8e22ec0
omit unused args warnings for intrinsics without body
vayunbiyani Jan 21, 2025
b20bc53
ci: fix explanation why LLVM download is disabled for windows-gnu
mati865 Nov 20, 2024
56c6ffb
Use +secure-plt for powerpc-unknown-linux-gnu{,spe}
taiki-e Jan 27, 2025
1565254
Fix off-by-one error causing driftsort to crash
uellenberg Jan 28, 2025
556010a
platform-support docs: fix x87 errata footnotes
RalfJung Jan 27, 2025
3899d14
fix broken release notes id
cyrgani Jan 29, 2025
c64038a
Use proper type when applying deref adjustment in const
compiler-errors Jan 30, 2025
139d6ba
set rustc dylib on manually constructed rustc command
onur-ozkan Jan 30, 2025
6fe68d0
add rustc_abi to control ABI decisions LLVM does not have flags for, …
RalfJung Jan 27, 2025
09f6848
run-make-support: add `-Csymbol-mangling-version` and `-Cprefer-dynam…
jieyouxu Jan 20, 2025
17e0fc6
run-make-support: collapse re-export
jieyouxu Jan 20, 2025
c15c970
run-make-support: add `is_windows_gnu` helper
jieyouxu Jan 20, 2025
0bc1b4f
run-make-support: add `object`-based symbol helpers
jieyouxu Jan 20, 2025
9734ebb
tests: port `symbol-mangling-hashed` to rmake.rs
jieyouxu Jan 20, 2025
4d42046
CompileTest: Add Directives to Ignore `arm-unknown-*` Tests
veera-sivarajan Jan 31, 2025
860476f
Update encode_utf16 to mention it is native endian
hkBst Jan 30, 2025
d98270b
miri: make float min/max non-deterministic
RalfJung Jan 31, 2025
209bb81
Add documentation for derive(CoercePointee)
Darksonn Jan 31, 2025
88260f4
bootstrap: only build `crt{begin,end}.o` when compiling to MUSL
japaric Jan 21, 2025
2c35bd0
`#[optimize(none)]` implies `#[inline(never)]`
clubby789 Jan 31, 2025
d8b176f
Move fulfillment error derivation into new module
compiler-errors Jan 22, 2025
304b3cf
Manually walk into WF obligations in BestObligation proof tree visitor
compiler-errors Jan 22, 2025
e4b65f2
Rollup merge of #133266 - mati865:windows-gnu-llvm-download, r=Kobzol
workingjubilee Jan 31, 2025
8eddcea
Rollup merge of #135768 - jieyouxu:migrate-symbol-mangling-hashed, r=…
workingjubilee Jan 31, 2025
3ce301e
Rollup merge of #135836 - ferrocene:ja-gh135782-build-crt-only-for-mu…
workingjubilee Jan 31, 2025
0b999bf
Rollup merge of #135840 - vayunbiyani:omit_intrinsic_unused_param_war…
workingjubilee Jan 31, 2025
9ec6ab8
Rollup merge of #135900 - compiler-errors:derive-wf, r=lcnr
workingjubilee Jan 31, 2025
c343781
Rollup merge of #136146 - RalfJung:x86-abi, r=workingjubilee
workingjubilee Jan 31, 2025
6f3f900
Rollup merge of #136154 - taiki-e:ppc-secure-plt, r=nikic
workingjubilee Jan 31, 2025
21184df
Rollup merge of #136163 - uellenberg:driftsort-off-by-one, r=Mark-Sim…
workingjubilee Jan 31, 2025
fe8ae5b
Rollup merge of #136266 - cyrgani:patch-1, r=Mark-Simulacrum
workingjubilee Jan 31, 2025
0bd90c4
Rollup merge of #136283 - hkBst:patch-31, r=workingjubilee
workingjubilee Jan 31, 2025
d82d0c2
Rollup merge of #136309 - onur-ozkan:133629, r=jieyouxu
workingjubilee Jan 31, 2025
63b329f
Rollup merge of #136314 - compiler-errors:const-deref-adj, r=fee1-dead
workingjubilee Jan 31, 2025
7964a88
Rollup merge of #136339 - veera-sivarajan:ignore-arm-unknown-headers,…
workingjubilee Jan 31, 2025
fe050d5
Rollup merge of #136348 - RalfJung:miri-float-min-max, r=oli-obk
workingjubilee Jan 31, 2025
12dc9f4
Rollup merge of #136351 - Darksonn:coerce-pointee-docs, r=compiler-er…
workingjubilee Jan 31, 2025
26a42c1
Rollup merge of #136358 - clubby789:opt-none-noinline, r=saethlin
workingjubilee Jan 31, 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
3 changes: 1 addition & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -16,8 +16,7 @@ Version 1.84.1 (2025-01-30)
Version 1.84.0 (2025-01-09)
==========================

<a id="
Language"></a>
<a id="1.84.0-Language"></a>

Language
--------
16 changes: 14 additions & 2 deletions compiler/rustc_const_eval/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -747,7 +747,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
{
let a: F = self.read_scalar(&args[0])?.to_float()?;
let b: F = self.read_scalar(&args[1])?.to_float()?;
let res = self.adjust_nan(a.min(b), &[a, b]);
let res = if a == b {
// They are definitely not NaN (those are never equal), but they could be `+0` and `-0`.
// Let the machine decide which one to return.
M::equal_float_min_max(self, a, b)
} else {
self.adjust_nan(a.min(b), &[a, b])
};
self.write_scalar(res, dest)?;
interp_ok(())
}
@@ -762,7 +768,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
{
let a: F = self.read_scalar(&args[0])?.to_float()?;
let b: F = self.read_scalar(&args[1])?.to_float()?;
let res = self.adjust_nan(a.max(b), &[a, b]);
let res = if a == b {
// They are definitely not NaN (those are never equal), but they could be `+0` and `-0`.
// Let the machine decide which one to return.
M::equal_float_min_max(self, a, b)
} else {
self.adjust_nan(a.max(b), &[a, b])
};
self.write_scalar(res, dest)?;
interp_ok(())
}
6 changes: 6 additions & 0 deletions compiler/rustc_const_eval/src/interpret/machine.rs
Original file line number Diff line number Diff line change
@@ -278,6 +278,12 @@ pub trait Machine<'tcx>: Sized {
F2::NAN
}

/// Determines the result of `min`/`max` on floats when the arguments are equal.
fn equal_float_min_max<F: Float>(_ecx: &InterpCx<'tcx, Self>, a: F, _b: F) -> F {
// By default, we pick the left argument.
a
}

/// Called before a basic block terminator is executed.
#[inline]
fn before_terminator(_ecx: &mut InterpCx<'tcx, Self>) -> InterpResult<'tcx> {
6 changes: 5 additions & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
@@ -253,6 +253,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return;
}

let mut expr_ty = self.typeck_results.borrow().expr_ty_adjusted(expr);

for a in &adj {
match a.kind {
Adjust::NeverToAny => {
@@ -266,7 +268,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None,
expr.span,
overloaded_deref.method_call(self.tcx),
self.tcx.mk_args(&[a.target.into()]),
self.tcx.mk_args(&[expr_ty.into()]),
);
}
Adjust::Deref(None) => {
@@ -283,6 +285,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// No effects to enforce here.
}
}

expr_ty = a.target;
}

let autoborrow_mut = adj.iter().any(|adj| {
6 changes: 5 additions & 1 deletion compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ use std::iter;
use std::ops::{Range, RangeFrom};

use rustc_abi::{ExternAbi, FieldIdx};
use rustc_attr_parsing::InlineAttr;
use rustc_attr_parsing::{InlineAttr, OptimizeAttr};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_index::Idx;
@@ -770,6 +770,10 @@ fn check_codegen_attributes<'tcx, I: Inliner<'tcx>>(
return Err("never inline attribute");
}

if let OptimizeAttr::DoNotOptimize = callee_attrs.optimize {
return Err("has DoNotOptimize attribute");
}

// Reachability pass defines which functions are eligible for inlining. Generally inlining
// other functions is incorrect because they could reference symbols that aren't exported.
let is_generic = callsite.callee.args.non_erasable_generics().next().is_some();
8 changes: 8 additions & 0 deletions compiler/rustc_passes/src/liveness.rs
Original file line number Diff line number Diff line change
@@ -1522,6 +1522,14 @@ impl<'tcx> Liveness<'_, 'tcx> {
}

fn warn_about_unused_args(&self, body: &hir::Body<'_>, entry_ln: LiveNode) {
if let Some(intrinsic) =
self.ir.tcx.intrinsic(self.ir.tcx.hir().body_owner_def_id(body.id()))
{
if intrinsic.must_be_overridden {
return;
}
}

for p in body.params {
self.check_unused_vars_in_pat(
p.pat,
15 changes: 15 additions & 0 deletions compiler/rustc_target/src/spec/json.rs
Original file line number Diff line number Diff line change
@@ -128,6 +128,19 @@ impl Target {
Some(Ok(()))
})).unwrap_or(Ok(()))
} );
($key_name:ident, RustcAbi) => ( {
let name = (stringify!($key_name)).replace("_", "-");
obj.remove(&name).and_then(|o| o.as_str().and_then(|s| {
match s.parse::<super::RustcAbi>() {
Ok(rustc_abi) => base.$key_name = Some(rustc_abi),
_ => return Some(Err(format!(
"'{s}' is not a valid value for rustc-abi. \
Use 'x86-softfloat' or leave the field unset."
))),
}
Some(Ok(()))
})).unwrap_or(Ok(()))
} );
($key_name:ident, RelocModel) => ( {
let name = (stringify!($key_name)).replace("_", "-");
obj.remove(&name).and_then(|o| o.as_str().and_then(|s| {
@@ -612,6 +625,7 @@ impl Target {
key!(llvm_mcount_intrinsic, optional);
key!(llvm_abiname);
key!(llvm_floatabi, FloatAbi)?;
key!(rustc_abi, RustcAbi)?;
key!(relax_elf_relocations, bool);
key!(llvm_args, list);
key!(use_ctors_section, bool);
@@ -788,6 +802,7 @@ impl ToJson for Target {
target_option_val!(llvm_mcount_intrinsic);
target_option_val!(llvm_abiname);
target_option_val!(llvm_floatabi);
target_option_val!(rustc_abi);
target_option_val!(relax_elf_relocations);
target_option_val!(llvm_args);
target_option_val!(use_ctors_section);
49 changes: 45 additions & 4 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
@@ -1114,6 +1114,33 @@ impl ToJson for FloatAbi {
}
}

/// The Rustc-specific variant of the ABI used for this target.
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
pub enum RustcAbi {
/// On x86-32/64 only: do not use any FPU or SIMD registers for the ABI.
X86Softfloat,
}

impl FromStr for RustcAbi {
type Err = ();

fn from_str(s: &str) -> Result<RustcAbi, ()> {
Ok(match s {
"x86-softfloat" => RustcAbi::X86Softfloat,
_ => return Err(()),
})
}
}

impl ToJson for RustcAbi {
fn to_json(&self) -> Json {
match *self {
RustcAbi::X86Softfloat => "x86-softfloat",
}
.to_json()
}
}

#[derive(Clone, Copy, PartialEq, Hash, Debug)]
pub enum TlsModel {
GeneralDynamic,
@@ -2505,6 +2532,12 @@ pub struct TargetOptions {
/// If not provided, LLVM will infer the float ABI from the target triple (`llvm_target`).
pub llvm_floatabi: Option<FloatAbi>,

/// Picks a specific ABI for this target. This is *not* just for "Rust" ABI functions,
/// it can also affect "C" ABI functions; the point is that this flag is interpreted by
/// rustc and not forwarded to LLVM.
/// So far, this is only used on x86.
pub rustc_abi: Option<RustcAbi>,

/// Whether or not RelaxElfRelocation flag will be passed to the linker
pub relax_elf_relocations: bool,

@@ -2664,10 +2697,6 @@ impl TargetOptions {
.collect();
}
}

pub(crate) fn has_feature(&self, search_feature: &str) -> bool {
self.features.split(',').any(|f| f.strip_prefix('+').is_some_and(|f| f == search_feature))
}
}

impl Default for TargetOptions {
@@ -2774,6 +2803,7 @@ impl Default for TargetOptions {
llvm_mcount_intrinsic: None,
llvm_abiname: "".into(),
llvm_floatabi: None,
rustc_abi: None,
relax_elf_relocations: false,
llvm_args: cvs![],
use_ctors_section: false,
@@ -3240,6 +3270,17 @@ impl Target {
_ => {}
}

// Check consistency of Rust ABI declaration.
if let Some(rust_abi) = self.rustc_abi {
match rust_abi {
RustcAbi::X86Softfloat => check_matches!(
&*self.arch,
"x86" | "x86_64",
"`x86-softfloat` ABI is only valid for x86 targets"
),
}
}

// Check that the given target-features string makes some basic sense.
if !self.features.is_empty() {
let mut features_enabled = FxHashSet::default();
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
// The cdecl ABI is used. It differs from the stdcall or fastcall ABI.
// "i686-unknown-windows" is used to get the minimal subset of windows-specific features.

use crate::spec::{Target, base};
use crate::spec::{RustcAbi, Target, base};

pub(crate) fn target() -> Target {
let mut base = base::uefi_msvc::opts();
@@ -22,6 +22,7 @@ pub(crate) fn target() -> Target {
// If you initialize FP units yourself, you can override these flags with custom linker
// arguments, thus giving you access to full MMX/SSE acceleration.
base.features = "-mmx,-sse,+soft-float".into();
base.rustc_abi = Some(RustcAbi::X86Softfloat);

// Use -GNU here, because of the reason below:
// Background and Problem:
Original file line number Diff line number Diff line change
@@ -18,6 +18,11 @@ pub(crate) fn target() -> Target {
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
options: TargetOptions {
endian: Endian::Big,
features: "+secure-plt".into(),
mcount: "_mcount".into(),
..base
},
}
}
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
abi: "spe".into(),
endian: Endian::Big,
features: "+secure-plt".into(),
mcount: "_mcount".into(),
..base
},
5 changes: 3 additions & 2 deletions compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
// features.

use crate::spec::{
Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelroLevel, SanitizerSet, StackProbeType,
Target, TargetOptions,
Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelroLevel, RustcAbi, SanitizerSet,
StackProbeType, Target, TargetOptions,
};

pub(crate) fn target() -> Target {
@@ -20,6 +20,7 @@ pub(crate) fn target() -> Target {
relro_level: RelroLevel::Full,
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
rustc_abi: Some(RustcAbi::X86Softfloat),
features: "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2,+soft-float".into(),
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
disable_redzone: true,
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
// LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features.

use crate::abi::call::Conv;
use crate::spec::{Target, base};
use crate::spec::{RustcAbi, Target, base};

pub(crate) fn target() -> Target {
let mut base = base::uefi_msvc::opts();
@@ -26,6 +26,7 @@ pub(crate) fn target() -> Target {
// If you initialize FP units yourself, you can override these flags with custom linker
// arguments, thus giving you access to full MMX/SSE acceleration.
base.features = "-mmx,-sse,+soft-float".into();
base.rustc_abi = Some(RustcAbi::X86Softfloat);

Target {
llvm_target: "x86_64-unknown-windows".into(),
52 changes: 36 additions & 16 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_span::{Symbol, sym};

use crate::spec::{FloatAbi, Target};
use crate::spec::{FloatAbi, RustcAbi, Target};

/// Features that control behaviour of rustc, rather than the codegen.
/// These exist globally and are not in the target-specific lists below.
@@ -422,7 +422,9 @@ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("sha512", Unstable(sym::sha512_sm_x86), &["avx2"]),
("sm3", Unstable(sym::sha512_sm_x86), &["avx"]),
("sm4", Unstable(sym::sha512_sm_x86), &["avx2"]),
("soft-float", Stability::Forbidden { reason: "unsound because it changes float ABI" }, &[]),
// This cannot actually be toggled, the ABI always fixes it, so it'd make little sense to
// stabilize. It must be in this list for the ABI check to be able to use it.
("soft-float", Stability::Unstable(sym::x87_target_feature), &[]),
("sse", Stable, &[]),
("sse2", Stable, &["sse"]),
("sse3", Stable, &["sse2"]),
@@ -773,23 +775,41 @@ impl Target {
// questions "which ABI is used".
match &*self.arch {
"x86" => {
// We support 2 ABIs, hardfloat (default) and softfloat.
// x86 has no sane ABI indicator so we have to use the target feature.
if self.has_feature("soft-float") {
NOTHING
} else {
// Hardfloat ABI. x87 must be enabled.
FeatureConstraints { required: &["x87"], incompatible: &[] }
// We use our own ABI indicator here; LLVM does not have anything native.
// Every case should require or forbid `soft-float`!
match self.rustc_abi {
None => {
// Default hardfloat ABI.
// x87 must be enabled, soft-float must be disabled.
FeatureConstraints { required: &["x87"], incompatible: &["soft-float"] }
}
Some(RustcAbi::X86Softfloat) => {
// Softfloat ABI, requires corresponding target feature. That feature trumps
// `x87` and all other FPU features so those do not matter.
// Note that this one requirement is the entire implementation of the ABI!
// LLVM handles the rest.
FeatureConstraints { required: &["soft-float"], incompatible: &[] }
}
}
}
"x86_64" => {
// We support 2 ABIs, hardfloat (default) and softfloat.
// x86 has no sane ABI indicator so we have to use the target feature.
if self.has_feature("soft-float") {
NOTHING
} else {
// Hardfloat ABI. x87 and SSE2 must be enabled.
FeatureConstraints { required: &["x87", "sse2"], incompatible: &[] }
// We use our own ABI indicator here; LLVM does not have anything native.
// Every case should require or forbid `soft-float`!
match self.rustc_abi {
None => {
// Default hardfloat ABI. On x86-64, this always includes SSE2.
FeatureConstraints {
required: &["x87", "sse2"],
incompatible: &["soft-float"],
}
}
Some(RustcAbi::X86Softfloat) => {
// Softfloat ABI, requires corresponding target feature. That feature trumps
// `x87` and all other FPU features so those do not matter.
// Note that this one requirement is the entire implementation of the ABI!
// LLVM handles the rest.
FeatureConstraints { required: &["soft-float"], incompatible: &[] }
}
}
}
"arm" => {
Loading