diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig index 0cb442d90f..1506a58497 100644 --- a/src/Compilation/Config.zig +++ b/src/Compilation/Config.zig @@ -137,7 +137,6 @@ pub const ResolveError = error{ SanitizeThreadRequiresLibCpp, LibCRequiresLibUnwind, LibCppRequiresLibUnwind, - OsRequiresLibC, LibCppRequiresLibC, LibUnwindRequiresLibC, TargetCannotDynamicLink, @@ -226,10 +225,6 @@ pub fn resolve(options: Options) ResolveError!Config { }; const link_libc = b: { - if (target_util.osRequiresLibC(target)) { - if (options.link_libc == false) return error.OsRequiresLibC; - break :b true; - } if (link_libcpp) { if (options.link_libc == false) return error.LibCppRequiresLibC; break :b true; @@ -250,7 +245,7 @@ pub fn resolve(options: Options) ResolveError!Config { if (options.ensure_libc_on_non_freestanding and target.os.tag != .freestanding) break :b true; - break :b false; + break :b target.requiresLibC(); }; const link_mode = b: { @@ -269,7 +264,7 @@ pub fn resolve(options: Options) ResolveError!Config { break :b .dynamic; } if (explicitly_exe_or_dyn_lib and link_libc and - (target_util.osRequiresLibC(target) or + (target.requiresLibC() or // For these libcs, Zig can only provide dynamic libc when cross-compiling. ((target.isGnuLibC() or target.isFreeBSDLibC() or target.isNetBSDLibC()) and !options.resolved_target.is_native_abi))) diff --git a/src/main.zig b/src/main.zig index c08e9da449..e865f5b4c7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3993,7 +3993,6 @@ fn createModule( error.SanitizeThreadRequiresLibCpp => fatal("thread sanitization is (for now) implemented in C++, so it requires linking libc++", .{}), error.LibCRequiresLibUnwind => fatal("libc of the specified target requires linking libunwind", .{}), error.LibCppRequiresLibUnwind => fatal("libc++ requires linking libunwind", .{}), - error.OsRequiresLibC => fatal("the target OS requires using libc as the stable syscall interface", .{}), error.LibCppRequiresLibC => fatal("libc++ requires linking libc", .{}), error.LibUnwindRequiresLibC => fatal("libunwind requires linking libc", .{}), error.TargetCannotDynamicLink => fatal("dynamic linking unavailable on the specified target", .{}), diff --git a/src/target.zig b/src/target.zig index 7e50589ab8..87d0522ce7 100644 --- a/src/target.zig +++ b/src/target.zig @@ -17,13 +17,6 @@ pub fn cannotDynamicLink(target: *const std.Target) bool { }; } -/// 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 osRequiresLibC(target: *const std.Target) bool { - return target.requiresLibC(); -} - pub fn libCNeedsLibUnwind(target: *const std.Target, link_mode: std.builtin.LinkMode) bool { return target.isGnuLibC() and link_mode == .static; } @@ -49,7 +42,7 @@ pub fn libCxxNeedsLibUnwind(target: *const std.Target) bool { pub fn requiresPIC(target: *const std.Target, linking_libc: bool) bool { return target.abi.isAndroid() or target.os.tag == .windows or target.os.tag == .uefi or - osRequiresLibC(target) or + target.requiresLibC() or (linking_libc and target.isGnuLibC()); }