authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-11 21:23:12-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:19-07:00
logb5e2af49a0469c7f96ebabb8e796585d53382e7d
treec59019f44d7e871a3771c4d38a86e4919f5e6c79
parent6ec6c077957c8d1f96d83299b35f6c84a34b07e6

linker: update link_mode references


5 files changed, 10 insertions(+), 10 deletions(-)

src/link.zig+1-1
...@@ -1098,7 +1098,7 @@ pub const File = struct {...@@ -1098,7 +1098,7 @@ pub const File = struct {
1098 }1098 }
10991099
1100 pub fn isStatic(self: File) bool {1100 pub fn isStatic(self: File) bool {
1101 return self.base.options.link_mode == .Static;1101 return self.base.comp.config.link_mode == .Static;
1102 }1102 }
11031103
1104 pub fn isObject(self: File) bool {1104 pub fn isObject(self: File) bool {
src/link/Coff.zig+1-1
...@@ -2218,7 +2218,7 @@ fn writeHeader(self: *Coff) !void {...@@ -2218,7 +2218,7 @@ fn writeHeader(self: *Coff) !void {
2218 .p32 => flags.@"32BIT_MACHINE" = 1,2218 .p32 => flags.@"32BIT_MACHINE" = 1,
2219 .p64 => flags.LARGE_ADDRESS_AWARE = 1,2219 .p64 => flags.LARGE_ADDRESS_AWARE = 1,
2220 }2220 }
2221 if (self.base.comp.config.output_mode == .Lib and self.base.options.link_mode == .Dynamic) {2221 if (self.base.comp.config.output_mode == .Lib and self.base.comp.config.link_mode == .Dynamic) {
2222 flags.DLL = 1;2222 flags.DLL = 1;
2223 }2223 }
22242224
src/link/Coff/lld.zig+3-3
...@@ -46,7 +46,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -46,7 +46,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
46 defer sub_prog_node.end();46 defer sub_prog_node.end();
4747
48 const is_lib = self.base.comp.config.output_mode == .Lib;48 const is_lib = self.base.comp.config.output_mode == .Lib;
49 const is_dyn_lib = self.base.options.link_mode == .Dynamic and is_lib;49 const is_dyn_lib = self.base.comp.config.link_mode == .Dynamic and is_lib;
50 const is_exe_or_dyn_lib = is_dyn_lib or self.base.comp.config.output_mode == .Exe;50 const is_exe_or_dyn_lib = is_dyn_lib or self.base.comp.config.output_mode == .Exe;
51 const link_in_crt = self.base.options.link_libc and is_exe_or_dyn_lib;51 const link_in_crt = self.base.options.link_libc and is_exe_or_dyn_lib;
52 const target = self.base.options.target;52 const target = self.base.options.target;
...@@ -423,7 +423,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -423,7 +423,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
423 }423 }
424 }424 }
425 } else {425 } else {
426 const lib_str = switch (self.base.options.link_mode) {426 const lib_str = switch (self.base.comp.config.link_mode) {
427 .Dynamic => "",427 .Dynamic => "",
428 .Static => "lib",428 .Static => "lib",
429 };429 };
...@@ -431,7 +431,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -431,7 +431,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
431 .Debug => "d",431 .Debug => "d",
432 else => "",432 else => "",
433 };433 };
434 switch (self.base.options.link_mode) {434 switch (self.base.comp.config.link_mode) {
435 .Static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})),435 .Static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})),
436 .Dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})),436 .Dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})),
437 }437 }
src/link/MachO.zig+3-3
...@@ -320,7 +320,7 @@ pub fn flush(self: *MachO, comp: *Compilation, prog_node: *std.Progress.Node) li...@@ -320,7 +320,7 @@ pub fn flush(self: *MachO, comp: *Compilation, prog_node: *std.Progress.Node) li
320 const gpa = self.base.comp.gpa;320 const gpa = self.base.comp.gpa;
321 const output_mode = self.base.comp.config.output_mode;321 const output_mode = self.base.comp.config.output_mode;
322322
323 if (output_mode == .Lib and self.base.options.link_mode == .Static) {323 if (output_mode == .Lib and self.base.comp.config.link_mode == .Static) {
324 if (build_options.have_llvm) {324 if (build_options.have_llvm) {
325 return self.base.linkAsArchive(comp, prog_node);325 return self.base.linkAsArchive(comp, prog_node);
326 } else {326 } else {
...@@ -608,7 +608,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No...@@ -608,7 +608,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
608 .stacksize = self.base.stack_size,608 .stacksize = self.base.stack_size,
609 });609 });
610 },610 },
611 .Lib => if (self.base.options.link_mode == .Dynamic) {611 .Lib => if (self.base.comp.config.link_mode == .Dynamic) {
612 try load_commands.writeDylibIdLC(gpa, &self.base.options, lc_writer);612 try load_commands.writeDylibIdLC(gpa, &self.base.options, lc_writer);
613 },613 },
614 else => {},614 else => {},
...@@ -1910,7 +1910,7 @@ fn resolveSymbolsInDylibs(self: *MachO) !void {...@@ -1910,7 +1910,7 @@ fn resolveSymbolsInDylibs(self: *MachO) !void {
1910fn resolveSymbolsAtLoading(self: *MachO) !void {1910fn resolveSymbolsAtLoading(self: *MachO) !void {
1911 const output_mode = self.base.comp.config.output_mode;1911 const output_mode = self.base.comp.config.output_mode;
1912 const is_lib = output_mode == .Lib;1912 const is_lib = output_mode == .Lib;
1913 const is_dyn_lib = self.base.options.link_mode == .Dynamic and is_lib;1913 const is_dyn_lib = self.base.comp.config.link_mode == .Dynamic and is_lib;
1914 const allow_undef = is_dyn_lib and self.base.allow_shlib_undefined;1914 const allow_undef = is_dyn_lib and self.base.allow_shlib_undefined;
19151915
1916 var next_sym: usize = 0;1916 var next_sym: usize = 0;
src/link/Wasm.zig+2-2
...@@ -4750,7 +4750,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !...@@ -4750,7 +4750,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
4750 try argv.append("--allow-undefined");4750 try argv.append("--allow-undefined");
4751 }4751 }
47524752
4753 if (wasm.base.comp.config.output_mode == .Lib and wasm.base.options.link_mode == .Dynamic) {4753 if (wasm.base.comp.config.output_mode == .Lib and wasm.base.comp.config.link_mode == .Dynamic) {
4754 try argv.append("--shared");4754 try argv.append("--shared");
4755 }4755 }
4756 if (wasm.base.options.pie) {4756 if (wasm.base.options.pie) {
...@@ -4770,7 +4770,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !...@@ -4770,7 +4770,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
47704770
4771 if (target.os.tag == .wasi) {4771 if (target.os.tag == .wasi) {
4772 const is_exe_or_dyn_lib = wasm.base.comp.config.output_mode == .Exe or4772 const is_exe_or_dyn_lib = wasm.base.comp.config.output_mode == .Exe or
4773 (wasm.base.comp.config.output_mode == .Lib and wasm.base.options.link_mode == .Dynamic);4773 (wasm.base.comp.config.output_mode == .Lib and wasm.base.comp.config.link_mode == .Dynamic);
4774 if (is_exe_or_dyn_lib) {4774 if (is_exe_or_dyn_lib) {
4775 for (wasm.wasi_emulated_libs) |crt_file| {4775 for (wasm.wasi_emulated_libs) |crt_file| {
4776 try argv.append(try comp.get_libc_crt_file(4776 try argv.append(try comp.get_libc_crt_file(