Commit b5e2af49a0

Andrew Kelley <andrew@ziglang.org>
2023-12-12 05:23:12
linker: update link_mode references
1 parent 6ec6c07
Changed files (5)
src/link/Coff/lld.zig
@@ -46,7 +46,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
     defer sub_prog_node.end();
 
     const is_lib = self.base.comp.config.output_mode == .Lib;
-    const is_dyn_lib = self.base.options.link_mode == .Dynamic and is_lib;
+    const is_dyn_lib = self.base.comp.config.link_mode == .Dynamic and is_lib;
     const is_exe_or_dyn_lib = is_dyn_lib or self.base.comp.config.output_mode == .Exe;
     const link_in_crt = self.base.options.link_libc and is_exe_or_dyn_lib;
     const target = self.base.options.target;
@@ -423,7 +423,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
                             }
                         }
                     } else {
-                        const lib_str = switch (self.base.options.link_mode) {
+                        const lib_str = switch (self.base.comp.config.link_mode) {
                             .Dynamic => "",
                             .Static => "lib",
                         };
@@ -431,7 +431,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
                             .Debug => "d",
                             else => "",
                         };
-                        switch (self.base.options.link_mode) {
+                        switch (self.base.comp.config.link_mode) {
                             .Static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})),
                             .Dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})),
                         }
src/link/Coff.zig
@@ -2218,7 +2218,7 @@ fn writeHeader(self: *Coff) !void {
         .p32 => flags.@"32BIT_MACHINE" = 1,
         .p64 => flags.LARGE_ADDRESS_AWARE = 1,
     }
-    if (self.base.comp.config.output_mode == .Lib and self.base.options.link_mode == .Dynamic) {
+    if (self.base.comp.config.output_mode == .Lib and self.base.comp.config.link_mode == .Dynamic) {
         flags.DLL = 1;
     }
 
src/link/MachO.zig
@@ -320,7 +320,7 @@ pub fn flush(self: *MachO, comp: *Compilation, prog_node: *std.Progress.Node) li
     const gpa = self.base.comp.gpa;
     const output_mode = self.base.comp.config.output_mode;
 
-    if (output_mode == .Lib and self.base.options.link_mode == .Static) {
+    if (output_mode == .Lib and self.base.comp.config.link_mode == .Static) {
         if (build_options.have_llvm) {
             return self.base.linkAsArchive(comp, prog_node);
         } else {
@@ -608,7 +608,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
                 .stacksize = self.base.stack_size,
             });
         },
-        .Lib => if (self.base.options.link_mode == .Dynamic) {
+        .Lib => if (self.base.comp.config.link_mode == .Dynamic) {
             try load_commands.writeDylibIdLC(gpa, &self.base.options, lc_writer);
         },
         else => {},
@@ -1910,7 +1910,7 @@ fn resolveSymbolsInDylibs(self: *MachO) !void {
 fn resolveSymbolsAtLoading(self: *MachO) !void {
     const output_mode = self.base.comp.config.output_mode;
     const is_lib = output_mode == .Lib;
-    const is_dyn_lib = self.base.options.link_mode == .Dynamic and is_lib;
+    const is_dyn_lib = self.base.comp.config.link_mode == .Dynamic and is_lib;
     const allow_undef = is_dyn_lib and self.base.allow_shlib_undefined;
 
     var next_sym: usize = 0;
src/link/Wasm.zig
@@ -4750,7 +4750,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
             try argv.append("--allow-undefined");
         }
 
-        if (wasm.base.comp.config.output_mode == .Lib and wasm.base.options.link_mode == .Dynamic) {
+        if (wasm.base.comp.config.output_mode == .Lib and wasm.base.comp.config.link_mode == .Dynamic) {
             try argv.append("--shared");
         }
         if (wasm.base.options.pie) {
@@ -4770,7 +4770,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
 
         if (target.os.tag == .wasi) {
             const is_exe_or_dyn_lib = wasm.base.comp.config.output_mode == .Exe or
-                (wasm.base.comp.config.output_mode == .Lib and wasm.base.options.link_mode == .Dynamic);
+                (wasm.base.comp.config.output_mode == .Lib and wasm.base.comp.config.link_mode == .Dynamic);
             if (is_exe_or_dyn_lib) {
                 for (wasm.wasi_emulated_libs) |crt_file| {
                     try argv.append(try comp.get_libc_crt_file(
src/link.zig
@@ -1098,7 +1098,7 @@ pub const File = struct {
     }
 
     pub fn isStatic(self: File) bool {
-        return self.base.options.link_mode == .Static;
+        return self.base.comp.config.link_mode == .Static;
     }
 
     pub fn isObject(self: File) bool {