Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
329682d
rustdoc-json: move `target` to `json::conversions`
aDotInTheVoid Oct 17, 2025
b762676
Rename {i,u}N::*exact_div to *div_exact
nxsaken Nov 2, 2025
f590ae6
Rename {u,i}N::*exact_sh{l,r} to *sh{l,r}_exact
nxsaken Oct 16, 2025
8d0b5a9
Check the coexistence of stack-protector and safe-stack.
cezarbbb Nov 4, 2025
3086cb2
tests for linux.
cezarbbb Nov 4, 2025
8e59eb3
tests for windows 32bit.
cezarbbb Nov 4, 2025
670871a
tests for windows 64bit.
cezarbbb Nov 4, 2025
c49f4e1
test function name order correction
cezarbbb Nov 5, 2025
c9d0ee1
add -Cunsafe-allow-abi-mismatch=sanitizer to silence ABI mismatch error
cezarbbb Nov 6, 2025
6ed469c
IAT: Reinstate early bailout
fmease Nov 9, 2025
c5f2eb6
rustc_target: hide TargetOptions::vendor
tamird Nov 9, 2025
dc32847
Prepare `TestProps::load_from` for handler extraction
Zalathar Oct 20, 2025
a6580fb
Introduce a system of "directive handlers" indexed by directive name
Zalathar Oct 20, 2025
e00bc9c
Migrate all `TestProps` directive processing into smaller named handlers
Zalathar Oct 20, 2025
d82b84c
Remove the temporary line-break preservers
Zalathar Oct 21, 2025
33e9911
Add FIXMEs for some existing directive-handling concerns
Zalathar Nov 10, 2025
8e44fa9
Rollup merge of #147115 - cezarbbb:stable_ssp, r=SparrowLii
Zalathar Nov 10, 2025
a824017
Rollup merge of #147771 - nxsaken:div_shlr_exact, r=dtolnay
Zalathar Nov 10, 2025
bd3781f
Rollup merge of #147833 - aDotInTheVoid:rdj-shuffle, r=camelid
Zalathar Nov 10, 2025
32567a2
Rollup merge of #147955 - Zalathar:handlers, r=jieyouxu
Zalathar Nov 10, 2025
09dba77
Rollup merge of #148760 - tamird:avoid-vendor-logic, r=madsmtm
Zalathar Nov 10, 2025
ce83b99
Rollup merge of #148771 - fmease:iat-reinstate-early-elim, r=BoxyUwU
Zalathar Nov 10, 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
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,8 @@ pub(crate) fn codegen_call_with_unwind_action(
pub(crate) fn lib_call_arg_param(tcx: TyCtxt<'_>, ty: Type, is_signed: bool) -> AbiParam {
let param = AbiParam::new(ty);
if ty.is_int() && u64::from(ty.bits()) < tcx.data_layout.pointer_size().bits() {
match (&tcx.sess.target.arch, tcx.sess.target.vendor.as_ref()) {
(Arch::X86_64, _) | (Arch::AArch64, "apple") => match (ty, is_signed) {
match (&tcx.sess.target.arch, tcx.sess.target.is_like_darwin) {
(Arch::X86_64, _) | (Arch::AArch64, true) => match (ty, is_signed) {
(types::I8 | types::I16, true) => param.sext(),
(types::I8 | types::I16, false) => param.uext(),
_ => param,
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::prelude::*;

pub(crate) fn f16_to_f32(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
let (value, arg_ty) =
if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64 {
if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
(
fx.bcx.ins().bitcast(types::I16, MemFlags::new(), value),
lib_call_arg_param(fx.tcx, types::I16, false),
Expand All @@ -22,8 +22,7 @@ fn f16_to_f64(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
}

pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64
{
let ret_ty = if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
types::I16
} else {
types::F16
Expand All @@ -38,8 +37,7 @@ pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value
}

fn f64_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64
{
let ret_ty = if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
types::I16
} else {
types::F16
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ fn self_contained_components(
LinkSelfContainedDefault::InferredForMusl => sess.crt_static(Some(crate_type)),
LinkSelfContainedDefault::InferredForMingw => {
sess.host == sess.target
&& sess.target.vendor != "uwp"
&& sess.target.abi != "uwp"
&& detect_self_contained_mingw(sess, linker)
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub(crate) fn get_linker<'a>(
// To comply with the Windows App Certification Kit,
// MSVC needs to link with the Store versions of the runtime libraries (vcruntime, msvcrt, etc).
let t = &sess.target;
if matches!(flavor, LinkerFlavor::Msvc(..)) && t.vendor == "uwp" {
if matches!(flavor, LinkerFlavor::Msvc(..)) && t.abi == "uwp" {
if let Some(ref tool) = msvc_tool {
let original_path = tool.path();
if let Some(root_lib_path) = original_path.ancestors().nth(4) {
Expand Down Expand Up @@ -134,7 +134,7 @@ pub(crate) fn get_linker<'a>(

// FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
// to the linker args construction.
assert!(cmd.get_args().is_empty() || sess.target.vendor == "uwp");
assert!(cmd.get_args().is_empty() || sess.target.abi == "uwp");
match flavor {
LinkerFlavor::Unix(Cc::No) if sess.target.os == "l4re" => {
Box::new(L4Bender::new(cmd, sess)) as Box<dyn Linker>
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub fn asm_const_to_str<'tcx>(
}

pub fn is_mingw_gnu_toolchain(target: &Target) -> bool {
target.vendor == "pc" && target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
}

pub fn i686_decorated_name(
Expand Down
18 changes: 13 additions & 5 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1487,11 +1487,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
match assoc_tag {
// Don't attempt to look up inherent associated types when the feature is not
// enabled. Theoretically it'd be fine to do so since we feature-gate their
// definition site. However, due to current limitations of the implementation
// (caused by us performing selection during HIR ty lowering instead of in the
// trait solver), IATs can lead to cycle errors (#108491) which mask the
// feature-gate error, needlessly confusing users who use IATs by accident
// (#113265).
// definition site. However, the current implementation of inherent associated
// items is somewhat brittle, so let's not run it by default.
ty::AssocTag::Type => return Ok(None),
ty::AssocTag::Const => {
// We also gate the mgca codepath for type-level uses of inherent consts
Expand Down Expand Up @@ -1520,9 +1517,18 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
})
.collect();

// At the moment, we actually bail out with a hard error if the selection of an inherent
// associated item fails (see below). This means we never consider trait associated items
// as potential fallback candidates (#142006). To temporarily mask that issue, let's not
// select at all if there are no early inherent candidates.
if candidates.is_empty() {
return Ok(None);
}

let (applicable_candidates, fulfillment_errors) =
self.select_inherent_assoc_candidates(span, self_ty, candidates.clone());

// FIXME(#142006): Don't eagerly error here, there might be applicable trait candidates.
let InherentAssocCandidate { impl_, assoc_item, scope: def_scope } =
match &applicable_candidates[..] {
&[] => Err(self.report_unresolved_inherent_assoc_item(
Expand All @@ -1543,6 +1549,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
)),
}?;

// FIXME(#142006): Don't eagerly validate here, there might be trait candidates that are
// accessible (visible and stable) contrary to the inherent candidate.
self.check_assoc_item(assoc_item, name, def_scope, block, span);

// FIXME(fmease): Currently creating throwaway `parent_args` to please
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn walk_native_lib_search_dirs<R>(
// FIXME: On AIX this also has the side-effect of making the list of library search paths
// non-empty, which is needed or the linker may decide to record the LIBPATH env, if
// defined, as the search path instead of appending the default search paths.
if sess.target.vendor == "fortanix"
if sess.target.abi == "fortanix"
|| sess.target.os == "linux"
|| sess.target.os == "fuchsia"
|| sess.target.is_like_aix
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_session/src/config/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
ins_none!(sym::target_thread_local);
}

ins_str!(sym::target_vendor, &sess.target.vendor);
ins_sym!(sym::target_vendor, sess.target.vendor_symbol());

// If the user wants a test runner, then add the test cfg.
if sess.is_test_crate() {
Expand Down Expand Up @@ -456,7 +456,7 @@ impl CheckCfg {
);
values_target_os.insert(Symbol::intern(&target.options.os));
values_target_pointer_width.insert(sym::integer(target.pointer_width));
values_target_vendor.insert(Symbol::intern(&target.options.vendor));
values_target_vendor.insert(target.vendor_symbol());
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(debug_closure_helpers))]
#![expect(internal_features)]
#![feature(iter_intersperse)]
#![feature(rustc_attrs)]
// tidy-alphabetical-end

use std::path::{Path, PathBuf};
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_target/src/spec/base/windows_uwp_msvc.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::spec::{LinkerFlavor, Lld, TargetOptions, base};

pub(crate) fn opts() -> TargetOptions {
let mut opts = base::windows_msvc::opts();
let mut opts =
TargetOptions { abi: "uwp".into(), vendor: "uwp".into(), ..base::windows_msvc::opts() };

opts.abi = "uwp".into();
opts.vendor = "uwp".into();
opts.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/APPCONTAINER", "mincore.lib"]);

opts
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ impl ToJson for Target {
($attr:ident) => {{ target_option_val!($attr, (stringify!($attr)).replace("_", "-")) }};
($attr:ident, $json_name:expr) => {{
let name = $json_name;
#[allow(rustc::bad_opt_access)]
if default.$attr != target.$attr {
d.insert(name.into(), target.$attr.to_json());
}
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2045,6 +2045,7 @@ type StaticCow<T> = Cow<'static, T>;
/// construction, all its fields logically belong to `Target` and available from `Target`
/// through `Deref` impls.
#[derive(PartialEq, Clone, Debug)]
#[rustc_lint_opt_ty]
pub struct TargetOptions {
/// Used as the `target_endian` `cfg` variable. Defaults to little endian.
pub endian: Endian,
Expand All @@ -2063,7 +2064,10 @@ pub struct TargetOptions {
/// However, parts of the backend do check this field for specific values to enable special behavior.
pub abi: StaticCow<str>,
/// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown".
pub vendor: StaticCow<str>,
#[rustc_lint_opt_deny_field_access(
"use `Target::is_like_*` instead of this field; see https://github.com/rust-lang/rust/issues/100343 for rationale"
)]
vendor: StaticCow<str>,

/// Linker to invoke
pub linker: Option<StaticCow<str>>,
Expand Down Expand Up @@ -3323,6 +3327,10 @@ impl Target {
Align::MAX
}
}

pub fn vendor_symbol(&self) -> Symbol {
Symbol::intern(&self.vendor)
}
}

/// Either a target tuple string or a path to a JSON file.
Expand Down
19 changes: 11 additions & 8 deletions compiler/rustc_target/src/spec/targets/i686_win7_windows_gnu.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use crate::spec::{
Arch, Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base,
Arch, Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, TargetOptions,
base,
};

pub(crate) fn target() -> Target {
let mut base = base::windows_gnu::opts();
base.vendor = "win7".into();
base.rustc_abi = Some(RustcAbi::X86Sse2);
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
base.frame_pointer = FramePointer::Always; // Required for backtraces
base.linker = Some("i686-w64-mingw32-gcc".into());
let mut base = TargetOptions {
vendor: "win7".into(),
rustc_abi: Some(RustcAbi::X86Sse2),
cpu: "pentium4".into(),
max_atomic_width: Some(64),
frame_pointer: FramePointer::Always, // Required for backtraces
linker: Some("i686-w64-mingw32-gcc".into()),
..base::windows_gnu::opts()
};

// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.
Expand Down
30 changes: 17 additions & 13 deletions compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
use crate::spec::{Arch, LinkerFlavor, Lld, RustcAbi, SanitizerSet, Target, TargetMetadata, base};
use crate::spec::{
Arch, LinkerFlavor, Lld, RustcAbi, SanitizerSet, Target, TargetMetadata, TargetOptions, base,
};

pub(crate) fn target() -> Target {
let mut base = base::windows_msvc::opts();
base.vendor = "win7".into();
base.rustc_abi = Some(RustcAbi::X86Sse2);
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
base.supported_sanitizers = SanitizerSet::ADDRESS;
// On Windows 7 32-bit, the alignment characteristic of the TLS Directory
// don't appear to be respected by the PE Loader, leading to crashes. As
// a result, let's disable has_thread_local to make sure TLS goes through
// the emulation layer.
// See https://github.com/rust-lang/rust/issues/138903
base.has_thread_local = false;
let mut base = TargetOptions {
vendor: "win7".into(),
rustc_abi: Some(RustcAbi::X86Sse2),
cpu: "pentium4".into(),
max_atomic_width: Some(64),
supported_sanitizers: SanitizerSet::ADDRESS,
// On Windows 7 32-bit, the alignment characteristic of the TLS Directory
// don't appear to be respected by the PE Loader, leading to crashes. As
// a result, let's disable has_thread_local to make sure TLS goes through
// the emulation layer.
// See https://github.com/rust-lang/rust/issues/138903
has_thread_local: false,
..base::windows_msvc::opts()
};

base.add_pre_link_args(
LinkerFlavor::Msvc(Lld::No),
Expand Down
16 changes: 9 additions & 7 deletions compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use rustc_abi::Endian;

use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetMetadata, base};
use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
let mut base = base::solaris::opts();
base.endian = Endian::Big;
let mut base = TargetOptions {
endian: Endian::Big,
// llvm calls this "v9"
cpu: "v9".into(),
vendor: "sun".into(),
max_atomic_width: Some(64),
..base::solaris::opts()
};
base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]);
// llvm calls this "v9"
base.cpu = "v9".into();
base.vendor = "sun".into();
base.max_atomic_width = Some(64);

Target {
llvm_target: "sparcv9-sun-solaris".into(),
Expand Down
19 changes: 11 additions & 8 deletions compiler/rustc_target/src/spec/targets/x86_64_pc_solaris.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
use crate::spec::{
Arch, Cc, LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetMetadata, base,
Arch, Cc, LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions,
base,
};

pub(crate) fn target() -> Target {
let mut base = base::solaris::opts();
let mut base = TargetOptions {
cpu: "x86-64".into(),
plt_by_default: false,
vendor: "pc".into(),
max_atomic_width: Some(64),
stack_probes: StackProbeType::Inline,
supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD,
..base::solaris::opts()
};
base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]);
base.cpu = "x86-64".into();
base.plt_by_default = false;
base.vendor = "pc".into();
base.max_atomic_width = Some(64);
base.stack_probes = StackProbeType::Inline;
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD;

Target {
llvm_target: "x86_64-pc-solaris".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, base};
use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
let mut base = base::windows_gnu::opts();
base.vendor = "win7".into();
base.cpu = "x86-64".into();
base.plt_by_default = false;
let mut base = TargetOptions {
vendor: "win7".into(),
cpu: "x86-64".into(),
plt_by_default: false,
max_atomic_width: Some(64),
linker: Some("x86_64-w64-mingw32-gcc".into()),
..base::windows_gnu::opts()
};
// Use high-entropy 64 bit address space for ASLR
base.add_pre_link_args(
LinkerFlavor::Gnu(Cc::No, Lld::No),
&["-m", "i386pep", "--high-entropy-va"],
);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64", "-Wl,--high-entropy-va"]);
base.max_atomic_width = Some(64);
base.linker = Some("x86_64-w64-mingw32-gcc".into());

Target {
llvm_target: "x86_64-pc-windows-gnu".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use crate::spec::{Arch, SanitizerSet, Target, TargetMetadata, base};
use crate::spec::{Arch, SanitizerSet, Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
let mut base = base::windows_msvc::opts();
base.vendor = "win7".into();
base.cpu = "x86-64".into();
base.plt_by_default = false;
base.max_atomic_width = Some(64);
base.supported_sanitizers = SanitizerSet::ADDRESS;
let base = TargetOptions {
vendor: "win7".into(),
cpu: "x86-64".into(),
plt_by_default: false,
max_atomic_width: Some(64),
supported_sanitizers: SanitizerSet::ADDRESS,
..base::windows_msvc::opts()
};

Target {
llvm_target: "x86_64-pc-windows-msvc".into(),
Expand Down
Loading
Loading