zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 659e043a34e1b5b24cb83ce5569d7ee295eb27ad (tree)
parent 3a0b76b855b243867d84d8bfa5de550143bed2ae
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed, 27 Dec 2023 23:47:31 -0700

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

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

Diffstat:
Msrc/Compilation.zig | 14++++++++++----
Msrc/mingw.zig | 2+-
2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/Compilation.zig b/src/Compilation.zig @@ -3580,6 +3580,9 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v }; }, .windows_import_lib => |index| { + if (build_options.only_c) + @panic("building import libs not included in core functionality"); + const named_frame = tracy.namedFrame("windows_import_lib"); defer named_frame.end(); @@ -6391,15 +6394,18 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void { // If we haven't seen this library yet and we're targeting Windows, we need // to queue up a work item to produce the DLL import library for this. const gop = try comp.system_libs.getOrPut(comp.gpa, lib_name); - if (!gop.found_existing and comp.getTarget().os.tag == .windows) { + if (!gop.found_existing) { gop.value_ptr.* = .{ .needed = true, .weak = false, .path = null, }; - try comp.work_queue.writeItem(.{ - .windows_import_lib = comp.system_libs.count() - 1, - }); + const target = comp.root_mod.resolved_target.result; + if (target.os.tag == .windows and target.ofmt != .c) { + try comp.work_queue.writeItem(.{ + .windows_import_lib = comp.system_libs.count() - 1, + }); + } } } diff --git a/src/mingw.zig b/src/mingw.zig @@ -287,7 +287,7 @@ fn add_cc_args( } pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { - if (build_options.only_c) @panic("building import libs not included in core functionality"); + if (build_options.only_c) @compileError("building import libs not included in core functionality"); var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); defer arena_allocator.deinit(); const arena = arena_allocator.allocator();