Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,13 @@ dependencies = [
"windows 0.61.3",
]

[[package]]
name = "compiletest-lint-driver"
version = "0.1.0"
dependencies = [
"libloading",
]

[[package]]
name = "console"
version = "0.16.3"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"src/tools/clippy/clippy_dev",
"src/tools/collect-license-metadata",
"src/tools/compiletest",
"src/tools/compiletest-lint-driver",
"src/tools/coverage-dump",
"src/tools/features-status-dump",
"src/tools/generate-copyright",
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_target/src/spec/consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,13 @@ impl Target {
}
}
}
// Check that linker relaxation is enabled on RISC-V targets for binary size and runtime performance improvements
if kind == TargetKind::Builtin && matches!(self.arch, Arch::RiscV32 | Arch::RiscV64) {
check!(
self.features.contains("+relax"),
"The `+relax` feature should be enabled for RISC-V targets"
);
}

Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
cpu: "generic-rv32".into(),
llvm_abiname: LlvmAbi::Ilp32d,
max_atomic_width: Some(32),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
stack_probes: StackProbeType::Inline,
..base::vxworks::opts()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(crate) fn target() -> Target {
llvm_abiname: LlvmAbi::Ilp32e,
max_atomic_width: Some(32),
atomic_cas: false,
features: "+e,+forced-atomics".into(),
features: "+e,+forced-atomics,+relax".into(),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(crate) fn target() -> Target {
llvm_abiname: LlvmAbi::Ilp32e,
max_atomic_width: Some(32),
atomic_cas: false,
features: "+e,+m,+forced-atomics".into(),
features: "+e,+m,+forced-atomics,+relax".into(),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(crate) fn target() -> Target {
llvm_abiname: LlvmAbi::Ilp32e,
max_atomic_width: Some(32),
atomic_cas: false,
features: "+e,+m,+c,+forced-atomics".into(),
features: "+e,+m,+c,+forced-atomics,+relax".into(),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv32".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32d,
max_atomic_width: Some(32),
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv32".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32d,
max_atomic_width: Some(32),
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
atomic_cas: false,
features: "+forced-atomics".into(),
features: "+forced-atomics,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) fn target() -> Target {
max_atomic_width: Some(64),
atomic_cas: true,

features: "+m".into(),
features: "+m,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
executables: true,
panic_strategy: PanicStrategy::Abort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
atomic_cas: false,
features: "+m,+forced-atomics".into(),
features: "+m,+forced-atomics,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target {
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
features: "+m,+a".into(),
features: "+m,+a,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) fn target() -> Target {
max_atomic_width: Some(32),
atomic_cas: true,

features: "+m,+a,+c".into(),
features: "+m,+a,+c,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target {
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
features: "+m,+a,+c".into(),
features: "+m,+a,+c,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target {
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
features: "+m,+a,+c".into(),
features: "+m,+a,+c,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
panic_strategy: PanicStrategy::Unwind,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target {
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
features: "+m,+a,+c".into(),
features: "+m,+a,+c,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
panic_strategy: PanicStrategy::Unwind,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(crate) fn target() -> Target {
atomic_cas: true,

llvm_abiname: LlvmAbi::Ilp32f,
features: "+m,+a,+c,+f".into(),
features: "+m,+a,+c,+f,+relax".into(),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
llvm_abiname: LlvmAbi::Ilp32f,
features: "+m,+a,+c,+f".into(),
features: "+m,+a,+c,+f,+relax".into(),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
llvm_abiname: LlvmAbi::Ilp32f,
features: "+m,+a,+c,+f".into(),
features: "+m,+a,+c,+f,+relax".into(),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) fn target() -> Target {
max_atomic_width: Some(32),
atomic_cas: true,

features: "+m,+c".into(),
features: "+m,+c,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
atomic_cas: false,
features: "+m,+c,+forced-atomics".into(),
features: "+m,+c,+forced-atomics,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target {
linker: Some("rust-lld".into()),
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
features: "+m,+c".into(),
features: "+m,+c,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32,
panic_strategy: PanicStrategy::Unwind,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
atomic_cas: false,
features: "+m,+f,+c,+forced-atomics".into(),
features: "+m,+f,+c,+forced-atomics,+relax".into(),
llvm_abiname: LlvmAbi::Ilp32f,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv64".into(),
features: "+m,+a,+f,+d,+c,+b,+v,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+b,+v,+zicsr,+zifencei,+relax".into(),
llvm_abiname: LlvmAbi::Lp64d,
supported_sanitizers: SanitizerSet::ADDRESS,
max_atomic_width: Some(64),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
cpu: "generic-rv64".into(),
llvm_abiname: LlvmAbi::Lp64d,
max_atomic_width: Some(64),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
stack_probes: StackProbeType::Inline,
..base::vxworks::opts()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv64".into(),
features: "+rva23u64".into(),
features: "+rva23u64,+relax".into(),
llvm_abiname: LlvmAbi::Lp64d,
max_atomic_width: Some(64),
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv64".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
llvm_abiname: LlvmAbi::Lp64d,
max_atomic_width: Some(64),
..base::freebsd::opts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
let mut base = base::fuchsia::opts();
base.code_model = Some(CodeModel::Medium);
base.cpu = "generic-rv64".into();
base.features = "+m,+a,+f,+d,+c,+v,+zicsr,+zifencei".into();
base.features = "+m,+a,+f,+d,+c,+v,+zicsr,+zifencei,+relax".into();
base.llvm_abiname = LlvmAbi::Lp64d;
base.max_atomic_width = Some(64);
base.stack_probes = StackProbeType::Inline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
options: TargetOptions {
cpu: "generic-rv64".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
relocation_model: RelocModel::Pic,
code_model: Some(CodeModel::Medium),
tls_model: TlsModel::LocalExec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv64".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
llvm_abiname: LlvmAbi::Lp64d,
max_atomic_width: Some(64),
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv64".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
llvm_abiname: LlvmAbi::Lp64d,
max_atomic_width: Some(64),
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv64".into(),
features: "+m,+a,+f,+d,+c".into(),
features: "+m,+a,+f,+d,+c,+relax".into(),
llvm_abiname: LlvmAbi::Lp64d,
max_atomic_width: Some(64),
..base::managarm_mlibc::opts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv64".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
llvm_abiname: LlvmAbi::Lp64d,
max_atomic_width: Some(64),
mcount: "__mcount".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target {
llvm_abiname: LlvmAbi::Lp64d,
cpu: "generic-rv64".into(),
max_atomic_width: Some(64),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
code_model: Some(CodeModel::Medium),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target {
llvm_abiname: LlvmAbi::Lp64d,
cpu: "generic-rv64".into(),
max_atomic_width: Some(64),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
code_model: Some(CodeModel::Medium),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
code_model: Some(CodeModel::Medium),
cpu: "generic-rv64".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei".into(),
features: "+m,+a,+f,+d,+c,+zicsr,+zifencei,+relax".into(),
llvm_abiname: LlvmAbi::Lp64d,
max_atomic_width: Some(64),
..base::openbsd::opts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub(crate) fn target() -> Target {
let mut base = base::redox::opts();
base.code_model = Some(CodeModel::Medium);
base.cpu = "generic-rv64".into();
base.features = "+m,+a,+f,+d,+c".into();
base.features = "+m,+a,+f,+d,+c,+relax".into();
base.llvm_abiname = LlvmAbi::Lp64d;
base.plt_by_default = false;
base.max_atomic_width = Some(64);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target {
cpu: "generic-rv64".into(),
max_atomic_width: Some(64),
atomic_cas: false,
features: "+m,+forced-atomics".into(),
features: "+m,+forced-atomics,+relax".into(),
llvm_abiname: LlvmAbi::Lp64,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target {
linker: Some("rust-lld".into()),
cpu: "generic-rv64".into(),
max_atomic_width: Some(64),
features: "+m,+a,+c".into(),
features: "+m,+a,+c,+relax".into(),
llvm_abiname: LlvmAbi::Lp64,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target {
linker: Some("rust-lld".into()),
cpu: "generic-rv64".into(),
max_atomic_width: Some(64),
features: "+m,+a,+c".into(),
features: "+m,+a,+c,+relax".into(),
llvm_abiname: LlvmAbi::Lp64,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
13 changes: 10 additions & 3 deletions compiler/rustc_type_ir/src/ty_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,16 @@ pub enum TyKind<I: Interner> {

/// A view over an [`Adt`].
///
/// This variant contains the same data as `Adt` as well as a `Ty` field that represents the
/// set of fields that are viewed. This `Ty` should be either a type variable or a tuple of
/// `FieldRepresentingType`.
/// Takes an ADT and restricts the fields that can be accessed. The layout
/// is the same as the initial ADT. View types are `!MetaSized`.
///
/// The fields that can be accessed are encoded as a tuple of `FieldRepresentingType`.
/// For instance, `view_type!(MyStruct.{ field1, field2 })` is represented as
/// `View(MyStruct, [], (field_of!(MyStruct.field1), field_of!(FieldInfo.field2)))`.
///
/// Refer to the [View types experiment][1] project goal for more infos.
///
/// [1]: https://goals.rust-lang.org/2026/view-types-experiment.html
View(I::AdtDef, I::GenericArgs, I::Ty),

/// A projection, opaque type, free type alias, or inherent associated type.
Expand Down
Loading
Loading