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

Fixes "building import libs not included in core functionality" when
bootstrapping on Windows.
This commit is contained in:
Andrew Kelley 2023-12-27 23:47:31 -07:00
parent 3a0b76b855
commit 659e043a34
2 changed files with 11 additions and 5 deletions

View File

@ -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,
});
}
}
}

View File

@ -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();