Skip to content

Commit

Permalink
std: Remove duplicated code
Browse files Browse the repository at this point in the history
Make osRequiresLibC call Os.requiresLibC, let's keep a single list of OS
that require the libc to be linked in.
  • Loading branch information
LemonBoy authored and andrewrk committed Dec 30, 2020
1 parent daed2ba commit 2622575
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/std/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ pub const Target = 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 {
return switch (os.tag) {
.freebsd,
Expand Down
5 changes: 1 addition & 4 deletions src/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,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 switch (target.os.tag) {
.freebsd, .netbsd, .dragonfly, .openbsd, .macos, .ios, .watchos, .tvos => true,
else => false,
};
return target.os.requiresLibC();
}

pub fn libcNeedsLibUnwind(target: std.Target) bool {
Expand Down

0 comments on commit 2622575

Please sign in to comment.