diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-09-28 19:20:58 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-09-28 19:20:58 -0700 |
| commit | ada19c498d6cb52dd8f0de71d42baf845cfadc21 (patch) | |
| tree | 0f1d1d3298d0dc619f9decb43dd381defbeb713d /src/Compilation.zig | |
| parent | 412a2f966e18aa792089ac1f41482222d7f2434f (diff) | |
| download | zig-ada19c498d6cb52dd8f0de71d42baf845cfadc21.tar.gz zig-ada19c498d6cb52dd8f0de71d42baf845cfadc21.zip | |
stage2: building DLL import lib files
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 19 |
1 files changed, 19 insertions, 0 deletions
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. |
