| author | |
| committer | |
| log | 00e6895bde4b5871a944bccf4521b2f6f5f879f6 |
| tree | 5ef6071b34f48ae481b6c0f8785121907403e2cf |
| parent | d0ad76c03c11b6b033d13b28dac913ec11cb9c3a |
| signature |
There are various reasons why one might want to still create libc-less
compilations on these targets. Case in point: Compiling our bundled crt0 for
OpenBSD.
We will still default to linking libc on these targets, though.3 files changed, 3 insertions(+), 16 deletions(-)
src/Compilation/Config.zig+2-7| ... | @@ -137,7 +137,6 @@ pub const ResolveError = error{ | ... | @@ -137,7 +137,6 @@ pub const ResolveError = error{ |
| 137 | SanitizeThreadRequiresLibCpp, | 137 | SanitizeThreadRequiresLibCpp, |
| 138 | LibCRequiresLibUnwind, | 138 | LibCRequiresLibUnwind, |
| 139 | LibCppRequiresLibUnwind, | 139 | LibCppRequiresLibUnwind, |
| 140 | OsRequiresLibC, | ||
| 141 | LibCppRequiresLibC, | 140 | LibCppRequiresLibC, |
| 142 | LibUnwindRequiresLibC, | 141 | LibUnwindRequiresLibC, |
| 143 | TargetCannotDynamicLink, | 142 | TargetCannotDynamicLink, |
| ... | @@ -226,10 +225,6 @@ pub fn resolve(options: Options) ResolveError!Config { | ... | @@ -226,10 +225,6 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 226 | }; | 225 | }; |
| 227 | 226 | ||
| 228 | const link_libc = b: { | 227 | const link_libc = b: { |
| 229 | if (target_util.osRequiresLibC(target)) { | ||
| 230 | if (options.link_libc == false) return error.OsRequiresLibC; | ||
| 231 | break :b true; | ||
| 232 | } | ||
| 233 | if (link_libcpp) { | 228 | if (link_libcpp) { |
| 234 | if (options.link_libc == false) return error.LibCppRequiresLibC; | 229 | if (options.link_libc == false) return error.LibCppRequiresLibC; |
| 235 | break :b true; | 230 | break :b true; |
| ... | @@ -250,7 +245,7 @@ pub fn resolve(options: Options) ResolveError!Config { | ... | @@ -250,7 +245,7 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 250 | if (options.ensure_libc_on_non_freestanding and target.os.tag != .freestanding) | 245 | if (options.ensure_libc_on_non_freestanding and target.os.tag != .freestanding) |
| 251 | break :b true; | 246 | break :b true; |
| 252 | 247 | ||
| 253 | break :b false; | 248 | break :b target.requiresLibC(); |
| 254 | }; | 249 | }; |
| 255 | 250 | ||
| 256 | const link_mode = b: { | 251 | const link_mode = b: { |
| ... | @@ -269,7 +264,7 @@ pub fn resolve(options: Options) ResolveError!Config { | ... | @@ -269,7 +264,7 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 269 | break :b .dynamic; | 264 | break :b .dynamic; |
| 270 | } | 265 | } |
| 271 | if (explicitly_exe_or_dyn_lib and link_libc and | 266 | if (explicitly_exe_or_dyn_lib and link_libc and |
| 272 | (target_util.osRequiresLibC(target) or | 267 | (target.requiresLibC() or |
| 273 | // For these libcs, Zig can only provide dynamic libc when cross-compiling. | 268 | // For these libcs, Zig can only provide dynamic libc when cross-compiling. |
| 274 | ((target.isGnuLibC() or target.isFreeBSDLibC() or target.isNetBSDLibC()) and | 269 | ((target.isGnuLibC() or target.isFreeBSDLibC() or target.isNetBSDLibC()) and |
| 275 | !options.resolved_target.is_native_abi))) | 270 | !options.resolved_target.is_native_abi))) |
src/main.zig-1| ... | @@ -4078,7 +4078,6 @@ fn createModule( | ... | @@ -4078,7 +4078,6 @@ fn createModule( |
| 4078 | error.SanitizeThreadRequiresLibCpp => fatal("thread sanitization is (for now) implemented in C++, so it requires linking libc++", .{}), | 4078 | error.SanitizeThreadRequiresLibCpp => fatal("thread sanitization is (for now) implemented in C++, so it requires linking libc++", .{}), |
| 4079 | error.LibCRequiresLibUnwind => fatal("libc of the specified target requires linking libunwind", .{}), | 4079 | error.LibCRequiresLibUnwind => fatal("libc of the specified target requires linking libunwind", .{}), |
| 4080 | error.LibCppRequiresLibUnwind => fatal("libc++ requires linking libunwind", .{}), | 4080 | error.LibCppRequiresLibUnwind => fatal("libc++ requires linking libunwind", .{}), |
| 4081 | error.OsRequiresLibC => fatal("the target OS requires using libc as the stable syscall interface", .{}), | ||
| 4082 | error.LibCppRequiresLibC => fatal("libc++ requires linking libc", .{}), | 4081 | error.LibCppRequiresLibC => fatal("libc++ requires linking libc", .{}), |
| 4083 | error.LibUnwindRequiresLibC => fatal("libunwind requires linking libc", .{}), | 4082 | error.LibUnwindRequiresLibC => fatal("libunwind requires linking libc", .{}), |
| 4084 | error.TargetCannotDynamicLink => fatal("dynamic linking unavailable on the specified target", .{}), | 4083 | error.TargetCannotDynamicLink => fatal("dynamic linking unavailable on the specified target", .{}), |
src/target.zig+1-8| ... | @@ -17,13 +17,6 @@ pub fn cannotDynamicLink(target: *const std.Target) bool { | ... | @@ -17,13 +17,6 @@ pub fn cannotDynamicLink(target: *const std.Target) bool { |
| 17 | }; | 17 | }; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | /// On Darwin, we always link libSystem which contains libc. | ||
| 21 | /// Similarly on FreeBSD and NetBSD we always link system libc | ||
| 22 | /// since this is the stable syscall interface. | ||
| 23 | pub fn osRequiresLibC(target: *const std.Target) bool { | ||
| 24 | return target.requiresLibC(); | ||
| 25 | } | ||
| 26 | |||
| 27 | pub fn libCNeedsLibUnwind(target: *const std.Target, link_mode: std.builtin.LinkMode) bool { | 20 | pub fn libCNeedsLibUnwind(target: *const std.Target, link_mode: std.builtin.LinkMode) bool { |
| 28 | return target.isGnuLibC() and link_mode == .static; | 21 | return target.isGnuLibC() and link_mode == .static; |
| 29 | } | 22 | } |
| ... | @@ -49,7 +42,7 @@ pub fn libCxxNeedsLibUnwind(target: *const std.Target) bool { | ... | @@ -49,7 +42,7 @@ pub fn libCxxNeedsLibUnwind(target: *const std.Target) bool { |
| 49 | pub fn requiresPIC(target: *const std.Target, linking_libc: bool) bool { | 42 | pub fn requiresPIC(target: *const std.Target, linking_libc: bool) bool { |
| 50 | return target.abi.isAndroid() or | 43 | return target.abi.isAndroid() or |
| 51 | target.os.tag == .windows or target.os.tag == .uefi or | 44 | target.os.tag == .windows or target.os.tag == .uefi or |
| 52 | osRequiresLibC(target) or | 45 | target.requiresLibC() or |
| 53 | (linking_libc and target.isGnuLibC()); | 46 | (linking_libc and target.isGnuLibC()); |
| 54 | } | 47 | } |
| 55 | 48 |