Skip to content

Commit 4b91e4c

Browse files
committed
fix dynamic linker detection on windows (where there isn't one)
1 parent e26f063 commit 4b91e4c

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

lib/std/process.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,6 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0]
666666
}
667667
return paths.toOwnedSlice();
668668
},
669-
else => return error.UnimplementedSelfExeSharedPaths,
669+
else => @compileError("getSelfExeSharedLibPaths unimplemented for this target"),
670670
}
671671
}

lib/std/target.zig

+22
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,28 @@ pub const Target = union(enum) {
12201220
};
12211221
}
12221222

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+
12231245
/// Caller owns returned memory.
12241246
pub fn getStandardDynamicLinkerPath(
12251247
self: Target,

src-self-hosted/libc_installation.zig

+5-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,11 @@ fn ccPrintFileName(
536536
}
537537

538538
/// 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+
540544
const standard_ld_path = try std.Target.current.getStandardDynamicLinkerPath(allocator);
541545
var standard_ld_path_resource: ?[:0]u8 = standard_ld_path; // Set to null to avoid freeing it.
542546
defer if (standard_ld_path_resource) |s| allocator.free(s);

0 commit comments

Comments
 (0)