Commit 4b91e4c91f
Changed files (3)
lib
src-self-hosted
lib/std/process.zig
@@ -666,6 +666,6 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0]
}
return paths.toOwnedSlice();
},
- else => return error.UnimplementedSelfExeSharedPaths,
+ else => @compileError("getSelfExeSharedLibPaths unimplemented for this target"),
}
}
lib/std/target.zig
@@ -1220,6 +1220,28 @@ pub const Target = union(enum) {
};
}
+ pub fn hasDynamicLinker(self: Target) bool {
+ switch (self.getArch()) {
+ .wasm32,
+ .wasm64,
+ => return false,
+ else => {},
+ }
+ switch (self.getOs()) {
+ .freestanding,
+ .ios,
+ .tvos,
+ .watchos,
+ .macosx,
+ .uefi,
+ .windows,
+ .emscripten,
+ .other,
+ => return false,
+ else => return true,
+ }
+ }
+
/// Caller owns returned memory.
pub fn getStandardDynamicLinkerPath(
self: Target,
src-self-hosted/libc_installation.zig
@@ -536,7 +536,11 @@ fn ccPrintFileName(
}
/// Caller owns returned memory.
-pub fn detectNativeDynamicLinker(allocator: *Allocator) ![:0]u8 {
+pub fn detectNativeDynamicLinker(allocator: *Allocator) error{OutOfMemory, TargetHasNoDynamicLinker, UnknownDynamicLinkerPath}![:0]u8 {
+ if (!comptime Target.current.hasDynamicLinker()) {
+ return error.TargetHasNoDynamicLinker;
+ }
+
const standard_ld_path = try std.Target.current.getStandardDynamicLinkerPath(allocator);
var standard_ld_path_resource: ?[:0]u8 = standard_ld_path; // Set to null to avoid freeing it.
defer if (standard_ld_path_resource) |s| allocator.free(s);