diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-12-16 15:22:31 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-01 17:51:20 -0700 |
| commit | f2564318385ea90b08af044ae32ddef26e6346bd (patch) | |
| tree | acb36d3268bace51f780a872f40b04da092591de /src/link | |
| parent | 57afdfc8fae667e69850650ebb8606805d0d2272 (diff) | |
| download | zig-f2564318385ea90b08af044ae32ddef26e6346bd.tar.gz zig-f2564318385ea90b08af044ae32ddef26e6346bd.zip | |
fix compilation errors when enabling llvm
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/Coff.zig | 4 | ||||
| -rw-r--r-- | src/link/Coff/lld.zig | 23 | ||||
| -rw-r--r-- | src/link/Elf.zig | 20 |
3 files changed, 23 insertions, 24 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 98c649ca84..b6a3979122 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -18,6 +18,8 @@ major_subsystem_version: u16, minor_subsystem_version: u16, lib_dirs: []const []const u8, entry_addr: ?u32, +module_definition_file: ?[]const u8, +pdb_out_path: ?[]const u8, ptr_width: PtrWidth, page_size: u32, @@ -425,6 +427,8 @@ pub fn createEmpty( .lib_dirs = options.lib_dirs, .entry_addr = math.cast(u32, options.entry_addr orelse 0) orelse return error.EntryAddressTooBig, + .module_definition_file = options.module_definition_file, + .pdb_out_path = options.pdb_out_path, }; const use_llvm = comp.config.use_llvm; diff --git a/src/link/Coff/lld.zig b/src/link/Coff/lld.zig index a94644a41e..39e6d5288d 100644 --- a/src/link/Coff/lld.zig +++ b/src/link/Coff/lld.zig @@ -82,7 +82,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod try man.addOptionalFile(module_obj_path); man.hash.addOptionalBytes(comp.config.entry); man.hash.add(self.base.stack_size); - man.hash.addOptional(self.image_base); + man.hash.add(self.image_base); man.hash.addListOfBytes(self.lib_dirs); man.hash.add(comp.skip_linker_dependencies); if (comp.config.link_libc) { @@ -102,10 +102,10 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod man.hash.add(self.tsaware); man.hash.add(self.nxcompat); man.hash.add(self.dynamicbase); - man.hash.addOptional(self.base.allow_shlib_undefined); + man.hash.add(self.base.allow_shlib_undefined); // strip does not need to go into the linker hash because it is part of the hash namespace - man.hash.addOptional(self.major_subsystem_version); - man.hash.addOptional(self.minor_subsystem_version); + man.hash.add(self.major_subsystem_version); + man.hash.add(self.minor_subsystem_version); man.hash.addOptional(comp.version); try man.addOptionalFile(self.module_definition_file); @@ -237,7 +237,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod try argv.append(try allocPrint(arena, "-OUT:{s}", .{full_out_path})); - if (self.implib_emit) |emit| { + if (comp.implib_emit) |emit| { const implib_out_path = try emit.directory.join(arena, &[_][]const u8{emit.sub_path}); try argv.append(try allocPrint(arena, "-IMPLIB:{s}", .{implib_out_path})); } @@ -310,16 +310,9 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod const Mode = enum { uefi, win32 }; const mode: Mode = mode: { if (resolved_subsystem) |subsystem| { - const subsystem_suffix = ss: { - if (self.major_subsystem_version) |major| { - if (self.minor_subsystem_version) |minor| { - break :ss try allocPrint(arena, ",{d}.{d}", .{ major, minor }); - } else { - break :ss try allocPrint(arena, ",{d}", .{major}); - } - } - break :ss ""; - }; + const subsystem_suffix = try allocPrint(arena, ",{d}.{d}", .{ + self.major_subsystem_version, self.minor_subsystem_version, + }); switch (subsystem) { .Console => { diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 52e08af665..e5e5c98ec0 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -23,6 +23,8 @@ soname: ?[]const u8, bind_global_refs_locally: bool, linker_script: ?[]const u8, version_script: ?[]const u8, +print_icf_sections: bool, +print_map: bool, ptr_width: PtrWidth, @@ -307,6 +309,8 @@ pub fn createEmpty( .bind_global_refs_locally = options.bind_global_refs_locally, .linker_script = options.linker_script, .version_script = options.version_script, + .print_icf_sections = options.print_icf_sections, + .print_map = options.print_map, }; if (use_llvm and comp.config.have_zcu) { self.llvm_object = try LlvmObject.create(arena, comp); @@ -1294,12 +1298,9 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node // Look for entry address in objects if not set by the incremental compiler. if (self.entry_index == null) { - const entry: ?[]const u8 = entry: { - if (comp.config.entry) |entry| break :entry entry; - if (!self.base.isDynLib()) break :entry "_start"; - break :entry null; - }; - self.entry_index = if (entry) |name| self.globalByName(name) else null; + if (comp.config.entry) |name| { + self.entry_index = self.globalByName(name); + } } if (self.base.gc_sections) { @@ -2420,7 +2421,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v // We can skip hashing libc and libc++ components that we are in charge of building from Zig // installation sources because they are always a product of the compiler version + target information. man.hash.addOptionalBytes(comp.config.entry); - man.hash.addOptional(self.image_base); + man.hash.add(self.image_base); man.hash.add(self.base.gc_sections); man.hash.addOptional(self.sort_section); man.hash.add(self.eh_frame_hdr); @@ -5896,7 +5897,7 @@ pub fn addSymbol(self: *Elf) !Symbol.Index { break :blk index; } else { log.debug(" (allocating symbol index {d})", .{self.symbols.items.len}); - const index = @as(Symbol.Index, @intCast(self.symbols.items.len)); + const index: Symbol.Index = @intCast(self.symbols.items.len); _ = self.symbols.addOneAssumeCapacity(); break :blk index; } @@ -5961,6 +5962,7 @@ pub fn getOrPutGlobal(self: *Elf, name: []const u8) !GetOrPutGlobalResult { const gop = try self.resolver.getOrPut(gpa, name_off); if (!gop.found_existing) { const index = try self.addSymbol(); + log.debug("added symbol '{s}' at index {d}", .{ name, index }); const global = self.symbol(index); global.name_offset = name_off; global.flags.global = true; @@ -5996,7 +5998,7 @@ pub fn getOrCreateComdatGroupOwner(self: *Elf, name: [:0]const u8) !GetOrCreateC const off = try self.strings.insert(gpa, name); const gop = try self.comdat_groups_table.getOrPut(gpa, off); if (!gop.found_existing) { - const index = @as(ComdatGroupOwner.Index, @intCast(self.comdat_groups_owners.items.len)); + const index: ComdatGroupOwner.Index = @intCast(self.comdat_groups_owners.items.len); const owner = try self.comdat_groups_owners.addOne(gpa); owner.* = .{}; gop.value_ptr.* = index; |
