diff --git a/zig/lib/std/Target.zig b/zig/lib/std/Target.zig index 0e020216b8..f9d8908265 100644 --- a/zig/lib/std/Target.zig +++ b/zig/lib/std/Target.zig @@ -405,7 +405,7 @@ pub const Os = struct { /// On Darwin, we always link libSystem which contains libc. /// Similarly on FreeBSD and NetBSD we always link system libc /// since this is the stable syscall interface. - pub fn requiresLibC(os: Os) bool { + pub fn requiresLibC(os: Os, cpu: Cpu) bool { return switch (os.tag) { .freebsd, .netbsd, @@ -420,7 +420,12 @@ pub const Os = struct { .illumos, => true, - .linux, + .linux => blk: { + break :blk switch (cpu.arch) { + .loongarch64 => true, + else => false, + }; + }, .windows, .freestanding, .ananas, diff --git a/zig/src/target.zig b/zig/src/target.zig index 8c66017e79..f7d9cf57fc 100644 --- a/zig/src/target.zig +++ b/zig/src/target.zig @@ -80,6 +80,7 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .x86_64, .os = .linux, .abi = .musl }, .{ .arch = .x86_64, .os = .windows, .abi = .gnu }, .{ .arch = .x86_64, .os = .macos, .abi = .none, .os_ver = .{ .major = 10, .minor = 7, .patch = 0 } }, + .{ .arch = .loongarch64, .os = .linux, .abi = .gnu, .glibc_min = .{ .major = 2, .minor = 36, .patch = 0 } }, }; /// Minimum glibc version, due to dependencies from the Zig standard library on glibc symbols @@ -186,7 +187,7 @@ pub fn cannotDynamicLink(target: std.Target) bool { /// Similarly on FreeBSD and NetBSD we always link system libc /// since this is the stable syscall interface. pub fn osRequiresLibC(target: std.Target) bool { - return target.os.requiresLibC(); + return target.os.requiresLibC(target.cpu); } pub fn libcNeedsLibUnwind(target: std.Target) bool {