Skip to content

Commit 0d7ed3b

Browse files
committed
Auto merge of #110214 - compiler-errors:rollup-mkig4t6, r=compiler-errors
Rollup of 10 pull requests Successful merges: - #96971 (Initial support for loongarch64-unknown-linux-gnu) - #109894 (Remove Errors section from var_os docs) - #110000 (Rename tests/ui/unique to tests/ui/box/unit) - #110018 (Pass host linker to compiletest.) - #110104 ( Reword the docstring in todo! macro definition, fixing a typo) - #110113 (Fix `x test ui --target foo` when download-rustc is enabled) - #110126 (Support safe transmute in new solver) - #110155 (Fix typos in librustdoc, tools and config files) - #110162 (rustdoc: remove redundant expandSection code from main.js) - #110173 (kmc-solid: Implement `Socket::read_buf`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 13d1802 + 4c9cd9e commit 0d7ed3b

File tree

110 files changed

+1460
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1460
-243
lines changed

compiler/rustc_codegen_gcc/example/alloc_system.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
const MIN_ALIGN: usize = 8;
1616
#[cfg(any(target_arch = "x86_64",
1717
target_arch = "aarch64",
18+
target_arch = "loongarch64",
1819
target_arch = "mips64",
1920
target_arch = "s390x",
2021
target_arch = "sparc64"))]

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
127127
"msp430" => Architecture::Msp430,
128128
"hexagon" => Architecture::Hexagon,
129129
"bpf" => Architecture::Bpf,
130+
"loongarch64" => Architecture::LoongArch64,
130131
// Unsupported architecture.
131132
_ => return None,
132133
};
@@ -190,6 +191,10 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
190191
}
191192
e_flags
192193
}
194+
Architecture::LoongArch64 => {
195+
// Source: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_e_flags_identifies_abi_type_and_version
196+
elf::EF_LARCH_OBJABI_V1 | elf::EF_LARCH_ABI_DOUBLE_FLOAT
197+
}
193198
_ => 0,
194199
};
195200
// adapted from LLVM's `MCELFObjectTargetWriter::getOSABI`

compiler/rustc_llvm/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const OPTIONAL_COMPONENTS: &[&str] = &[
1010
"aarch64",
1111
"amdgpu",
1212
"avr",
13+
"loongarch",
1314
"m68k",
1415
"mips",
1516
"powerpc",

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) {
146146
#define SUBTARGET_HEXAGON
147147
#endif
148148

149+
#ifdef LLVM_COMPONENT_LOONGARCH
150+
#define SUBTARGET_LOONGARCH SUBTARGET(LoongArch)
151+
#else
152+
#define SUBTARGET_LOONGARCH
153+
#endif
154+
149155
#define GEN_SUBTARGETS \
150156
SUBTARGET_X86 \
151157
SUBTARGET_ARM \
@@ -159,6 +165,7 @@ extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) {
159165
SUBTARGET_SPARC \
160166
SUBTARGET_HEXAGON \
161167
SUBTARGET_RISCV \
168+
SUBTARGET_LOONGARCH \
162169

163170
#define SUBTARGET(x) \
164171
namespace llvm { \

compiler/rustc_llvm/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ pub fn initialize_available_targets() {
102102
LLVMInitializeM68kAsmPrinter,
103103
LLVMInitializeM68kAsmParser
104104
);
105+
init_target!(
106+
llvm_component = "loongarch",
107+
LLVMInitializeLoongArchTargetInfo,
108+
LLVMInitializeLoongArchTarget,
109+
LLVMInitializeLoongArchTargetMC,
110+
LLVMInitializeLoongArchAsmPrinter,
111+
LLVMInitializeLoongArchAsmParser
112+
);
105113
init_target!(
106114
llvm_component = "mips",
107115
LLVMInitializeMipsTargetInfo,

compiler/rustc_middle/src/ty/visit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
8383
| TypeFlags::HAS_CT_PLACEHOLDER,
8484
)
8585
}
86+
fn has_non_region_placeholders(&self) -> bool {
87+
self.has_type_flags(TypeFlags::HAS_TY_PLACEHOLDER | TypeFlags::HAS_CT_PLACEHOLDER)
88+
}
8689
fn needs_subst(&self) -> bool {
8790
self.has_type_flags(TypeFlags::NEEDS_SUBST)
8891
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{Target, TargetOptions};
2+
3+
pub fn target() -> Target {
4+
Target {
5+
llvm_target: "loongarch64-unknown-linux-gnu".into(),
6+
pointer_width: 64,
7+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
8+
arch: "loongarch64".into(),
9+
options: TargetOptions {
10+
cpu: "generic".into(),
11+
features: "+f,+d".into(),
12+
llvm_abiname: "lp64d".into(),
13+
max_atomic_width: Some(64),
14+
..super::linux_gnu_base::opts()
15+
},
16+
}
17+
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,7 @@ supported_targets! {
10211021
("x86_64-unknown-linux-gnux32", x86_64_unknown_linux_gnux32),
10221022
("i686-unknown-linux-gnu", i686_unknown_linux_gnu),
10231023
("i586-unknown-linux-gnu", i586_unknown_linux_gnu),
1024+
("loongarch64-unknown-linux-gnu", loongarch64_unknown_linux_gnu),
10241025
("m68k-unknown-linux-gnu", m68k_unknown_linux_gnu),
10251026
("mips-unknown-linux-gnu", mips_unknown_linux_gnu),
10261027
("mips64-unknown-linux-gnuabi64", mips64_unknown_linux_gnuabi64),

compiler/rustc_trait_selection/src/solve/assembly/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ pub(super) trait GoalKind<'tcx>: TypeFoldable<TyCtxt<'tcx>> + Copy + Eq {
225225
ecx: &mut EvalCtxt<'_, 'tcx>,
226226
goal: Goal<'tcx, Self>,
227227
) -> QueryResult<'tcx>;
228+
229+
fn consider_builtin_transmute_candidate(
230+
ecx: &mut EvalCtxt<'_, 'tcx>,
231+
goal: Goal<'tcx, Self>,
232+
) -> QueryResult<'tcx>;
228233
}
229234

230235
impl<'tcx> EvalCtxt<'_, 'tcx> {
@@ -373,6 +378,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
373378
G::consider_builtin_discriminant_kind_candidate(self, goal)
374379
} else if lang_items.destruct_trait() == Some(trait_def_id) {
375380
G::consider_builtin_destruct_candidate(self, goal)
381+
} else if lang_items.transmute_trait() == Some(trait_def_id) {
382+
G::consider_builtin_transmute_candidate(self, goal)
376383
} else {
377384
Err(NoSolution)
378385
};

compiler/rustc_trait_selection/src/solve/eval_ctxt.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,4 +639,25 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
639639
crate::traits::wf::unnormalized_obligations(self.infcx, param_env, arg)
640640
.map(|obligations| obligations.into_iter().map(|obligation| obligation.into()))
641641
}
642+
643+
pub(super) fn is_transmutable(
644+
&self,
645+
src_and_dst: rustc_transmute::Types<'tcx>,
646+
scope: Ty<'tcx>,
647+
assume: rustc_transmute::Assume,
648+
) -> Result<Certainty, NoSolution> {
649+
// FIXME(transmutability): This really should be returning nested goals for `Answer::If*`
650+
match rustc_transmute::TransmuteTypeEnv::new(self.infcx).is_transmutable(
651+
ObligationCause::dummy(),
652+
ty::Binder::dummy(src_and_dst),
653+
scope,
654+
assume,
655+
) {
656+
rustc_transmute::Answer::Yes => Ok(Certainty::Yes),
657+
rustc_transmute::Answer::No(_)
658+
| rustc_transmute::Answer::IfTransmutable { .. }
659+
| rustc_transmute::Answer::IfAll(_)
660+
| rustc_transmute::Answer::IfAny(_) => Err(NoSolution),
661+
}
662+
}
642663
}

0 commit comments

Comments
 (0)