Skip to content

Commit

Permalink
Fix libc.
Browse files Browse the repository at this point in the history
  • Loading branch information
yxd-ym committed Jan 29, 2024
1 parent 7455a4c commit 14d5aa2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions zig/lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion zig/src/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 14d5aa2

Please sign in to comment.