commit 4b91e4c91fae760f30becbafaf28befef832ecf5 (tree)
parent e26f063b22893f50dd7eb02a01585f4d52849ede
Author: Andrew Kelley <andrew@ziglang.org>
Date: Mon, 17 Feb 2020 16:03:01 -0500
fix dynamic linker detection on windows (where there isn't one)
Diffstat:
3 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/lib/std/process.zig b/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"),
}
}
diff --git a/lib/std/target.zig b/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,
diff --git a/src-self-hosted/libc_installation.zig b/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);