Skip to content

Commit ab0a33a

Browse files
authored
Unrolled build for #142053
Rollup merge of #142053 - heiher:loong32-none, r=wesleywiser Add new Tier-3 targets: `loongarch32-unknown-none*` MCP: rust-lang/compiler-team#865 NOTE: LoongArch32 ELF object support is available starting with object v0.37.0.
2 parents c31cccb + 38d69c3 commit ab0a33a

File tree

34 files changed

+181
-53
lines changed

34 files changed

+181
-53
lines changed

Cargo.lock

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ version = "0.4.2"
162162
source = "registry+https://github.com/rust-lang/crates.io-index"
163163
checksum = "01667f6f40216b9a0b2945e05fed5f1ad0ab6470e69cb9378001e37b1c0668e4"
164164
dependencies = [
165-
"object",
165+
"object 0.36.7",
166166
]
167167

168168
[[package]]
@@ -235,7 +235,7 @@ dependencies = [
235235
"cfg-if",
236236
"libc",
237237
"miniz_oxide",
238-
"object",
238+
"object 0.36.7",
239239
"rustc-demangle",
240240
"windows-targets 0.52.6",
241241
]
@@ -2509,7 +2509,19 @@ dependencies = [
25092509
"indexmap",
25102510
"memchr",
25112511
"ruzstd",
2512-
"wasmparser 0.222.1",
2512+
]
2513+
2514+
[[package]]
2515+
name = "object"
2516+
version = "0.37.0"
2517+
source = "registry+https://github.com/rust-lang/crates.io-index"
2518+
checksum = "6273adb7096cf9ab4335f258e627d8230e69d40d45567d678f552dcec6245215"
2519+
dependencies = [
2520+
"crc32fast",
2521+
"hashbrown",
2522+
"indexmap",
2523+
"memchr",
2524+
"wasmparser 0.232.0",
25132525
]
25142526

25152527
[[package]]
@@ -3109,7 +3121,7 @@ dependencies = [
31093121
"build_helper",
31103122
"gimli",
31113123
"libc",
3112-
"object",
3124+
"object 0.36.7",
31133125
"regex",
31143126
"serde_json",
31153127
"similar",
@@ -3422,7 +3434,7 @@ dependencies = [
34223434
"itertools",
34233435
"libc",
34243436
"measureme",
3425-
"object",
3437+
"object 0.37.0",
34263438
"rustc-demangle",
34273439
"rustc_abi",
34283440
"rustc_ast",
@@ -3463,7 +3475,7 @@ dependencies = [
34633475
"either",
34643476
"itertools",
34653477
"libc",
3466-
"object",
3478+
"object 0.37.0",
34673479
"pathdiff",
34683480
"regex",
34693481
"rustc_abi",
@@ -4495,7 +4507,7 @@ name = "rustc_target"
44954507
version = "0.0.0"
44964508
dependencies = [
44974509
"bitflags",
4498-
"object",
4510+
"object 0.37.0",
44994511
"rustc_abi",
45004512
"rustc_data_structures",
45014513
"rustc_fs_util",
@@ -5247,7 +5259,7 @@ checksum = "9e9c1e705f82a260173f3eec93f2ff6d7807f23ad5a8cc2e7316a891733ea7a1"
52475259
dependencies = [
52485260
"gimli",
52495261
"hashbrown",
5250-
"object",
5262+
"object 0.36.7",
52515263
"tracing",
52525264
]
52535265

@@ -5908,15 +5920,6 @@ dependencies = [
59085920
"indexmap",
59095921
]
59105922

5911-
[[package]]
5912-
name = "wasmparser"
5913-
version = "0.222.1"
5914-
source = "registry+https://github.com/rust-lang/crates.io-index"
5915-
checksum = "fa210fd1788e6b37a1d1930f3389c48e1d6ebd1a013d34fa4b7f9e3e3bf03146"
5916-
dependencies = [
5917-
"bitflags",
5918-
]
5919-
59205923
[[package]]
59215924
name = "wasmparser"
59225925
version = "0.229.0"
@@ -5941,6 +5944,15 @@ dependencies = [
59415944
"semver",
59425945
]
59435946

5947+
[[package]]
5948+
name = "wasmparser"
5949+
version = "0.232.0"
5950+
source = "registry+https://github.com/rust-lang/crates.io-index"
5951+
checksum = "917739b33bb1eb0e9a49bcd2637a351931be4578d0cc4d37b908d7a797784fbb"
5952+
dependencies = [
5953+
"bitflags",
5954+
]
5955+
59445956
[[package]]
59455957
name = "wast"
59465958
version = "230.0.0"

compiler/rustc_codegen_gcc/example/alloc_system.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// add fast paths for low alignment values.
99
#[cfg(any(target_arch = "x86",
1010
target_arch = "arm",
11+
target_arch = "loongarch32",
1112
target_arch = "m68k",
1213
target_arch = "mips",
1314
target_arch = "mips32r6",

compiler/rustc_codegen_llvm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ gimli = "0.31"
1515
itertools = "0.12"
1616
libc = "0.2"
1717
measureme = "12.0.1"
18-
object = { version = "0.36.3", default-features = false, features = ["std", "read"] }
18+
object = { version = "0.37.0", default-features = false, features = ["std", "read"] }
1919
rustc-demangle = "0.1.21"
2020
rustc_abi = { path = "../rustc_abi" }
2121
rustc_ast = { path = "../rustc_ast" }

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
251251
InlineAsmArch::Nvptx64 => {}
252252
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {}
253253
InlineAsmArch::Hexagon => {}
254-
InlineAsmArch::LoongArch64 => {
254+
InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => {
255255
constraints.extend_from_slice(&[
256256
"~{$fcc0}".to_string(),
257257
"~{$fcc1}".to_string(),

compiler/rustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ libc = "0.2.50"
5454
# tidy-alphabetical-end
5555

5656
[dependencies.object]
57-
version = "0.36.2"
57+
version = "0.37.0"
5858
default-features = false
5959
features = ["read_core", "elf", "macho", "pe", "xcoff", "unaligned", "archive", "write", "wasm"]
6060

compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport]
287287
(Architecture::X86_64, None) => elf::EM_X86_64,
288288
(Architecture::X86_64_X32, None) => elf::EM_X86_64,
289289
(Architecture::Hexagon, None) => elf::EM_HEXAGON,
290+
(Architecture::LoongArch32, None) => elf::EM_LOONGARCH,
290291
(Architecture::LoongArch64, None) => elf::EM_LOONGARCH,
291292
(Architecture::M68k, None) => elf::EM_68K,
292293
(Architecture::Mips, None) => elf::EM_MIPS,

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {
348348

349349
e_flags
350350
}
351-
Architecture::LoongArch64 => {
351+
Architecture::LoongArch32 | Architecture::LoongArch64 => {
352352
// Source: https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#e_flags-identifies-abi-type-and-version
353353
let mut e_flags: u32 = elf::EF_LARCH_OBJABI_V1;
354354

compiler/rustc_target/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ tracing = "0.1"
2020
# tidy-alphabetical-start
2121
default-features = false
2222
features = ["elf", "macho"]
23-
version = "0.36.2"
23+
version = "0.37.0"
2424
# tidy-alphabetical-end

compiler/rustc_target/src/asm/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ pub enum InlineAsmArch {
226226
RiscV64,
227227
Nvptx64,
228228
Hexagon,
229+
LoongArch32,
229230
LoongArch64,
230231
Mips,
231232
Mips64,
@@ -260,6 +261,7 @@ impl FromStr for InlineAsmArch {
260261
"powerpc" => Ok(Self::PowerPC),
261262
"powerpc64" => Ok(Self::PowerPC64),
262263
"hexagon" => Ok(Self::Hexagon),
264+
"loongarch32" => Ok(Self::LoongArch32),
263265
"loongarch64" => Ok(Self::LoongArch64),
264266
"mips" | "mips32r6" => Ok(Self::Mips),
265267
"mips64" | "mips64r6" => Ok(Self::Mips64),
@@ -365,7 +367,9 @@ impl InlineAsmReg {
365367
Self::PowerPC(PowerPCInlineAsmReg::parse(name)?)
366368
}
367369
InlineAsmArch::Hexagon => Self::Hexagon(HexagonInlineAsmReg::parse(name)?),
368-
InlineAsmArch::LoongArch64 => Self::LoongArch(LoongArchInlineAsmReg::parse(name)?),
370+
InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => {
371+
Self::LoongArch(LoongArchInlineAsmReg::parse(name)?)
372+
}
369373
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {
370374
Self::Mips(MipsInlineAsmReg::parse(name)?)
371375
}
@@ -652,7 +656,9 @@ impl InlineAsmRegClass {
652656
Self::PowerPC(PowerPCInlineAsmRegClass::parse(name)?)
653657
}
654658
InlineAsmArch::Hexagon => Self::Hexagon(HexagonInlineAsmRegClass::parse(name)?),
655-
InlineAsmArch::LoongArch64 => Self::LoongArch(LoongArchInlineAsmRegClass::parse(name)?),
659+
InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => {
660+
Self::LoongArch(LoongArchInlineAsmRegClass::parse(name)?)
661+
}
656662
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {
657663
Self::Mips(MipsInlineAsmRegClass::parse(name)?)
658664
}
@@ -860,7 +866,7 @@ pub fn allocatable_registers(
860866
hexagon::fill_reg_map(arch, reloc_model, target_features, target, &mut map);
861867
map
862868
}
863-
InlineAsmArch::LoongArch64 => {
869+
InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => {
864870
let mut map = loongarch::regclass_map();
865871
loongarch::fill_reg_map(arch, reloc_model, target_features, target, &mut map);
866872
map
@@ -992,7 +998,7 @@ impl InlineAsmClobberAbi {
992998
"C" | "system" => Ok(InlineAsmClobberAbi::Avr),
993999
_ => Err(&["C", "system"]),
9941000
},
995-
InlineAsmArch::LoongArch64 => match name {
1001+
InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => match name {
9961002
"C" | "system" => Ok(InlineAsmClobberAbi::LoongArch),
9971003
_ => Err(&["C", "system"]),
9981004
},

compiler/rustc_target/src/callconv/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
648648
"amdgpu" => amdgpu::compute_abi_info(cx, self),
649649
"arm" => arm::compute_abi_info(cx, self),
650650
"avr" => avr::compute_abi_info(self),
651-
"loongarch64" => loongarch::compute_abi_info(cx, self),
651+
"loongarch32" | "loongarch64" => loongarch::compute_abi_info(cx, self),
652652
"m68k" => m68k::compute_abi_info(self),
653653
"csky" => csky::compute_abi_info(self),
654654
"mips" | "mips32r6" => mips::compute_abi_info(cx, self),
@@ -691,7 +691,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
691691
match &*spec.arch {
692692
"x86" => x86::compute_rust_abi_info(cx, self),
693693
"riscv32" | "riscv64" => riscv::compute_rust_abi_info(cx, self),
694-
"loongarch64" => loongarch::compute_rust_abi_info(cx, self),
694+
"loongarch32" | "loongarch64" => loongarch::compute_rust_abi_info(cx, self),
695695
"aarch64" => aarch64::compute_rust_abi_info(cx, self),
696696
_ => {}
697697
};

compiler/rustc_target/src/spec/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,8 @@ supported_targets! {
19811981

19821982
("sparc-unknown-none-elf", sparc_unknown_none_elf),
19831983

1984+
("loongarch32-unknown-none", loongarch32_unknown_none),
1985+
("loongarch32-unknown-none-softfloat", loongarch32_unknown_none_softfloat),
19841986
("loongarch64-unknown-none", loongarch64_unknown_none),
19851987
("loongarch64-unknown-none-softfloat", loongarch64_unknown_none_softfloat),
19861988

@@ -3502,6 +3504,7 @@ impl Target {
35023504
"msp430" => (Architecture::Msp430, None),
35033505
"hexagon" => (Architecture::Hexagon, None),
35043506
"bpf" => (Architecture::Bpf, None),
3507+
"loongarch32" => (Architecture::LoongArch32, None),
35053508
"loongarch64" => (Architecture::LoongArch64, None),
35063509
"csky" => (Architecture::Csky, None),
35073510
"arm64ec" => (Architecture::Aarch64, Some(object::SubArchitecture::Arm64EC)),
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use crate::spec::{
2+
Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
3+
};
4+
5+
pub(crate) fn target() -> Target {
6+
Target {
7+
llvm_target: "loongarch32-unknown-none".into(),
8+
metadata: TargetMetadata {
9+
description: Some("Freestanding/bare-metal LoongArch32".into()),
10+
tier: Some(3),
11+
host_tools: Some(false),
12+
std: Some(false),
13+
},
14+
pointer_width: 32,
15+
data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
16+
arch: "loongarch32".into(),
17+
options: TargetOptions {
18+
cpu: "generic".into(),
19+
features: "+f,+d".into(),
20+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
21+
linker: Some("rust-lld".into()),
22+
llvm_abiname: "ilp32d".into(),
23+
max_atomic_width: Some(32),
24+
relocation_model: RelocModel::Static,
25+
panic_strategy: PanicStrategy::Abort,
26+
..Default::default()
27+
},
28+
}
29+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use crate::spec::{
2+
Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
3+
};
4+
5+
pub(crate) fn target() -> Target {
6+
Target {
7+
llvm_target: "loongarch32-unknown-none".into(),
8+
metadata: TargetMetadata {
9+
description: Some("Freestanding/bare-metal LoongArch32 softfloat".into()),
10+
tier: Some(3),
11+
host_tools: Some(false),
12+
std: Some(false),
13+
},
14+
pointer_width: 32,
15+
data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
16+
arch: "loongarch32".into(),
17+
options: TargetOptions {
18+
cpu: "generic".into(),
19+
features: "-f,-d".into(),
20+
abi: "softfloat".into(),
21+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
22+
linker: Some("rust-lld".into()),
23+
llvm_abiname: "ilp32s".into(),
24+
max_atomic_width: Some(32),
25+
relocation_model: RelocModel::Static,
26+
panic_strategy: PanicStrategy::Abort,
27+
..Default::default()
28+
},
29+
}
30+
}

compiler/rustc_target/src/target_features.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ impl Target {
846846
"wasm32" | "wasm64" => WASM_FEATURES,
847847
"bpf" => BPF_FEATURES,
848848
"csky" => CSKY_FEATURES,
849-
"loongarch64" => LOONGARCH_FEATURES,
849+
"loongarch32" | "loongarch64" => LOONGARCH_FEATURES,
850850
"s390x" => IBMZ_FEATURES,
851851
"sparc" | "sparc64" => SPARC_FEATURES,
852852
"m68k" => M68K_FEATURES,
@@ -860,7 +860,7 @@ impl Target {
860860
"aarch64" | "arm64ec" => AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI,
861861
"arm" => ARM_FEATURES_FOR_CORRECT_VECTOR_ABI,
862862
"powerpc" | "powerpc64" => POWERPC_FEATURES_FOR_CORRECT_VECTOR_ABI,
863-
"loongarch64" => LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI,
863+
"loongarch32" | "loongarch64" => LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI,
864864
"riscv32" | "riscv64" => RISCV_FEATURES_FOR_CORRECT_VECTOR_ABI,
865865
"wasm32" | "wasm64" => WASM_FEATURES_FOR_CORRECT_VECTOR_ABI,
866866
"s390x" => S390X_FEATURES_FOR_CORRECT_VECTOR_ABI,
@@ -1034,7 +1034,7 @@ impl Target {
10341034
_ => unreachable!(),
10351035
}
10361036
}
1037-
"loongarch64" => {
1037+
"loongarch32" | "loongarch64" => {
10381038
// LoongArch handles ABI in a very sane way, being fully explicit via `llvm_abiname`
10391039
// about what the intended ABI is.
10401040
match &*self.llvm_abiname {

library/core/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ debug_typeid = []
2929
[lints.rust.unexpected_cfgs]
3030
level = "warn"
3131
check-cfg = [
32+
# #[cfg(bootstrap)] loongarch32
33+
'cfg(target_arch, values("loongarch32"))',
3234
'cfg(no_fp_fmt_parse)',
3335
# core use #[path] imports to portable-simd `core_simd` crate
3436
# and to stdarch `core_arch` crate which messes-up with Cargo list

library/core/src/sync/atomic.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
//!
179179
//! | `target_arch` | Size limit |
180180
//! |---------------|---------|
181-
//! | `x86`, `arm`, `mips`, `mips32r6`, `powerpc`, `riscv32`, `sparc`, `hexagon` | 4 bytes |
181+
//! | `x86`, `arm`, `loongarch32`, `mips`, `mips32r6`, `powerpc`, `riscv32`, `sparc`, `hexagon` | 4 bytes |
182182
//! | `x86_64`, `aarch64`, `loongarch64`, `mips64`, `mips64r6`, `powerpc64`, `riscv64`, `sparc64`, `s390x` | 8 bytes |
183183
//!
184184
//! Atomics loads that are larger than this limit as well as atomic loads with ordering other
@@ -350,8 +350,12 @@ pub type Atomic<T> = <T as AtomicPrimitive>::AtomicInner;
350350
// This list should only contain architectures which have word-sized atomic-or/
351351
// atomic-and instructions but don't natively support byte-sized atomics.
352352
#[cfg(target_has_atomic = "8")]
353-
const EMULATE_ATOMIC_BOOL: bool =
354-
cfg!(any(target_arch = "riscv32", target_arch = "riscv64", target_arch = "loongarch64"));
353+
const EMULATE_ATOMIC_BOOL: bool = cfg!(any(
354+
target_arch = "riscv32",
355+
target_arch = "riscv64",
356+
target_arch = "loongarch32",
357+
target_arch = "loongarch64"
358+
));
355359

356360
/// A boolean type which can be safely shared between threads.
357361
///

library/std/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ test = true
157157
[lints.rust.unexpected_cfgs]
158158
level = "warn"
159159
check-cfg = [
160+
# #[cfg(bootstrap)] loongarch32
161+
'cfg(target_arch, values("loongarch32"))',
160162
# std use #[path] imports to portable-simd `std_float` crate
161163
# and to the `backtrace` crate which messes-up with Cargo list
162164
# of declared features, we therefor expect any feature cfg

0 commit comments

Comments
 (0)