aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2025-06-11 14:41:42 +0200
committerAlex Rønne Petersen <alex@alexrp.com>2025-07-06 01:00:18 +0200
commitb461d07a5464aec86c533434dab0b58edfffb331 (patch)
treed3e19fc63623fb765ff08757c069e27d915ef66e /src/main.zig
parent044ccf4138f8b027be01c95ad759d5302e2ff39d (diff)
downloadzig-b461d07a5464aec86c533434dab0b58edfffb331.tar.gz
zig-b461d07a5464aec86c533434dab0b58edfffb331.zip
Sema: Stop adding Windows implib link inputs for `extern "..."` syntax.
Closes #23971.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main.zig b/src/main.zig
index e974621e5e..0456122405 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -306,6 +306,7 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
return jitCmd(gpa, arena, cmd_args, .{
.cmd_name = "resinator",
.root_src_path = "resinator/main.zig",
+ .windows_libs = &.{"advapi32"},
.depend_on_aro = true,
.prepend_zig_lib_dir_path = true,
.server = use_server,
@@ -3631,7 +3632,6 @@ fn buildOutputType(
} else if (target.os.tag == .windows) {
try test_exec_args.appendSlice(arena, &.{
"--subsystem", "console",
- "-lkernel32", "-lntdll",
});
}
@@ -3845,7 +3845,8 @@ fn createModule(
.only_compiler_rt => continue,
}
- if (target.isMinGW()) {
+ // We currently prefer import libraries provided by MinGW-w64 even for MSVC.
+ if (target.os.tag == .windows) {
const exists = mingw.libExists(arena, target, create_module.dirs.zig_lib, lib_name) catch |err| {
fatal("failed to check zig installation for DLL import libs: {s}", .{
@errorName(err),
@@ -5221,6 +5222,12 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
try root_mod.deps.put(arena, "@build", build_mod);
+ var windows_libs: std.StringArrayHashMapUnmanaged(void) = .empty;
+
+ if (resolved_target.result.os.tag == .windows) {
+ try windows_libs.put(arena, "advapi32", {});
+ }
+
const comp = Compilation.create(gpa, arena, .{
.dirs = dirs,
.root_name = "build",
@@ -5242,6 +5249,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
.cache_mode = .whole,
.reference_trace = reference_trace,
.debug_compile_errors = debug_compile_errors,
+ .windows_lib_names = windows_libs.keys(),
}) catch |err| {
fatal("unable to create compilation: {s}", .{@errorName(err)});
};
@@ -5345,6 +5353,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
const JitCmdOptions = struct {
cmd_name: []const u8,
root_src_path: []const u8,
+ windows_libs: []const []const u8 = &.{},
prepend_zig_lib_dir_path: bool = false,
prepend_global_cache_path: bool = false,
prepend_zig_exe_path: bool = false,
@@ -5461,6 +5470,13 @@ fn jitCmd(
try root_mod.deps.put(arena, "aro", aro_mod);
}
+ var windows_libs: std.StringArrayHashMapUnmanaged(void) = .empty;
+
+ if (resolved_target.result.os.tag == .windows) {
+ try windows_libs.ensureUnusedCapacity(arena, options.windows_libs.len);
+ for (options.windows_libs) |lib| windows_libs.putAssumeCapacity(lib, {});
+ }
+
const comp = Compilation.create(gpa, arena, .{
.dirs = dirs,
.root_name = options.cmd_name,
@@ -5471,6 +5487,7 @@ fn jitCmd(
.self_exe_path = self_exe_path,
.thread_pool = &thread_pool,
.cache_mode = .whole,
+ .windows_lib_names = windows_libs.keys(),
}) catch |err| {
fatal("unable to create compilation: {s}", .{@errorName(err)});
};