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...@@ -3580,6 +3580,9 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
3580 };3580 };
3581 },3581 },
3582 .windows_import_lib => |index| {3582 .windows_import_lib => |index| {
3583 if (build_options.only_c)
3584 @panic("building import libs not included in core functionality");
3585
3583 const named_frame = tracy.namedFrame("windows_import_lib");3586 const named_frame = tracy.namedFrame("windows_import_lib");
3584 defer named_frame.end();3587 defer named_frame.end();
35853588
...@@ -6391,15 +6394,18 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {...@@ -6391,15 +6394,18 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {
6391 // If we haven't seen this library yet and we're targeting Windows, we need6394 // If we haven't seen this library yet and we're targeting Windows, we need
6392 // to queue up a work item to produce the DLL import library for this.6395 // to queue up a work item to produce the DLL import library for this.
6393 const gop = try comp.system_libs.getOrPut(comp.gpa, lib_name);6396 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) {
6395 gop.value_ptr.* = .{6398 gop.value_ptr.* = .{
6396 .needed = true,6399 .needed = true,
6397 .weak = false,6400 .weak = false,
6398 .path = null,6401 .path = null,
6399 };6402 };
6400 try comp.work_queue.writeItem(.{6403 const target = comp.root_mod.resolved_target.result;
6401 .windows_import_lib = comp.system_libs.count() - 1,6404 if (target.os.tag == .windows and target.ofmt != .c) {
6402 });6405 try comp.work_queue.writeItem(.{
6406 .windows_import_lib = comp.system_libs.count() - 1,
6407 });
6408 }
6403 }6409 }
6404}6410}
64056411
src/mingw.zig+1-1
...@@ -287,7 +287,7 @@ fn add_cc_args(...@@ -287,7 +287,7 @@ fn add_cc_args(
287}287}
288288
289pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {289pub 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");
291 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);291 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
292 defer arena_allocator.deinit();292 defer arena_allocator.deinit();
293 const arena = arena_allocator.allocator();293 const arena = arena_allocator.allocator();