authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-27 23:47:31-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 19:49:08-07:00
log659e043a34e1b5b24cb83ce5569d7ee295eb27ad
tree232676e649d91a4ec37b92fb0b2faeb79c19b47a
parent3a0b76b855b243867d84d8bfa5de550143bed2ae

Compilation: don't add importlib jobs when outputting C code

Fixes "building import libs not included in core functionality" when bootstrapping on Windows.

2 files changed, 11 insertions(+), 5 deletions(-)

src/Compilation.zig+10-4
......@@ -3580,6 +3580,9 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
35803580 };
35813581 },
35823582 .windows_import_lib => |index| {
3583 if (build_options.only_c)
3584 @panic("building import libs not included in core functionality");
3585
35833586 const named_frame = tracy.namedFrame("windows_import_lib");
35843587 defer named_frame.end();
35853588
......@@ -6391,15 +6394,18 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {
63916394 // If we haven't seen this library yet and we're targeting Windows, we need
63926395 // to queue up a work item to produce the DLL import library for this.
63936396 const gop = try comp.system_libs.getOrPut(comp.gpa, lib_name);
6394 if (!gop.found_existing and comp.getTarget().os.tag == .windows) {
6397 if (!gop.found_existing) {
63956398 gop.value_ptr.* = .{
63966399 .needed = true,
63976400 .weak = false,
63986401 .path = null,
63996402 };
6400 try comp.work_queue.writeItem(.{
6401 .windows_import_lib = comp.system_libs.count() - 1,
6402 });
6403 const target = comp.root_mod.resolved_target.result;
6404 if (target.os.tag == .windows and target.ofmt != .c) {
6405 try comp.work_queue.writeItem(.{
6406 .windows_import_lib = comp.system_libs.count() - 1,
6407 });
6408 }
64036409 }
64046410}
64056411
src/mingw.zig+1-1
......@@ -287,7 +287,7 @@ fn add_cc_args(
287287}
288288
289289pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
290 if (build_options.only_c) @panic("building import libs not included in core functionality");
290 if (build_options.only_c) @compileError("building import libs not included in core functionality");
291291 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
292292 defer arena_allocator.deinit();
293293 const arena = arena_allocator.allocator();