From ada19c498d6cb52dd8f0de71d42baf845cfadc21 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 28 Sep 2020 19:20:58 -0700 Subject: stage2: building DLL import lib files --- src/Compilation.zig | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 00eb8c374d..3095ffab81 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -168,6 +168,9 @@ const Job = union(enum) { generate_builtin_zig: void, /// Use stage1 C++ code to compile zig code into an object file. stage1_module: void, + + /// The value is the index into `link.File.Options.system_libs`. + windows_import_lib: usize, }; pub const CObject = struct { @@ -868,6 +871,15 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { comp.work_queue.writeAssumeCapacity(&static_lib_jobs); comp.work_queue.writeItemAssumeCapacity(crt_job); } + // Generate Windows import libs. + if (comp.getTarget().os.tag == .windows) { + const count = comp.bin_file.options.system_libs.count(); + try comp.work_queue.ensureUnusedCapacity(count); + var i: usize = 0; + while (i < count) : (i += 1) { + comp.work_queue.writeItemAssumeCapacity(.{ .windows_import_lib = i }); + } + } if (comp.wantBuildLibUnwindFromSource()) { try comp.work_queue.writeItem(.{ .libunwind = {} }); } @@ -1233,6 +1245,13 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void { fatal("unable to build mingw-w64 CRT file: {}", .{@errorName(err)}); }; }, + .windows_import_lib => |index| { + const link_lib = self.bin_file.options.system_libs.items()[index].key; + mingw.buildImportLib(self, link_lib) catch |err| { + // TODO Expose this as a normal compile error rather than crashing here. + fatal("unable to generate DLL import .lib file: {}", .{@errorName(err)}); + }; + }, .libunwind => { libunwind.buildStaticLib(self) catch |err| { // TODO Expose this as a normal compile error rather than crashing here. -- cgit v1.2.3