| author | |
| committer | |
| log | 4b91e4c91fae760f30becbafaf28befef832ecf5 |
| tree | cea75e9083be7abcc0fdfec11d54e0eb23a15244 |
| parent | e26f063b22893f50dd7eb02a01585f4d52849ede |
3 files changed, 28 insertions(+), 2 deletions(-)
lib/std/process.zig+1-1| ... | @@ -666,6 +666,6 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0] | ... | @@ -666,6 +666,6 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0] |
| 666 | } | 666 | } |
| 667 | return paths.toOwnedSlice(); | 667 | return paths.toOwnedSlice(); |
| 668 | }, | 668 | }, |
| 669 | else => return error.UnimplementedSelfExeSharedPaths, | 669 | else => @compileError("getSelfExeSharedLibPaths unimplemented for this target"), |
| 670 | } | 670 | } |
| 671 | } | 671 | } |
lib/std/target.zig+22| ... | @@ -1220,6 +1220,28 @@ pub const Target = union(enum) { | ... | @@ -1220,6 +1220,28 @@ pub const Target = union(enum) { |
| 1220 | }; | 1220 | }; |
| 1221 | } | 1221 | } |
| 1222 | 1222 | ||
| 1223 | pub fn hasDynamicLinker(self: Target) bool { | ||
| 1224 | switch (self.getArch()) { | ||
| 1225 | .wasm32, | ||
| 1226 | .wasm64, | ||
| 1227 | => return false, | ||
| 1228 | else => {}, | ||
| 1229 | } | ||
| 1230 | switch (self.getOs()) { | ||
| 1231 | .freestanding, | ||
| 1232 | .ios, | ||
| 1233 | .tvos, | ||
| 1234 | .watchos, | ||
| 1235 | .macosx, | ||
| 1236 | .uefi, | ||
| 1237 | .windows, | ||
| 1238 | .emscripten, | ||
| 1239 | .other, | ||
| 1240 | => return false, | ||
| 1241 | else => return true, | ||
| 1242 | } | ||
| 1243 | } | ||
| 1244 | |||
| 1223 | /// Caller owns returned memory. | 1245 | /// Caller owns returned memory. |
| 1224 | pub fn getStandardDynamicLinkerPath( | 1246 | pub fn getStandardDynamicLinkerPath( |
| 1225 | self: Target, | 1247 | self: Target, |
src-self-hosted/libc_installation.zig+5-1| ... | @@ -536,7 +536,11 @@ fn ccPrintFileName( | ... | @@ -536,7 +536,11 @@ fn ccPrintFileName( |
| 536 | } | 536 | } |
| 537 | 537 | ||
| 538 | /// Caller owns returned memory. | 538 | /// Caller owns returned memory. |
| 539 | pub fn detectNativeDynamicLinker(allocator: *Allocator) ![:0]u8 { | 539 | pub fn detectNativeDynamicLinker(allocator: *Allocator) error{OutOfMemory, TargetHasNoDynamicLinker, UnknownDynamicLinkerPath}![:0]u8 { |
| 540 | if (!comptime Target.current.hasDynamicLinker()) { | ||
| 541 | return error.TargetHasNoDynamicLinker; | ||
| 542 | } | ||
| 543 | |||
| 540 | const standard_ld_path = try std.Target.current.getStandardDynamicLinkerPath(allocator); | 544 | const standard_ld_path = try std.Target.current.getStandardDynamicLinkerPath(allocator); |
| 541 | var standard_ld_path_resource: ?[:0]u8 = standard_ld_path; // Set to null to avoid freeing it. | 545 | var standard_ld_path_resource: ?[:0]u8 = standard_ld_path; // Set to null to avoid freeing it. |
| 542 | defer if (standard_ld_path_resource) |s| allocator.free(s); | 546 | defer if (standard_ld_path_resource) |s| allocator.free(s); |