From 0da7c4b0c8a2a2fe0862f7757bc5976342d51dc8 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 29 Sep 2020 14:46:40 -0700 Subject: improve stage2 COFF LLD linking * change some {} to be {s} to gain type safety * fix libraries being libfoo.lib instead of foo.lib for COFF * when linking mingw-w64, add the "always link" libs so that we generate DLL import .lib files for them as the linker code relies on. * COFF LLD linker does not support -r so we do a file copy as an alternative to the -r thing that ELF linking does. I will file an issue for the corresponding TODO upon merging this branch, to look into an optimization that possibly elides this copy when the source and destination are both cache directories. * add a CLI error message when trying to link multiple objects into one and using COFF object format. --- src/Compilation.zig | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index c3cda196de..9cc2c3aa5c 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -879,6 +879,11 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { try comp.work_queue.ensureUnusedCapacity(static_lib_jobs.len + 1); comp.work_queue.writeAssumeCapacity(&static_lib_jobs); comp.work_queue.writeItemAssumeCapacity(crt_job); + + // When linking mingw-w64 there are some import libs we always need. + for (mingw.always_link_libs) |name| { + try comp.bin_file.options.system_libs.put(comp.gpa, name, .{}); + } } // Generate Windows import libs. if (comp.getTarget().os.tag == .windows) { -- cgit v1.2.3