Skip to content
Closed
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
13 changes: 13 additions & 0 deletions compiler/rustc_public/src/compiler_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,19 @@ impl<'tcx> CompilerInterface<'tcx> {
self.with_cx(|tables, cx| cx.adt_repr(def.internal(tables, cx.tcx)).stable(tables, cx))
}

/// Returns whether this ADT is a phantom data
pub(crate) fn adt_is_phantom_data(&self, def: AdtDef) -> bool {
self.with_cx(|tables, cx| cx.adt_is_phantom_data(def.internal(tables, cx.tcx)))
}
/// Returns whether this ADT is manually drop
pub(crate) fn adt_is_manually_drop(&self, def: AdtDef) -> bool {
self.with_cx(|tables, cx| cx.adt_is_manually_drop(def.internal(tables, cx.tcx)))
}
/// Returns whether this ADT is unsafe cell
pub(crate) fn adt_is_unsafe_cell(&self, def: AdtDef) -> bool {
self.with_cx(|tables, cx| cx.adt_is_unsafe_cell(def.internal(tables, cx.tcx)))
}

/// Retrieve the function signature for the given generic arguments.
pub(crate) fn fn_sig(&self, def: FnDef, args: &GenericArgs) -> PolyFnSig {
self.with_cx(|tables, cx| {
Expand Down
12 changes: 12 additions & 0 deletions compiler/rustc_public/src/ty/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ impl AdtDef {
with(|cx| cx.adt_is_simd(*self))
}

pub fn is_phantom_data(&self) -> bool {
with(|cx| cx.adt_is_phantom_data(*self))
}

pub fn is_manually_drop(&self) -> bool {
with(|cx| cx.adt_is_manually_drop(*self))
}

pub fn is_unsafe_cell(&self) -> bool {
with(|cx| cx.adt_is_unsafe_cell(*self))
}

/// The number of variants in this ADT.
pub fn num_variants(&self) -> usize {
with(|cx| cx.adt_variants_len(*self))
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_public_bridge/src/context/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,20 @@ impl<'tcx, B: Bridge> CompilerCtxt<'tcx, B> {
def.repr()
}

/// Returns if the ADT is a PhantomData
pub fn adt_is_phantom_data(&self, def: AdtDef<'tcx>) -> bool {
def.is_phantom_data()
}

/// Returns if the ADT is ManuallyDrop
pub fn adt_is_manually_drop(&self, def: AdtDef<'tcx>) -> bool {
def.is_manually_drop()
}

/// Returns if the ADT is an UnsafeCell
pub fn adt_is_unsafe_cell(&self, def: AdtDef<'tcx>) -> bool {
def.is_unsafe_cell()
}
/// Retrieve the function signature for the given generic arguments.
pub fn fn_sig(&self, def_id: DefId, args_ref: GenericArgs<'tcx>) -> Binder<'tcx, FnSig<'tcx>> {
let sig = self.tcx.fn_sig(def_id).instantiate(self.tcx, args_ref).skip_norm_wip();
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
Loading
Loading