Skip to content

Commit b7e48c6

Browse files
authored
std: Add loongarch support for elf. (#20678)
1 parent 0d1db79 commit b7e48c6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/std/Target.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,8 @@ pub const Cpu = struct {
12101210
.spirv => .NONE,
12111211
.spirv32 => .NONE,
12121212
.spirv64 => .NONE,
1213-
.loongarch32 => .NONE,
1214-
.loongarch64 => .NONE,
1213+
.loongarch32 => .LOONGARCH,
1214+
.loongarch64 => .LOONGARCH,
12151215
};
12161216
}
12171217

lib/std/elf.zig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,9 @@ pub const EM = enum(u16) {
16261626
/// C-SKY
16271627
CSKY = 252,
16281628

1629+
/// LoongArch
1630+
LOONGARCH = 258,
1631+
16291632
/// Fujitsu FR-V
16301633
FRV = 0x5441,
16311634

@@ -1655,6 +1658,14 @@ pub const EM = enum(u16) {
16551658
.SPARCV9 => .sparc64,
16561659
.S390 => .s390x,
16571660
.SPU_2 => .spu_2,
1661+
// FIXME:
1662+
// No support for .loongarch32 yet so it is safe to assume we are on .loongarch64.
1663+
//
1664+
// However, when e_machine is .LOONGARCH, we should check
1665+
// ei_class's value to decide the CPU architecture.
1666+
// - ELFCLASS32 => .loongarch32
1667+
// - ELFCLASS64 => .loongarch64
1668+
.LOONGARCH => .loongarch64,
16581669
// there's many cases we don't (yet) handle, or will never have a
16591670
// zig target cpu arch equivalent (such as null).
16601671
else => null,

0 commit comments

Comments
 (0)