diff options
| author | kcbanner <kcbanner@gmail.com> | 2022-11-09 00:50:29 -0500 |
|---|---|---|
| committer | kcbanner <kcbanner@gmail.com> | 2023-01-04 21:45:06 -0500 |
| commit | b97a68c529b5db15705f4d542d8ead616d27c880 (patch) | |
| tree | 4a88814249684640687fbde316fe0ad0bf9256d6 /src | |
| parent | 0471eea0e2cac49946449efe4698d5ac18c0dc0d (diff) | |
| download | zig-b97a68c529b5db15705f4d542d8ead616d27c880.tar.gz zig-b97a68c529b5db15705f4d542d8ead616d27c880.zip | |
windows: supporting changes for boostrapping via msvc
- add support for passing through .def files to the linker,
required for building libLTO.dll in LLVM
- fixup libcpp linking conditionals
- add option to skip linking zstd for use in bootstrapping (when
building against an LLVM with LLVM_ENABLE_ZSTD=OFF)
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 8 | ||||
| -rw-r--r-- | src/link.zig | 7 | ||||
| -rw-r--r-- | src/link/Coff/lld.zig | 4 | ||||
| -rw-r--r-- | src/main.zig | 7 |
4 files changed, 24 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index eeecf58751..98eb15c437 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -984,6 +984,7 @@ pub const InitOptions = struct { linker_dynamicbase: bool = false, linker_optimization: ?u8 = null, linker_compress_debug_sections: ?link.CompressDebugSections = null, + linker_module_definition_file: ?[]const u8 = null, major_subsystem_version: ?u32 = null, minor_subsystem_version: ?u32 = null, clang_passthrough_mode: bool = false, @@ -1815,6 +1816,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { .allow_shlib_undefined = options.linker_allow_shlib_undefined, .bind_global_refs_locally = options.linker_bind_global_refs_locally orelse false, .compress_debug_sections = options.linker_compress_debug_sections orelse .none, + .module_definition_file = options.linker_module_definition_file, .import_memory = options.linker_import_memory orelse false, .import_symbols = options.linker_import_symbols, .import_table = options.linker_import_table, @@ -4379,7 +4381,7 @@ pub fn addCCArgs( try argv.append("-fno-unwind-tables"); } }, - .shared_library, .ll, .bc, .unknown, .static_library, .object, .zig => {}, + .shared_library, .ll, .bc, .unknown, .static_library, .object, .def, .zig => {}, .assembly => { // The Clang assembler does not accept the list of CPU features like the // compiler frontend does. Therefore we must hard-code the -m flags for @@ -4524,6 +4526,7 @@ pub const FileExt = enum { object, static_library, zig, + def, unknown, pub fn clangSupportsDepFile(ext: FileExt) bool { @@ -4537,6 +4540,7 @@ pub const FileExt = enum { .object, .static_library, .zig, + .def, .unknown, => false, }; @@ -4629,6 +4633,8 @@ pub fn classifyFileExt(filename: []const u8) FileExt { return .object; } else if (mem.endsWith(u8, filename, ".cu")) { return .cu; + } else if (mem.endsWith(u8, filename, ".def")) { + return .def; } else { return .unknown; } diff --git a/src/link.zig b/src/link.zig index 0a526db0de..410d1232af 100644 --- a/src/link.zig +++ b/src/link.zig @@ -219,6 +219,13 @@ pub const Options = struct { /// (Darwin) remove dylibs that are unreachable by the entry point or exported symbols dead_strip_dylibs: bool = false, + /// (Windows) PDB source path prefix to instruct the linker how to resolve relative + /// paths when consolidating CodeView streams into a single PDB file. + pdb_source_path: ?[]const u8 = null, + + /// (Windows) .def file to specify when linking + module_definition_file: ?[] const u8 = null, + pub fn effectiveOutputMode(options: Options) std.builtin.OutputMode { return if (options.use_lld) .Obj else options.output_mode; } diff --git a/src/link/Coff/lld.zig b/src/link/Coff/lld.zig index dfa56527bf..367dde3e88 100644 --- a/src/link/Coff/lld.zig +++ b/src/link/Coff/lld.zig @@ -260,6 +260,10 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod try argv.append(p); } + if (self.base.options.module_definition_file) |def| { + try argv.append(try allocPrint(arena, "-DEF:{s}", .{ def })); + } + const resolved_subsystem: ?std.Target.SubSystem = blk: { if (self.base.options.subsystem) |explicit| break :blk explicit; switch (target.os.tag) { diff --git a/src/main.zig b/src/main.zig index 421164de1c..d718f299c7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -742,6 +742,7 @@ fn buildOutputType( var linker_nxcompat = false; var linker_dynamicbase = false; var linker_optimization: ?u8 = null; + var linker_module_definition_file: ?[]const u8 = null; var test_evented_io = false; var test_no_exec = false; var entry: ?[]const u8 = null; @@ -1404,7 +1405,7 @@ fn buildOutputType( root_src_file = arg; } }, - .unknown => { + .def, .unknown => { fatal("unrecognized file extension of parameter '{s}'", .{arg}); }, } @@ -1478,6 +1479,9 @@ fn buildOutputType( .must_link = must_link, }); }, + .def => { + linker_module_definition_file = it.only_arg; + }, .zig => { if (root_src_file) |other| { fatal("found another zig file '{s}' after root source file '{s}'", .{ it.only_arg, other }); @@ -3015,6 +3019,7 @@ fn buildOutputType( .linker_dynamicbase = linker_dynamicbase, .linker_optimization = linker_optimization, .linker_compress_debug_sections = linker_compress_debug_sections, + .linker_module_definition_file = linker_module_definition_file, .major_subsystem_version = major_subsystem_version, .minor_subsystem_version = minor_subsystem_version, .link_eh_frame_hdr = link_eh_frame_hdr, |
