authorgravatar for tristan.ross@midstall.comTristan Ross <tristan.ross@midstall.com> 2024-02-18 20:34:32-08:00
committergravatar for tristan.ross@midstall.comTristan Ross <tristan.ross@midstall.com> 2024-03-11 07:09:10-07:00
log9d70d614ae33133f3786ec056b8660476ff49f53
tree61c46c488ae72d9ea9e96f25b661dc8d374abe5f
parent099f3c4039d5702b073639ef8b55881973b71c80
signaturelock-open Commit is signed but in an unrecognized format.

std.builtin: make link mode fields lowercase


35 files changed, 159 insertions(+), 164 deletions(-)

build.zig+1-1
...@@ -855,7 +855,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {...@@ -855,7 +855,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {
855}855}
856856
857const CMakeConfig = struct {857const CMakeConfig = struct {
858 llvm_linkage: std.Build.Step.Compile.Linkage,858 llvm_linkage: std.builtin.LinkMode,
859 cmake_binary_dir: []const u8,859 cmake_binary_dir: []const u8,
860 cmake_prefix_path: []const u8,860 cmake_prefix_path: []const u8,
861 cmake_static_library_prefix: []const u8,861 cmake_static_library_prefix: []const u8,
lib/c.zig+10-10
...@@ -26,7 +26,7 @@ const is_freestanding = switch (native_os) {...@@ -26,7 +26,7 @@ const is_freestanding = switch (native_os) {
2626
27comptime {27comptime {
28 if (is_freestanding and is_wasm and builtin.link_libc) {28 if (is_freestanding and is_wasm and builtin.link_libc) {
29 @export(wasm_start, .{ .name = "_start", .linkage = .Strong });29 @export(wasm_start, .{ .name = "_start", .linkage = .strong });
30 }30 }
3131
32 if (native_os == .linux) {32 if (native_os == .linux) {
...@@ -34,16 +34,16 @@ comptime {...@@ -34,16 +34,16 @@ comptime {
34 }34 }
3535
36 if (builtin.link_libc) {36 if (builtin.link_libc) {
37 @export(strcmp, .{ .name = "strcmp", .linkage = .Strong });37 @export(strcmp, .{ .name = "strcmp", .linkage = .strong });
38 @export(strncmp, .{ .name = "strncmp", .linkage = .Strong });38 @export(strncmp, .{ .name = "strncmp", .linkage = .strong });
39 @export(strerror, .{ .name = "strerror", .linkage = .Strong });39 @export(strerror, .{ .name = "strerror", .linkage = .strong });
40 @export(strlen, .{ .name = "strlen", .linkage = .Strong });40 @export(strlen, .{ .name = "strlen", .linkage = .strong });
41 @export(strcpy, .{ .name = "strcpy", .linkage = .Strong });41 @export(strcpy, .{ .name = "strcpy", .linkage = .strong });
42 @export(strncpy, .{ .name = "strncpy", .linkage = .Strong });42 @export(strncpy, .{ .name = "strncpy", .linkage = .strong });
43 @export(strcat, .{ .name = "strcat", .linkage = .Strong });43 @export(strcat, .{ .name = "strcat", .linkage = .strong });
44 @export(strncat, .{ .name = "strncat", .linkage = .Strong });44 @export(strncat, .{ .name = "strncat", .linkage = .strong });
45 } else if (is_msvc) {45 } else if (is_msvc) {
46 @export(_fltused, .{ .name = "_fltused", .linkage = .Strong });46 @export(_fltused, .{ .name = "_fltused", .linkage = .strong });
47 }47 }
48}48}
4949
lib/compiler_rt/os_version_check.zig+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1const std = @import("std");1const std = @import("std");
2const testing = std.testing;2const testing = std.testing;
3const builtin = @import("builtin");3const builtin = @import("builtin");
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak;
5const panic = @import("common.zig").panic;5const panic = @import("common.zig").panic;
66
7const have_availability_version_check = builtin.os.tag.isDarwin() and7const have_availability_version_check = builtin.os.tag.isDarwin() and
lib/compiler_rt/stack_probe.zig+2-2
...@@ -8,8 +8,8 @@ const is_test = builtin.is_test;...@@ -8,8 +8,8 @@ const is_test = builtin.is_test;
8const is_gnu = abi.isGnu();8const is_gnu = abi.isGnu();
9const is_mingw = os_tag == .windows and is_gnu;9const is_mingw = os_tag == .windows and is_gnu;
1010
11const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;11const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak;
12const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Strong;12const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .strong;
13pub const panic = @import("common.zig").panic;13pub const panic = @import("common.zig").panic;
1414
15comptime {15comptime {
lib/std/Build.zig+1-1
...@@ -645,7 +645,7 @@ pub const ExecutableOptions = struct {...@@ -645,7 +645,7 @@ pub const ExecutableOptions = struct {
645 version: ?std.SemanticVersion = null,645 version: ?std.SemanticVersion = null,
646 optimize: std.builtin.OptimizeMode = .Debug,646 optimize: std.builtin.OptimizeMode = .Debug,
647 code_model: std.builtin.CodeModel = .default,647 code_model: std.builtin.CodeModel = .default,
648 linkage: ?Step.Compile.Linkage = null,648 linkage: ?std.builtin.LinkMode = null,
649 max_rss: usize = 0,649 max_rss: usize = 0,
650 link_libc: ?bool = null,650 link_libc: ?bool = null,
651 single_threaded: ?bool = null,651 single_threaded: ?bool = null,
lib/std/Build/Module.zig+1-1
...@@ -414,7 +414,7 @@ pub const LinkSystemLibraryOptions = struct {...@@ -414,7 +414,7 @@ pub const LinkSystemLibraryOptions = struct {
414 needed: bool = false,414 needed: bool = false,
415 weak: bool = false,415 weak: bool = false,
416 use_pkg_config: SystemLib.UsePkgConfig = .yes,416 use_pkg_config: SystemLib.UsePkgConfig = .yes,
417 preferred_link_mode: std.builtin.LinkMode = .Dynamic,417 preferred_link_mode: std.builtin.LinkMode = .dynamic,
418 search_strategy: SystemLib.SearchStrategy = .paths_first,418 search_strategy: SystemLib.SearchStrategy = .paths_first,
419};419};
420420
lib/std/Build/Step/Compile.zig+13-18
...@@ -28,7 +28,7 @@ linker_script: ?LazyPath = null,...@@ -28,7 +28,7 @@ linker_script: ?LazyPath = null,
28version_script: ?LazyPath = null,28version_script: ?LazyPath = null,
29out_filename: []const u8,29out_filename: []const u8,
30out_lib_filename: []const u8,30out_lib_filename: []const u8,
31linkage: ?Linkage = null,31linkage: ?std.builtin.LinkMode = null,
32version: ?std.SemanticVersion,32version: ?std.SemanticVersion,
33kind: Kind,33kind: Kind,
34major_only_filename: ?[]const u8,34major_only_filename: ?[]const u8,
...@@ -223,7 +223,7 @@ pub const Options = struct {...@@ -223,7 +223,7 @@ pub const Options = struct {
223 name: []const u8,223 name: []const u8,
224 root_module: Module.CreateOptions,224 root_module: Module.CreateOptions,
225 kind: Kind,225 kind: Kind,
226 linkage: ?Linkage = null,226 linkage: ?std.builtin.LinkMode = null,
227 version: ?std.SemanticVersion = null,227 version: ?std.SemanticVersion = null,
228 max_rss: usize = 0,228 max_rss: usize = 0,
229 filters: []const []const u8 = &.{},229 filters: []const []const u8 = &.{},
...@@ -246,8 +246,6 @@ pub const Kind = enum {...@@ -246,8 +246,6 @@ pub const Kind = enum {
246 @"test",246 @"test",
247};247};
248248
249pub const Linkage = enum { dynamic, static };
250
251pub fn create(owner: *std.Build, options: Options) *Compile {249pub fn create(owner: *std.Build, options: Options) *Compile {
252 const name = owner.dupe(options.name);250 const name = owner.dupe(options.name);
253 if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {251 if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {
...@@ -283,10 +281,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {...@@ -283,10 +281,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
283 .obj => .Obj,281 .obj => .Obj,
284 .exe, .@"test" => .Exe,282 .exe, .@"test" => .Exe,
285 },283 },
286 .link_mode = if (options.linkage) |some| @as(std.builtin.LinkMode, switch (some) {284 .link_mode = options.linkage,
287 .dynamic => .Dynamic,
288 .static => .Static,
289 }) else null,
290 .version = options.version,285 .version = options.version,
291 }) catch @panic("OOM");286 }) catch @panic("OOM");
292287
...@@ -531,11 +526,11 @@ pub fn dependsOnSystemLibrary(self: *const Compile, name: []const u8) bool {...@@ -531,11 +526,11 @@ pub fn dependsOnSystemLibrary(self: *const Compile, name: []const u8) bool {
531}526}
532527
533pub fn isDynamicLibrary(self: *const Compile) bool {528pub fn isDynamicLibrary(self: *const Compile) bool {
534 return self.kind == .lib and self.linkage == Linkage.dynamic;529 return self.kind == .lib and self.linkage == .dynamic;
535}530}
536531
537pub fn isStaticLibrary(self: *const Compile) bool {532pub fn isStaticLibrary(self: *const Compile) bool {
538 return self.kind == .lib and self.linkage != Linkage.dynamic;533 return self.kind == .lib and self.linkage != .dynamic;
539}534}
540535
541pub fn producesPdbFile(self: *Compile) bool {536pub fn producesPdbFile(self: *Compile) bool {
...@@ -988,7 +983,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -988,7 +983,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
988 var prev_has_cflags = false;983 var prev_has_cflags = false;
989 var prev_has_rcflags = false;984 var prev_has_rcflags = false;
990 var prev_search_strategy: Module.SystemLib.SearchStrategy = .paths_first;985 var prev_search_strategy: Module.SystemLib.SearchStrategy = .paths_first;
991 var prev_preferred_link_mode: std.builtin.LinkMode = .Dynamic;986 var prev_preferred_link_mode: std.builtin.LinkMode = .dynamic;
992 // Track the number of positional arguments so that a nice error can be987 // Track the number of positional arguments so that a nice error can be
993 // emitted if there is nothing to link.988 // emitted if there is nothing to link.
994 var total_linker_objects: usize = @intFromBool(self.root_module.root_source_file != null);989 var total_linker_objects: usize = @intFromBool(self.root_module.root_source_file != null);
...@@ -1053,16 +1048,16 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1053,16 +1048,16 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
1053 {1048 {
1054 switch (system_lib.search_strategy) {1049 switch (system_lib.search_strategy) {
1055 .no_fallback => switch (system_lib.preferred_link_mode) {1050 .no_fallback => switch (system_lib.preferred_link_mode) {
1056 .Dynamic => try zig_args.append("-search_dylibs_only"),1051 .dynamic => try zig_args.append("-search_dylibs_only"),
1057 .Static => try zig_args.append("-search_static_only"),1052 .static => try zig_args.append("-search_static_only"),
1058 },1053 },
1059 .paths_first => switch (system_lib.preferred_link_mode) {1054 .paths_first => switch (system_lib.preferred_link_mode) {
1060 .Dynamic => try zig_args.append("-search_paths_first"),1055 .dynamic => try zig_args.append("-search_paths_first"),
1061 .Static => try zig_args.append("-search_paths_first_static"),1056 .static => try zig_args.append("-search_paths_first_static"),
1062 },1057 },
1063 .mode_first => switch (system_lib.preferred_link_mode) {1058 .mode_first => switch (system_lib.preferred_link_mode) {
1064 .Dynamic => try zig_args.append("-search_dylibs_first"),1059 .dynamic => try zig_args.append("-search_dylibs_first"),
1065 .Static => try zig_args.append("-search_static_first"),1060 .static => try zig_args.append("-search_static_first"),
1066 },1061 },
1067 }1062 }
1068 prev_search_strategy = system_lib.search_strategy;1063 prev_search_strategy = system_lib.search_strategy;
...@@ -1138,7 +1133,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1138,7 +1133,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
1138 try zig_args.append(full_path_lib);1133 try zig_args.append(full_path_lib);
1139 total_linker_objects += 1;1134 total_linker_objects += 1;
11401135
1141 if (other.linkage == Linkage.dynamic and1136 if (other.linkage == .dynamic and
1142 self.rootModuleTarget().os.tag != .windows)1137 self.rootModuleTarget().os.tag != .windows)
1143 {1138 {
1144 if (fs.path.dirname(full_path_lib)) |dirname| {1139 if (fs.path.dirname(full_path_lib)) |dirname| {
lib/std/Build/Step/TranslateC.zig+1-1
...@@ -55,7 +55,7 @@ pub const AddExecutableOptions = struct {...@@ -55,7 +55,7 @@ pub const AddExecutableOptions = struct {
55 version: ?std.SemanticVersion = null,55 version: ?std.SemanticVersion = null,
56 target: ?std.Build.ResolvedTarget = null,56 target: ?std.Build.ResolvedTarget = null,
57 optimize: ?std.builtin.OptimizeMode = null,57 optimize: ?std.builtin.OptimizeMode = null,
58 linkage: ?Step.Compile.Linkage = null,58 linkage: ?std.builtin.LinkMode = null,
59};59};
6060
61pub fn getOutput(self: *TranslateC) std.Build.LazyPath {61pub fn getOutput(self: *TranslateC) std.Build.LazyPath {
lib/std/builtin.zig+2-2
...@@ -500,8 +500,8 @@ pub const OutputMode = enum {...@@ -500,8 +500,8 @@ pub const OutputMode = enum {
500/// This data structure is used by the Zig language code generation and500/// This data structure is used by the Zig language code generation and
501/// therefore must be kept in sync with the compiler implementation.501/// therefore must be kept in sync with the compiler implementation.
502pub const LinkMode = enum {502pub const LinkMode = enum {
503 Static,503 static,
504 Dynamic,504 dynamic,
505};505};
506506
507/// This data structure is used by the Zig language code generation and507/// This data structure is used by the Zig language code generation and
lib/std/c/darwin.zig+1-1
...@@ -202,7 +202,7 @@ var dummy_execute_header: mach_hdr = undefined;...@@ -202,7 +202,7 @@ var dummy_execute_header: mach_hdr = undefined;
202pub extern var _mh_execute_header: mach_hdr;202pub extern var _mh_execute_header: mach_hdr;
203comptime {203comptime {
204 if (builtin.target.isDarwin()) {204 if (builtin.target.isDarwin()) {
205 @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .Weak });205 @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak });
206 }206 }
207}207}
208208
lib/std/dynamic_library.zig+1-1
...@@ -56,7 +56,7 @@ const RDebug = extern struct {...@@ -56,7 +56,7 @@ const RDebug = extern struct {
56/// TODO make it possible to reference this same external symbol 2x so we don't need this56/// TODO make it possible to reference this same external symbol 2x so we don't need this
57/// helper function.57/// helper function.
58pub fn get_DYNAMIC() ?[*]elf.Dyn {58pub fn get_DYNAMIC() ?[*]elf.Dyn {
59 return @extern([*]elf.Dyn, .{ .name = "_DYNAMIC", .linkage = .Weak });59 return @extern([*]elf.Dyn, .{ .name = "_DYNAMIC", .linkage = .weak });
60}60}
6161
62pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {62pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {
lib/std/os/linux.zig+1-1
...@@ -394,7 +394,7 @@ const extern_getauxval = switch (builtin.zig_backend) {...@@ -394,7 +394,7 @@ const extern_getauxval = switch (builtin.zig_backend) {
394394
395comptime {395comptime {
396 if (extern_getauxval) {396 if (extern_getauxval) {
397 @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .Weak });397 @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
398 }398 }
399}399}
400400
lib/std/start.zig+1-1
...@@ -50,7 +50,7 @@ comptime {...@@ -50,7 +50,7 @@ comptime {
50 }50 }
51 }51 }
52 } else {52 } else {
53 if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) {53 if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) {
54 if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {54 if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {
55 @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });55 @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });
56 }56 }
lib/std/zig.zig+12-12
...@@ -155,9 +155,9 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe...@@ -155,9 +155,9 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe
155 .coff => switch (options.output_mode) {155 .coff => switch (options.output_mode) {
156 .Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, t.exeFileExt() }),156 .Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, t.exeFileExt() }),
157 .Lib => {157 .Lib => {
158 const suffix = switch (options.link_mode orelse .Static) {158 const suffix = switch (options.link_mode orelse .static) {
159 .Static => ".lib",159 .static => ".lib",
160 .Dynamic => ".dll",160 .dynamic => ".dll",
161 };161 };
162 return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, suffix });162 return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, suffix });
163 },163 },
...@@ -166,11 +166,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe...@@ -166,11 +166,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe
166 .elf => switch (options.output_mode) {166 .elf => switch (options.output_mode) {
167 .Exe => return allocator.dupe(u8, root_name),167 .Exe => return allocator.dupe(u8, root_name),
168 .Lib => {168 .Lib => {
169 switch (options.link_mode orelse .Static) {169 switch (options.link_mode orelse .static) {
170 .Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{170 .static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{
171 t.libPrefix(), root_name,171 t.libPrefix(), root_name,
172 }),172 }),
173 .Dynamic => {173 .dynamic => {
174 if (options.version) |ver| {174 if (options.version) |ver| {
175 return std.fmt.allocPrint(allocator, "{s}{s}.so.{d}.{d}.{d}", .{175 return std.fmt.allocPrint(allocator, "{s}{s}.so.{d}.{d}.{d}", .{
176 t.libPrefix(), root_name, ver.major, ver.minor, ver.patch,176 t.libPrefix(), root_name, ver.major, ver.minor, ver.patch,
...@@ -188,11 +188,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe...@@ -188,11 +188,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe
188 .macho => switch (options.output_mode) {188 .macho => switch (options.output_mode) {
189 .Exe => return allocator.dupe(u8, root_name),189 .Exe => return allocator.dupe(u8, root_name),
190 .Lib => {190 .Lib => {
191 switch (options.link_mode orelse .Static) {191 switch (options.link_mode orelse .static) {
192 .Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{192 .static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{
193 t.libPrefix(), root_name,193 t.libPrefix(), root_name,
194 }),194 }),
195 .Dynamic => {195 .dynamic => {
196 if (options.version) |ver| {196 if (options.version) |ver| {
197 return std.fmt.allocPrint(allocator, "{s}{s}.{d}.{d}.{d}.dylib", .{197 return std.fmt.allocPrint(allocator, "{s}{s}.{d}.{d}.{d}.dylib", .{
198 t.libPrefix(), root_name, ver.major, ver.minor, ver.patch,198 t.libPrefix(), root_name, ver.major, ver.minor, ver.patch,
...@@ -210,11 +210,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe...@@ -210,11 +210,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe
210 .wasm => switch (options.output_mode) {210 .wasm => switch (options.output_mode) {
211 .Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, t.exeFileExt() }),211 .Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, t.exeFileExt() }),
212 .Lib => {212 .Lib => {
213 switch (options.link_mode orelse .Static) {213 switch (options.link_mode orelse .static) {
214 .Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{214 .static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{
215 t.libPrefix(), root_name,215 t.libPrefix(), root_name,
216 }),216 }),
217 .Dynamic => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}),217 .dynamic => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}),
218 }218 }
219 },219 },
220 .Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}),220 .Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}),
src/Compilation.zig+6-6
...@@ -1201,7 +1201,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1201,7 +1201,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1201 const output_mode = options.config.output_mode;1201 const output_mode = options.config.output_mode;
1202 const is_dyn_lib = switch (output_mode) {1202 const is_dyn_lib = switch (output_mode) {
1203 .Obj, .Exe => false,1203 .Obj, .Exe => false,
1204 .Lib => options.config.link_mode == .Dynamic,1204 .Lib => options.config.link_mode == .dynamic,
1205 };1205 };
1206 const is_exe_or_dyn_lib = switch (output_mode) {1206 const is_exe_or_dyn_lib = switch (output_mode) {
1207 .Obj => false,1207 .Obj => false,
...@@ -1806,8 +1806,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1806,8 +1806,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1806 .{ .musl_crt_file = .scrt1_o },1806 .{ .musl_crt_file = .scrt1_o },
1807 .{ .musl_crt_file = .rcrt1_o },1807 .{ .musl_crt_file = .rcrt1_o },
1808 switch (comp.config.link_mode) {1808 switch (comp.config.link_mode) {
1809 .Static => .{ .musl_crt_file = .libc_a },1809 .static => .{ .musl_crt_file = .libc_a },
1810 .Dynamic => .{ .musl_crt_file = .libc_so },1810 .dynamic => .{ .musl_crt_file = .libc_so },
1811 },1811 },
1812 });1812 });
1813 }1813 }
...@@ -6087,7 +6087,7 @@ pub fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const...@@ -6087,7 +6087,7 @@ pub fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const
6087fn wantBuildLibCFromSource(comp: Compilation) bool {6087fn wantBuildLibCFromSource(comp: Compilation) bool {
6088 const is_exe_or_dyn_lib = switch (comp.config.output_mode) {6088 const is_exe_or_dyn_lib = switch (comp.config.output_mode) {
6089 .Obj => false,6089 .Obj => false,
6090 .Lib => comp.config.link_mode == .Dynamic,6090 .Lib => comp.config.link_mode == .dynamic,
6091 .Exe => true,6091 .Exe => true,
6092 };6092 };
6093 const ofmt = comp.root_mod.resolved_target.result.ofmt;6093 const ofmt = comp.root_mod.resolved_target.result.ofmt;
...@@ -6116,7 +6116,7 @@ fn wantBuildMinGWFromSource(comp: Compilation) bool {...@@ -6116,7 +6116,7 @@ fn wantBuildMinGWFromSource(comp: Compilation) bool {
6116fn wantBuildLibUnwindFromSource(comp: *Compilation) bool {6116fn wantBuildLibUnwindFromSource(comp: *Compilation) bool {
6117 const is_exe_or_dyn_lib = switch (comp.config.output_mode) {6117 const is_exe_or_dyn_lib = switch (comp.config.output_mode) {
6118 .Obj => false,6118 .Obj => false,
6119 .Lib => comp.config.link_mode == .Dynamic,6119 .Lib => comp.config.link_mode == .dynamic,
6120 .Exe => true,6120 .Exe => true,
6121 };6121 };
6122 const ofmt = comp.root_mod.resolved_target.result.ofmt;6122 const ofmt = comp.root_mod.resolved_target.result.ofmt;
...@@ -6310,7 +6310,7 @@ fn buildOutputFromZig(...@@ -6310,7 +6310,7 @@ fn buildOutputFromZig(
63106310
6311 const config = try Config.resolve(.{6311 const config = try Config.resolve(.{
6312 .output_mode = output_mode,6312 .output_mode = output_mode,
6313 .link_mode = .Static,6313 .link_mode = .static,
6314 .resolved_target = comp.root_mod.resolved_target,6314 .resolved_target = comp.root_mod.resolved_target,
6315 .is_test = false,6315 .is_test = false,
6316 .have_zcu = true,6316 .have_zcu = true,
src/Compilation/Config.zig+12-12
...@@ -348,26 +348,26 @@ pub fn resolve(options: Options) ResolveError!Config {...@@ -348,26 +348,26 @@ pub fn resolve(options: Options) ResolveError!Config {
348 const link_mode = b: {348 const link_mode = b: {
349 const explicitly_exe_or_dyn_lib = switch (options.output_mode) {349 const explicitly_exe_or_dyn_lib = switch (options.output_mode) {
350 .Obj => false,350 .Obj => false,
351 .Lib => (options.link_mode orelse .Static) == .Dynamic,351 .Lib => (options.link_mode orelse .static) == .dynamic,
352 .Exe => true,352 .Exe => true,
353 };353 };
354354
355 if (target_util.cannotDynamicLink(target)) {355 if (target_util.cannotDynamicLink(target)) {
356 if (options.link_mode == .Dynamic) return error.TargetCannotDynamicLink;356 if (options.link_mode == .dynamic) return error.TargetCannotDynamicLink;
357 break :b .Static;357 break :b .static;
358 }358 }
359 if (explicitly_exe_or_dyn_lib and link_libc and359 if (explicitly_exe_or_dyn_lib and link_libc and
360 (target.isGnuLibC() or target_util.osRequiresLibC(target)))360 (target.isGnuLibC() or target_util.osRequiresLibC(target)))
361 {361 {
362 if (options.link_mode == .Static) return error.LibCRequiresDynamicLinking;362 if (options.link_mode == .static) return error.LibCRequiresDynamicLinking;
363 break :b .Dynamic;363 break :b .dynamic;
364 }364 }
365 // When creating a executable that links to system libraries, we365 // When creating a executable that links to system libraries, we
366 // require dynamic linking, but we must not link static libraries366 // require dynamic linking, but we must not link static libraries
367 // or object files dynamically!367 // or object files dynamically!
368 if (options.any_dyn_libs and options.output_mode == .Exe) {368 if (options.any_dyn_libs and options.output_mode == .Exe) {
369 if (options.link_mode == .Static) return error.SharedLibrariesRequireDynamicLinking;369 if (options.link_mode == .static) return error.SharedLibrariesRequireDynamicLinking;
370 break :b .Dynamic;370 break :b .dynamic;
371 }371 }
372372
373 if (options.link_mode) |link_mode| break :b link_mode;373 if (options.link_mode) |link_mode| break :b link_mode;
...@@ -377,16 +377,16 @@ pub fn resolve(options: Options) ResolveError!Config {...@@ -377,16 +377,16 @@ pub fn resolve(options: Options) ResolveError!Config {
377 {377 {
378 // If targeting the system's native ABI and the system's libc is378 // If targeting the system's native ABI and the system's libc is
379 // musl, link dynamically by default.379 // musl, link dynamically by default.
380 break :b .Dynamic;380 break :b .dynamic;
381 }381 }
382382
383 // Static is generally a better default. Fight me.383 // Static is generally a better default. Fight me.
384 break :b .Static;384 break :b .static;
385 };385 };
386386
387 const import_memory = options.import_memory orelse (options.output_mode == .Obj);387 const import_memory = options.import_memory orelse (options.output_mode == .Obj);
388 const export_memory = b: {388 const export_memory = b: {
389 if (link_mode == .Dynamic) {389 if (link_mode == .dynamic) {
390 if (options.export_memory == true) return error.ExportMemoryAndDynamicIncompatible;390 if (options.export_memory == true) return error.ExportMemoryAndDynamicIncompatible;
391 break :b false;391 break :b false;
392 }392 }
...@@ -397,7 +397,7 @@ pub fn resolve(options: Options) ResolveError!Config {...@@ -397,7 +397,7 @@ pub fn resolve(options: Options) ResolveError!Config {
397 const pie: bool = b: {397 const pie: bool = b: {
398 switch (options.output_mode) {398 switch (options.output_mode) {
399 .Obj, .Exe => {},399 .Obj, .Exe => {},
400 .Lib => if (link_mode == .Dynamic) {400 .Lib => if (link_mode == .dynamic) {
401 if (options.pie == true) return error.DynamicLibraryPrecludesPie;401 if (options.pie == true) return error.DynamicLibraryPrecludesPie;
402 break :b false;402 break :b false;
403 },403 },
...@@ -467,7 +467,7 @@ pub fn resolve(options: Options) ResolveError!Config {...@@ -467,7 +467,7 @@ pub fn resolve(options: Options) ResolveError!Config {
467 if (rdynamic) break :b true;467 if (rdynamic) break :b true;
468 break :b switch (options.output_mode) {468 break :b switch (options.output_mode) {
469 .Obj, .Exe => false,469 .Obj, .Exe => false,
470 .Lib => link_mode == .Dynamic,470 .Lib => link_mode == .dynamic,
471 };471 };
472 };472 };
473473
src/Package/Module.zig+1-1
...@@ -178,7 +178,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {...@@ -178,7 +178,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {
178 return error.PieRequiresPic;178 return error.PieRequiresPic;
179 break :b true;179 break :b true;
180 }180 }
181 if (options.global.link_mode == .Dynamic) {181 if (options.global.link_mode == .dynamic) {
182 if (options.inherited.pic == false)182 if (options.inherited.pic == false)
183 return error.DynamicLinkingRequiresPic;183 return error.DynamicLinkingRequiresPic;
184 break :b true;184 break :b true;
src/arch/x86_64/Emit.zig+2-2
...@@ -110,7 +110,7 @@ pub fn emitMir(emit: *Emit) Error!void {...@@ -110,7 +110,7 @@ pub fn emitMir(emit: *Emit) Error!void {
110 const is_obj_or_static_lib = switch (emit.lower.output_mode) {110 const is_obj_or_static_lib = switch (emit.lower.output_mode) {
111 .Exe => false,111 .Exe => false,
112 .Obj => true,112 .Obj => true,
113 .Lib => emit.lower.link_mode == .Static,113 .Lib => emit.lower.link_mode == .static,
114 };114 };
115 const atom = elf_file.symbol(data.atom_index).atom(elf_file).?;115 const atom = elf_file.symbol(data.atom_index).atom(elf_file).?;
116 const sym_index = elf_file.zigObjectPtr().?.symbol(data.sym_index);116 const sym_index = elf_file.zigObjectPtr().?.symbol(data.sym_index);
...@@ -158,7 +158,7 @@ pub fn emitMir(emit: *Emit) Error!void {...@@ -158,7 +158,7 @@ pub fn emitMir(emit: *Emit) Error!void {
158 const is_obj_or_static_lib = switch (emit.lower.output_mode) {158 const is_obj_or_static_lib = switch (emit.lower.output_mode) {
159 .Exe => false,159 .Exe => false,
160 .Obj => true,160 .Obj => true,
161 .Lib => emit.lower.link_mode == .Static,161 .Lib => emit.lower.link_mode == .static,
162 };162 };
163 const atom = macho_file.getSymbol(data.atom_index).getAtom(macho_file).?;163 const atom = macho_file.getSymbol(data.atom_index).getAtom(macho_file).?;
164 const sym_index = macho_file.getZigObject().?.symbols.items[data.sym_index];164 const sym_index = macho_file.getZigObject().?.symbols.items[data.sym_index];
src/arch/x86_64/Lower.zig+1-1
...@@ -329,7 +329,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)...@@ -329,7 +329,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
329 const is_obj_or_static_lib = switch (lower.output_mode) {329 const is_obj_or_static_lib = switch (lower.output_mode) {
330 .Exe => false,330 .Exe => false,
331 .Obj => true,331 .Obj => true,
332 .Lib => lower.link_mode == .Static,332 .Lib => lower.link_mode == .static,
333 };333 };
334334
335 const emit_prefix = prefix;335 const emit_prefix = prefix;
src/glibc.zig+1-1
...@@ -1084,7 +1084,7 @@ fn buildSharedLib(...@@ -1084,7 +1084,7 @@ fn buildSharedLib(
1084 const strip = comp.compilerRtStrip();1084 const strip = comp.compilerRtStrip();
1085 const config = try Compilation.Config.resolve(.{1085 const config = try Compilation.Config.resolve(.{
1086 .output_mode = .Lib,1086 .output_mode = .Lib,
1087 .link_mode = .Dynamic,1087 .link_mode = .dynamic,
1088 .resolved_target = comp.root_mod.resolved_target,1088 .resolved_target = comp.root_mod.resolved_target,
1089 .is_test = false,1089 .is_test = false,
1090 .have_zcu = false,1090 .have_zcu = false,
src/libcxx.zig+2-2
...@@ -115,7 +115,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -115,7 +115,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
115115
116 const root_name = "c++";116 const root_name = "c++";
117 const output_mode = .Lib;117 const output_mode = .Lib;
118 const link_mode = .Static;118 const link_mode = .static;
119 const target = comp.root_mod.resolved_target.result;119 const target = comp.root_mod.resolved_target.result;
120 const basename = try std.zig.binNameAlloc(arena, .{120 const basename = try std.zig.binNameAlloc(arena, .{
121 .root_name = root_name,121 .root_name = root_name,
...@@ -327,7 +327,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -327,7 +327,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
327327
328 const root_name = "c++abi";328 const root_name = "c++abi";
329 const output_mode = .Lib;329 const output_mode = .Lib;
330 const link_mode = .Static;330 const link_mode = .static;
331 const target = comp.root_mod.resolved_target.result;331 const target = comp.root_mod.resolved_target.result;
332 const basename = try std.zig.binNameAlloc(arena, .{332 const basename = try std.zig.binNameAlloc(arena, .{
333 .root_name = root_name,333 .root_name = root_name,
src/libtsan.zig+1-1
...@@ -27,7 +27,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!v...@@ -27,7 +27,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!v
2727
28 const root_name = "tsan";28 const root_name = "tsan";
29 const output_mode = .Lib;29 const output_mode = .Lib;
30 const link_mode = .Static;30 const link_mode = .static;
31 const target = comp.getTarget();31 const target = comp.getTarget();
32 const basename = try std.zig.binNameAlloc(arena, .{32 const basename = try std.zig.binNameAlloc(arena, .{
33 .root_name = root_name,33 .root_name = root_name,
src/libunwind.zig+1-1
...@@ -62,7 +62,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -62,7 +62,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
62 });62 });
6363
64 const root_name = "unwind";64 const root_name = "unwind";
65 const link_mode = .Static;65 const link_mode = .static;
66 const target = comp.root_mod.resolved_target.result;66 const target = comp.root_mod.resolved_target.result;
67 const basename = try std.zig.binNameAlloc(arena, .{67 const basename = try std.zig.binNameAlloc(arena, .{
68 .root_name = root_name,68 .root_name = root_name,
src/link.zig+6-6
...@@ -287,8 +287,8 @@ pub const File = struct {...@@ -287,8 +287,8 @@ pub const File = struct {
287 switch (output_mode) {287 switch (output_mode) {
288 .Obj => return,288 .Obj => return,
289 .Lib => switch (link_mode) {289 .Lib => switch (link_mode) {
290 .Static => return,290 .static => return,
291 .Dynamic => {},291 .dynamic => {},
292 },292 },
293 .Exe => {},293 .Exe => {},
294 }294 }
...@@ -582,7 +582,7 @@ pub const File = struct {...@@ -582,7 +582,7 @@ pub const File = struct {
582 const use_lld = build_options.have_llvm and comp.config.use_lld;582 const use_lld = build_options.have_llvm and comp.config.use_lld;
583 const output_mode = comp.config.output_mode;583 const output_mode = comp.config.output_mode;
584 const link_mode = comp.config.link_mode;584 const link_mode = comp.config.link_mode;
585 if (use_lld and output_mode == .Lib and link_mode == .Static) {585 if (use_lld and output_mode == .Lib and link_mode == .static) {
586 return base.linkAsArchive(arena, prog_node);586 return base.linkAsArchive(arena, prog_node);
587 }587 }
588 switch (base.tag) {588 switch (base.tag) {
...@@ -957,8 +957,8 @@ pub const File = struct {...@@ -957,8 +957,8 @@ pub const File = struct {
957 const executable_mode = if (builtin.target.os.tag == .windows) 0 else 0o777;957 const executable_mode = if (builtin.target.os.tag == .windows) 0 else 0o777;
958 switch (effectiveOutputMode(use_lld, output_mode)) {958 switch (effectiveOutputMode(use_lld, output_mode)) {
959 .Lib => return switch (link_mode) {959 .Lib => return switch (link_mode) {
960 .Dynamic => executable_mode,960 .dynamic => executable_mode,
961 .Static => fs.File.default_mode,961 .static => fs.File.default_mode,
962 },962 },
963 .Exe => return executable_mode,963 .Exe => return executable_mode,
964 .Obj => return fs.File.default_mode,964 .Obj => return fs.File.default_mode,
...@@ -966,7 +966,7 @@ pub const File = struct {...@@ -966,7 +966,7 @@ pub const File = struct {
966 }966 }
967967
968 pub fn isStatic(self: File) bool {968 pub fn isStatic(self: File) bool {
969 return self.comp.config.link_mode == .Static;969 return self.comp.config.link_mode == .static;
970 }970 }
971971
972 pub fn isObject(self: File) bool {972 pub fn isObject(self: File) bool {
src/link/Coff.zig+1-1
...@@ -2275,7 +2275,7 @@ fn writeHeader(self: *Coff) !void {...@@ -2275,7 +2275,7 @@ fn writeHeader(self: *Coff) !void {
2275 .p32 => flags.@"32BIT_MACHINE" = 1,2275 .p32 => flags.@"32BIT_MACHINE" = 1,
2276 .p64 => flags.LARGE_ADDRESS_AWARE = 1,2276 .p64 => flags.LARGE_ADDRESS_AWARE = 1,
2277 }2277 }
2278 if (self.base.comp.config.output_mode == .Lib and self.base.comp.config.link_mode == .Dynamic) {2278 if (self.base.comp.config.output_mode == .Lib and self.base.comp.config.link_mode == .dynamic) {
2279 flags.DLL = 1;2279 flags.DLL = 1;
2280 }2280 }
22812281
src/link/Coff/lld.zig+5-5
...@@ -45,7 +45,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node)...@@ -45,7 +45,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node)
45 defer sub_prog_node.end();45 defer sub_prog_node.end();
4646
47 const is_lib = comp.config.output_mode == .Lib;47 const is_lib = comp.config.output_mode == .Lib;
48 const is_dyn_lib = comp.config.link_mode == .Dynamic and is_lib;48 const is_dyn_lib = comp.config.link_mode == .dynamic and is_lib;
49 const is_exe_or_dyn_lib = is_dyn_lib or comp.config.output_mode == .Exe;49 const is_exe_or_dyn_lib = is_dyn_lib or comp.config.output_mode == .Exe;
50 const link_in_crt = comp.config.link_libc and is_exe_or_dyn_lib;50 const link_in_crt = comp.config.link_libc and is_exe_or_dyn_lib;
51 const target = comp.root_mod.resolved_target.result;51 const target = comp.root_mod.resolved_target.result;
...@@ -411,16 +411,16 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node)...@@ -411,16 +411,16 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node)
411 try argv.append(try comp.get_libc_crt_file(arena, "mingwex.lib"));411 try argv.append(try comp.get_libc_crt_file(arena, "mingwex.lib"));
412 } else {412 } else {
413 const lib_str = switch (comp.config.link_mode) {413 const lib_str = switch (comp.config.link_mode) {
414 .Dynamic => "",414 .dynamic => "",
415 .Static => "lib",415 .static => "lib",
416 };416 };
417 const d_str = switch (optimize_mode) {417 const d_str = switch (optimize_mode) {
418 .Debug => "d",418 .Debug => "d",
419 else => "",419 else => "",
420 };420 };
421 switch (comp.config.link_mode) {421 switch (comp.config.link_mode) {
422 .Static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})),422 .static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})),
423 .Dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})),423 .dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})),
424 }424 }
425425
426 try argv.append(try allocPrint(arena, "{s}vcruntime{s}.lib", .{ lib_str, d_str }));426 try argv.append(try allocPrint(arena, "{s}vcruntime{s}.lib", .{ lib_str, d_str }));
src/link/Elf.zig+26-26
...@@ -262,7 +262,7 @@ pub fn createEmpty(...@@ -262,7 +262,7 @@ pub fn createEmpty(
262 .sparc64 => 0x2000,262 .sparc64 => 0x2000,
263 else => 0x1000,263 else => 0x1000,
264 };264 };
265 const is_dyn_lib = output_mode == .Lib and link_mode == .Dynamic;265 const is_dyn_lib = output_mode == .Lib and link_mode == .dynamic;
266 const default_sym_version: elf.Elf64_Versym = if (is_dyn_lib or comp.config.rdynamic)266 const default_sym_version: elf.Elf64_Versym = if (is_dyn_lib or comp.config.rdynamic)
267 elf.VER_NDX_GLOBAL267 elf.VER_NDX_GLOBAL
268 else268 else
...@@ -349,7 +349,7 @@ pub fn createEmpty(...@@ -349,7 +349,7 @@ pub fn createEmpty(
349 }349 }
350350
351 const is_obj = output_mode == .Obj;351 const is_obj = output_mode == .Obj;
352 const is_obj_or_ar = is_obj or (output_mode == .Lib and link_mode == .Static);352 const is_obj_or_ar = is_obj or (output_mode == .Lib and link_mode == .static);
353353
354 // What path should this ELF linker code output to?354 // What path should this ELF linker code output to?
355 // If using LLD to link, this code should produce an object file so that it355 // If using LLD to link, this code should produce an object file so that it
...@@ -1180,10 +1180,10 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node)...@@ -1180,10 +1180,10 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node)
11801180
1181 success: {1181 success: {
1182 if (!self.base.isStatic()) {1182 if (!self.base.isStatic()) {
1183 if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .Dynamic))1183 if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .dynamic))
1184 break :success;1184 break :success;
1185 }1185 }
1186 if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .Static))1186 if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .static))
1187 break :success;1187 break :success;
11881188
1189 try self.reportMissingLibraryError(1189 try self.reportMissingLibraryError(
...@@ -1211,8 +1211,8 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node)...@@ -1211,8 +1211,8 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node)
1211 });1211 });
1212 } else if (target.isMusl()) {1212 } else if (target.isMusl()) {
1213 const path = try comp.get_libc_crt_file(arena, switch (link_mode) {1213 const path = try comp.get_libc_crt_file(arena, switch (link_mode) {
1214 .Static => "libc.a",1214 .static => "libc.a",
1215 .Dynamic => "libc.so",1215 .dynamic => "libc.so",
1216 });1216 });
1217 try system_libs.append(.{ .path = path });1217 try system_libs.append(.{ .path = path });
1218 } else {1218 } else {
...@@ -1628,7 +1628,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {...@@ -1628,7 +1628,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {
1628 // libc dep1628 // libc dep
1629 if (comp.config.link_libc) {1629 if (comp.config.link_libc) {
1630 if (self.base.comp.libc_installation != null) {1630 if (self.base.comp.libc_installation != null) {
1631 const needs_grouping = link_mode == .Static;1631 const needs_grouping = link_mode == .static;
1632 if (needs_grouping) try argv.append("--start-group");1632 if (needs_grouping) try argv.append("--start-group");
1633 try argv.appendSlice(target_util.libcFullLinkFlags(target));1633 try argv.appendSlice(target_util.libcFullLinkFlags(target));
1634 if (needs_grouping) try argv.append("--end-group");1634 if (needs_grouping) try argv.append("--end-group");
...@@ -1642,8 +1642,8 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {...@@ -1642,8 +1642,8 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {
1642 try argv.append(try comp.get_libc_crt_file(arena, "libc_nonshared.a"));1642 try argv.append(try comp.get_libc_crt_file(arena, "libc_nonshared.a"));
1643 } else if (target.isMusl()) {1643 } else if (target.isMusl()) {
1644 try argv.append(try comp.get_libc_crt_file(arena, switch (link_mode) {1644 try argv.append(try comp.get_libc_crt_file(arena, switch (link_mode) {
1645 .Static => "libc.a",1645 .static => "libc.a",
1646 .Dynamic => "libc.so",1646 .dynamic => "libc.so",
1647 }));1647 }));
1648 }1648 }
1649 }1649 }
...@@ -1797,10 +1797,10 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void {...@@ -1797,10 +1797,10 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void {
1797 // Maybe we should hoist search-strategy all the way here?1797 // Maybe we should hoist search-strategy all the way here?
1798 for (self.lib_dirs) |lib_dir| {1798 for (self.lib_dirs) |lib_dir| {
1799 if (!self.base.isStatic()) {1799 if (!self.base.isStatic()) {
1800 if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .Dynamic))1800 if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .dynamic))
1801 break :success;1801 break :success;
1802 }1802 }
1803 if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .Static))1803 if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .static))
1804 break :success;1804 break :success;
1805 }1805 }
1806 } else {1806 } else {
...@@ -1858,8 +1858,8 @@ fn accessLibPath(...@@ -1858,8 +1858,8 @@ fn accessLibPath(
1858 test_path.clearRetainingCapacity();1858 test_path.clearRetainingCapacity();
1859 const prefix = if (link_mode != null) "lib" else "";1859 const prefix = if (link_mode != null) "lib" else "";
1860 const suffix = if (link_mode) |mode| switch (mode) {1860 const suffix = if (link_mode) |mode| switch (mode) {
1861 .Static => target.staticLibSuffix(),1861 .static => target.staticLibSuffix(),
1862 .Dynamic => target.dynamicLibSuffix(),1862 .dynamic => target.dynamicLibSuffix(),
1863 } else "";1863 } else "";
1864 try test_path.writer().print("{s}" ++ sep ++ "{s}{s}{s}", .{1864 try test_path.writer().print("{s}" ++ sep ++ "{s}{s}{s}", .{
1865 lib_dir_path,1865 lib_dir_path,
...@@ -2150,10 +2150,10 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi...@@ -2150,10 +2150,10 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
2150 const is_obj = output_mode == .Obj;2150 const is_obj = output_mode == .Obj;
2151 const is_lib = output_mode == .Lib;2151 const is_lib = output_mode == .Lib;
2152 const link_mode = comp.config.link_mode;2152 const link_mode = comp.config.link_mode;
2153 const is_dyn_lib = link_mode == .Dynamic and is_lib;2153 const is_dyn_lib = link_mode == .dynamic and is_lib;
2154 const is_exe_or_dyn_lib = is_dyn_lib or output_mode == .Exe;2154 const is_exe_or_dyn_lib = is_dyn_lib or output_mode == .Exe;
2155 const have_dynamic_linker = comp.config.link_libc and2155 const have_dynamic_linker = comp.config.link_libc and
2156 link_mode == .Dynamic and is_exe_or_dyn_lib;2156 link_mode == .dynamic and is_exe_or_dyn_lib;
2157 const target = comp.root_mod.resolved_target.result;2157 const target = comp.root_mod.resolved_target.result;
2158 const compiler_rt_path: ?[]const u8 = blk: {2158 const compiler_rt_path: ?[]const u8 = blk: {
2159 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;2159 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;
...@@ -2463,7 +2463,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi...@@ -2463,7 +2463,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
2463 try argv.append(arg);2463 try argv.append(arg);
2464 }2464 }
24652465
2466 if (link_mode == .Static) {2466 if (link_mode == .static) {
2467 if (target.cpu.arch.isArmOrThumb()) {2467 if (target.cpu.arch.isArmOrThumb()) {
2468 try argv.append("-Bstatic");2468 try argv.append("-Bstatic");
2469 } else {2469 } else {
...@@ -2647,7 +2647,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi...@@ -2647,7 +2647,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
2647 comp.link_error_flags.missing_libc = false;2647 comp.link_error_flags.missing_libc = false;
2648 if (comp.config.link_libc) {2648 if (comp.config.link_libc) {
2649 if (comp.libc_installation != null) {2649 if (comp.libc_installation != null) {
2650 const needs_grouping = link_mode == .Static;2650 const needs_grouping = link_mode == .static;
2651 if (needs_grouping) try argv.append("--start-group");2651 if (needs_grouping) try argv.append("--start-group");
2652 try argv.appendSlice(target_util.libcFullLinkFlags(target));2652 try argv.appendSlice(target_util.libcFullLinkFlags(target));
2653 if (needs_grouping) try argv.append("--end-group");2653 if (needs_grouping) try argv.append("--end-group");
...@@ -2661,8 +2661,8 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi...@@ -2661,8 +2661,8 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
2661 try argv.append(try comp.get_libc_crt_file(arena, "libc_nonshared.a"));2661 try argv.append(try comp.get_libc_crt_file(arena, "libc_nonshared.a"));
2662 } else if (target.isMusl()) {2662 } else if (target.isMusl()) {
2663 try argv.append(try comp.get_libc_crt_file(arena, switch (link_mode) {2663 try argv.append(try comp.get_libc_crt_file(arena, switch (link_mode) {
2664 .Static => "libc.a",2664 .static => "libc.a",
2665 .Dynamic => "libc.so",2665 .dynamic => "libc.so",
2666 }));2666 }));
2667 } else {2667 } else {
2668 comp.link_error_flags.missing_libc = true;2668 comp.link_error_flags.missing_libc = true;
...@@ -2928,8 +2928,8 @@ pub fn writeElfHeader(self: *Elf) !void {...@@ -2928,8 +2928,8 @@ pub fn writeElfHeader(self: *Elf) !void {
2928 .Exe => if (comp.config.pie) .DYN else .EXEC,2928 .Exe => if (comp.config.pie) .DYN else .EXEC,
2929 .Obj => .REL,2929 .Obj => .REL,
2930 .Lib => switch (link_mode) {2930 .Lib => switch (link_mode) {
2931 .Static => @as(elf.ET, .REL),2931 .static => @as(elf.ET, .REL),
2932 .Dynamic => .DYN,2932 .dynamic => .DYN,
2933 },2933 },
2934 };2934 };
2935 mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(elf_type), endian);2935 mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(elf_type), endian);
...@@ -3216,7 +3216,7 @@ fn allocateLinkerDefinedSymbols(self: *Elf) void {...@@ -3216,7 +3216,7 @@ fn allocateLinkerDefinedSymbols(self: *Elf) void {
32163216
3217 // __rela_iplt_start, __rela_iplt_end3217 // __rela_iplt_start, __rela_iplt_end
3218 if (self.rela_dyn_section_index) |shndx| blk: {3218 if (self.rela_dyn_section_index) |shndx| blk: {
3219 if (link_mode != .Static or comp.config.pie) break :blk;3219 if (link_mode != .static or comp.config.pie) break :blk;
3220 const shdr = &self.shdrs.items[shndx];3220 const shdr = &self.shdrs.items[shndx];
3221 const end_addr = shdr.sh_addr + shdr.sh_size;3221 const end_addr = shdr.sh_addr + shdr.sh_size;
3222 const start_addr = end_addr - self.calcNumIRelativeRelocs() * @sizeOf(elf.Elf64_Rela);3222 const start_addr = end_addr - self.calcNumIRelativeRelocs() * @sizeOf(elf.Elf64_Rela);
...@@ -5061,12 +5061,12 @@ const CsuObjects = struct {...@@ -5061,12 +5061,12 @@ const CsuObjects = struct {
5061 } = switch (comp.config.output_mode) {5061 } = switch (comp.config.output_mode) {
5062 .Obj => return CsuObjects{},5062 .Obj => return CsuObjects{},
5063 .Lib => switch (comp.config.link_mode) {5063 .Lib => switch (comp.config.link_mode) {
5064 .Dynamic => .dynamic_lib,5064 .dynamic => .dynamic_lib,
5065 .Static => return CsuObjects{},5065 .static => return CsuObjects{},
5066 },5066 },
5067 .Exe => switch (comp.config.link_mode) {5067 .Exe => switch (comp.config.link_mode) {
5068 .Dynamic => if (comp.config.pie) .dynamic_pie else .dynamic_exe,5068 .dynamic => if (comp.config.pie) .dynamic_pie else .dynamic_exe,
5069 .Static => if (comp.config.pie) .static_pie else .static_exe,5069 .static => if (comp.config.pie) .static_pie else .static_exe,
5070 },5070 },
5071 };5071 };
50725072
src/link/MachO/load_commands.zig+1-1
...@@ -222,7 +222,7 @@ pub fn writeDylibLC(ctx: WriteDylibLCCtx, writer: anytype) !void {...@@ -222,7 +222,7 @@ pub fn writeDylibLC(ctx: WriteDylibLCCtx, writer: anytype) !void {
222pub fn writeDylibIdLC(macho_file: *MachO, writer: anytype) !void {222pub fn writeDylibIdLC(macho_file: *MachO, writer: anytype) !void {
223 const comp = macho_file.base.comp;223 const comp = macho_file.base.comp;
224 const gpa = comp.gpa;224 const gpa = comp.gpa;
225 assert(comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic);225 assert(comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic);
226 const emit = macho_file.base.emit;226 const emit = macho_file.base.emit;
227 const install_name = macho_file.install_name orelse227 const install_name = macho_file.install_name orelse
228 try emit.directory.join(gpa, &.{emit.sub_path});228 try emit.directory.join(gpa, &.{emit.sub_path});
src/link/Wasm.zig+3-3
...@@ -2518,7 +2518,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node)...@@ -2518,7 +2518,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node)
2518 // When the target os is WASI, we allow linking with WASI-LIBC2518 // When the target os is WASI, we allow linking with WASI-LIBC
2519 if (target.os.tag == .wasi) {2519 if (target.os.tag == .wasi) {
2520 const is_exe_or_dyn_lib = output_mode == .Exe or2520 const is_exe_or_dyn_lib = output_mode == .Exe or
2521 (output_mode == .Lib and link_mode == .Dynamic);2521 (output_mode == .Lib and link_mode == .dynamic);
2522 if (is_exe_or_dyn_lib) {2522 if (is_exe_or_dyn_lib) {
2523 for (comp.wasi_emulated_libs) |crt_file| {2523 for (comp.wasi_emulated_libs) |crt_file| {
2524 try positionals.append(try comp.get_libc_crt_file(2524 try positionals.append(try comp.get_libc_crt_file(
...@@ -3549,7 +3549,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo...@@ -3549,7 +3549,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo
3549 try argv.append("--allow-undefined");3549 try argv.append("--allow-undefined");
3550 }3550 }
35513551
3552 if (comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic) {3552 if (comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic) {
3553 try argv.append("--shared");3553 try argv.append("--shared");
3554 }3554 }
3555 if (comp.config.pie) {3555 if (comp.config.pie) {
...@@ -3569,7 +3569,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo...@@ -3569,7 +3569,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo
35693569
3570 if (target.os.tag == .wasi) {3570 if (target.os.tag == .wasi) {
3571 const is_exe_or_dyn_lib = comp.config.output_mode == .Exe or3571 const is_exe_or_dyn_lib = comp.config.output_mode == .Exe or
3572 (comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic);3572 (comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic);
3573 if (is_exe_or_dyn_lib) {3573 if (is_exe_or_dyn_lib) {
3574 for (comp.wasi_emulated_libs) |crt_file| {3574 for (comp.wasi_emulated_libs) |crt_file| {
3575 try argv.append(try comp.get_libc_crt_file(3575 try argv.append(try comp.get_libc_crt_file(
src/main.zig+32-32
...@@ -755,8 +755,8 @@ const SystemLib = struct {...@@ -755,8 +755,8 @@ const SystemLib = struct {
755 fn fallbackMode(this: SystemLib) std.builtin.LinkMode {755 fn fallbackMode(this: SystemLib) std.builtin.LinkMode {
756 assert(this.search_strategy != .no_fallback);756 assert(this.search_strategy != .no_fallback);
757 return switch (this.preferred_mode) {757 return switch (this.preferred_mode) {
758 .Dynamic => .Static,758 .dynamic => .static,
759 .Static => .Dynamic,759 .static => .dynamic,
760 };760 };
761 }761 }
762};762};
...@@ -892,7 +892,7 @@ fn buildOutputType(...@@ -892,7 +892,7 @@ fn buildOutputType(
892 var entitlements: ?[]const u8 = null;892 var entitlements: ?[]const u8 = null;
893 var pagezero_size: ?u64 = null;893 var pagezero_size: ?u64 = null;
894 var lib_search_strategy: SystemLib.SearchStrategy = .paths_first;894 var lib_search_strategy: SystemLib.SearchStrategy = .paths_first;
895 var lib_preferred_mode: std.builtin.LinkMode = .Dynamic;895 var lib_preferred_mode: std.builtin.LinkMode = .dynamic;
896 var headerpad_size: ?u32 = null;896 var headerpad_size: ?u32 = null;
897 var headerpad_max_install_names: bool = false;897 var headerpad_max_install_names: bool = false;
898 var dead_strip_dylibs: bool = false;898 var dead_strip_dylibs: bool = false;
...@@ -1166,22 +1166,22 @@ fn buildOutputType(...@@ -1166,22 +1166,22 @@ fn buildOutputType(
1166 };1166 };
1167 } else if (mem.eql(u8, arg, "-search_paths_first")) {1167 } else if (mem.eql(u8, arg, "-search_paths_first")) {
1168 lib_search_strategy = .paths_first;1168 lib_search_strategy = .paths_first;
1169 lib_preferred_mode = .Dynamic;1169 lib_preferred_mode = .dynamic;
1170 } else if (mem.eql(u8, arg, "-search_paths_first_static")) {1170 } else if (mem.eql(u8, arg, "-search_paths_first_static")) {
1171 lib_search_strategy = .paths_first;1171 lib_search_strategy = .paths_first;
1172 lib_preferred_mode = .Static;1172 lib_preferred_mode = .static;
1173 } else if (mem.eql(u8, arg, "-search_dylibs_first")) {1173 } else if (mem.eql(u8, arg, "-search_dylibs_first")) {
1174 lib_search_strategy = .mode_first;1174 lib_search_strategy = .mode_first;
1175 lib_preferred_mode = .Dynamic;1175 lib_preferred_mode = .dynamic;
1176 } else if (mem.eql(u8, arg, "-search_static_first")) {1176 } else if (mem.eql(u8, arg, "-search_static_first")) {
1177 lib_search_strategy = .mode_first;1177 lib_search_strategy = .mode_first;
1178 lib_preferred_mode = .Static;1178 lib_preferred_mode = .static;
1179 } else if (mem.eql(u8, arg, "-search_dylibs_only")) {1179 } else if (mem.eql(u8, arg, "-search_dylibs_only")) {
1180 lib_search_strategy = .no_fallback;1180 lib_search_strategy = .no_fallback;
1181 lib_preferred_mode = .Dynamic;1181 lib_preferred_mode = .dynamic;
1182 } else if (mem.eql(u8, arg, "-search_static_only")) {1182 } else if (mem.eql(u8, arg, "-search_static_only")) {
1183 lib_search_strategy = .no_fallback;1183 lib_search_strategy = .no_fallback;
1184 lib_preferred_mode = .Static;1184 lib_preferred_mode = .static;
1185 } else if (mem.eql(u8, arg, "-headerpad")) {1185 } else if (mem.eql(u8, arg, "-headerpad")) {
1186 const next_arg = args_iter.nextOrFatal();1186 const next_arg = args_iter.nextOrFatal();
1187 headerpad_size = std.fmt.parseUnsigned(u32, eatIntPrefix(next_arg, 16), 16) catch |err| {1187 headerpad_size = std.fmt.parseUnsigned(u32, eatIntPrefix(next_arg, 16), 16) catch |err| {
...@@ -1478,12 +1478,12 @@ fn buildOutputType(...@@ -1478,12 +1478,12 @@ fn buildOutputType(
1478 emit_implib = .no;1478 emit_implib = .no;
1479 emit_implib_arg_provided = true;1479 emit_implib_arg_provided = true;
1480 } else if (mem.eql(u8, arg, "-dynamic")) {1480 } else if (mem.eql(u8, arg, "-dynamic")) {
1481 create_module.opts.link_mode = .Dynamic;1481 create_module.opts.link_mode = .dynamic;
1482 lib_preferred_mode = .Dynamic;1482 lib_preferred_mode = .dynamic;
1483 lib_search_strategy = .mode_first;1483 lib_search_strategy = .mode_first;
1484 } else if (mem.eql(u8, arg, "-static")) {1484 } else if (mem.eql(u8, arg, "-static")) {
1485 create_module.opts.link_mode = .Static;1485 create_module.opts.link_mode = .static;
1486 lib_preferred_mode = .Static;1486 lib_preferred_mode = .static;
1487 lib_search_strategy = .no_fallback;1487 lib_search_strategy = .no_fallback;
1488 } else if (mem.eql(u8, arg, "-fdll-export-fns")) {1488 } else if (mem.eql(u8, arg, "-fdll-export-fns")) {
1489 create_module.opts.dll_export_fns = true;1489 create_module.opts.dll_export_fns = true;
...@@ -1904,7 +1904,7 @@ fn buildOutputType(...@@ -1904,7 +1904,7 @@ fn buildOutputType(
1904 },1904 },
1905 .nostdlib_cpp => create_module.opts.ensure_libcpp_on_non_freestanding = false,1905 .nostdlib_cpp => create_module.opts.ensure_libcpp_on_non_freestanding = false,
1906 .shared => {1906 .shared => {
1907 create_module.opts.link_mode = .Dynamic;1907 create_module.opts.link_mode = .dynamic;
1908 is_shared_lib = true;1908 is_shared_lib = true;
1909 },1909 },
1910 .rdynamic => create_module.opts.rdynamic = true,1910 .rdynamic => create_module.opts.rdynamic = true,
...@@ -1961,20 +1961,20 @@ fn buildOutputType(...@@ -1961,20 +1961,20 @@ fn buildOutputType(
1961 mem.eql(u8, linker_arg, "-call_shared"))1961 mem.eql(u8, linker_arg, "-call_shared"))
1962 {1962 {
1963 lib_search_strategy = .no_fallback;1963 lib_search_strategy = .no_fallback;
1964 lib_preferred_mode = .Dynamic;1964 lib_preferred_mode = .dynamic;
1965 } else if (mem.eql(u8, linker_arg, "-Bstatic") or1965 } else if (mem.eql(u8, linker_arg, "-Bstatic") or
1966 mem.eql(u8, linker_arg, "-dn") or1966 mem.eql(u8, linker_arg, "-dn") or
1967 mem.eql(u8, linker_arg, "-non_shared") or1967 mem.eql(u8, linker_arg, "-non_shared") or
1968 mem.eql(u8, linker_arg, "-static"))1968 mem.eql(u8, linker_arg, "-static"))
1969 {1969 {
1970 lib_search_strategy = .no_fallback;1970 lib_search_strategy = .no_fallback;
1971 lib_preferred_mode = .Static;1971 lib_preferred_mode = .static;
1972 } else if (mem.eql(u8, linker_arg, "-search_paths_first")) {1972 } else if (mem.eql(u8, linker_arg, "-search_paths_first")) {
1973 lib_search_strategy = .paths_first;1973 lib_search_strategy = .paths_first;
1974 lib_preferred_mode = .Dynamic;1974 lib_preferred_mode = .dynamic;
1975 } else if (mem.eql(u8, linker_arg, "-search_dylibs_first")) {1975 } else if (mem.eql(u8, linker_arg, "-search_dylibs_first")) {
1976 lib_search_strategy = .mode_first;1976 lib_search_strategy = .mode_first;
1977 lib_preferred_mode = .Dynamic;1977 lib_preferred_mode = .dynamic;
1978 } else {1978 } else {
1979 try linker_args.append(linker_arg);1979 try linker_args.append(linker_arg);
1980 }1980 }
...@@ -3033,7 +3033,7 @@ fn buildOutputType(...@@ -3033,7 +3033,7 @@ fn buildOutputType(
30333033
3034 const is_exe_or_dyn_lib = switch (create_module.resolved_options.output_mode) {3034 const is_exe_or_dyn_lib = switch (create_module.resolved_options.output_mode) {
3035 .Obj => false,3035 .Obj => false,
3036 .Lib => create_module.resolved_options.link_mode == .Dynamic,3036 .Lib => create_module.resolved_options.link_mode == .dynamic,
3037 .Exe => true,3037 .Exe => true,
3038 };3038 };
3039 // Note that cmake when targeting Windows will try to execute3039 // Note that cmake when targeting Windows will try to execute
...@@ -3770,8 +3770,8 @@ fn createModule(...@@ -3770,8 +3770,8 @@ fn createModule(
3770 )) {3770 )) {
3771 const path = try arena.dupe(u8, test_path.items);3771 const path = try arena.dupe(u8, test_path.items);
3772 switch (info.preferred_mode) {3772 switch (info.preferred_mode) {
3773 .Static => try create_module.link_objects.append(arena, .{ .path = path }),3773 .static => try create_module.link_objects.append(arena, .{ .path = path }),
3774 .Dynamic => try create_module.resolved_system_libs.append(arena, .{3774 .dynamic => try create_module.resolved_system_libs.append(arena, .{
3775 .name = lib_name,3775 .name = lib_name,
3776 .lib = .{3776 .lib = .{
3777 .needed = info.needed,3777 .needed = info.needed,
...@@ -3804,8 +3804,8 @@ fn createModule(...@@ -3804,8 +3804,8 @@ fn createModule(
3804 )) {3804 )) {
3805 const path = try arena.dupe(u8, test_path.items);3805 const path = try arena.dupe(u8, test_path.items);
3806 switch (info.fallbackMode()) {3806 switch (info.fallbackMode()) {
3807 .Static => try create_module.link_objects.append(arena, .{ .path = path }),3807 .static => try create_module.link_objects.append(arena, .{ .path = path }),
3808 .Dynamic => try create_module.resolved_system_libs.append(arena, .{3808 .dynamic => try create_module.resolved_system_libs.append(arena, .{
3809 .name = lib_name,3809 .name = lib_name,
3810 .lib = .{3810 .lib = .{
3811 .needed = info.needed,3811 .needed = info.needed,
...@@ -3838,8 +3838,8 @@ fn createModule(...@@ -3838,8 +3838,8 @@ fn createModule(
3838 )) {3838 )) {
3839 const path = try arena.dupe(u8, test_path.items);3839 const path = try arena.dupe(u8, test_path.items);
3840 switch (info.preferred_mode) {3840 switch (info.preferred_mode) {
3841 .Static => try create_module.link_objects.append(arena, .{ .path = path }),3841 .static => try create_module.link_objects.append(arena, .{ .path = path }),
3842 .Dynamic => try create_module.resolved_system_libs.append(arena, .{3842 .dynamic => try create_module.resolved_system_libs.append(arena, .{
3843 .name = lib_name,3843 .name = lib_name,
3844 .lib = .{3844 .lib = .{
3845 .needed = info.needed,3845 .needed = info.needed,
...@@ -3862,8 +3862,8 @@ fn createModule(...@@ -3862,8 +3862,8 @@ fn createModule(
3862 )) {3862 )) {
3863 const path = try arena.dupe(u8, test_path.items);3863 const path = try arena.dupe(u8, test_path.items);
3864 switch (info.fallbackMode()) {3864 switch (info.fallbackMode()) {
3865 .Static => try create_module.link_objects.append(arena, .{ .path = path }),3865 .static => try create_module.link_objects.append(arena, .{ .path = path }),
3866 .Dynamic => try create_module.resolved_system_libs.append(arena, .{3866 .dynamic => try create_module.resolved_system_libs.append(arena, .{
3867 .name = lib_name,3867 .name = lib_name,
3868 .lib = .{3868 .lib = .{
3869 .needed = info.needed,3869 .needed = info.needed,
...@@ -6842,7 +6842,7 @@ fn accessLibPath(...@@ -6842,7 +6842,7 @@ fn accessLibPath(
6842) !bool {6842) !bool {
6843 const sep = fs.path.sep_str;6843 const sep = fs.path.sep_str;
68446844
6845 if (target.isDarwin() and link_mode == .Dynamic) tbd: {6845 if (target.isDarwin() and link_mode == .dynamic) tbd: {
6846 // Prefer .tbd over .dylib.6846 // Prefer .tbd over .dylib.
6847 test_path.clearRetainingCapacity();6847 test_path.clearRetainingCapacity();
6848 try test_path.writer().print("{s}" ++ sep ++ "lib{s}.tbd", .{ lib_dir_path, lib_name });6848 try test_path.writer().print("{s}" ++ sep ++ "lib{s}.tbd", .{ lib_dir_path, lib_name });
...@@ -6863,8 +6863,8 @@ fn accessLibPath(...@@ -6863,8 +6863,8 @@ fn accessLibPath(
6863 target.libPrefix(),6863 target.libPrefix(),
6864 lib_name,6864 lib_name,
6865 switch (link_mode) {6865 switch (link_mode) {
6866 .Static => target.staticLibSuffix(),6866 .static => target.staticLibSuffix(),
6867 .Dynamic => target.dynamicLibSuffix(),6867 .dynamic => target.dynamicLibSuffix(),
6868 },6868 },
6869 });6869 });
6870 try checked_paths.writer().print("\n {s}", .{test_path.items});6870 try checked_paths.writer().print("\n {s}", .{test_path.items});
...@@ -6879,7 +6879,7 @@ fn accessLibPath(...@@ -6879,7 +6879,7 @@ fn accessLibPath(
68796879
6880 // In the case of Darwin, the main check will be .dylib, so here we6880 // In the case of Darwin, the main check will be .dylib, so here we
6881 // additionally check for .so files.6881 // additionally check for .so files.
6882 if (target.isDarwin() and link_mode == .Dynamic) so: {6882 if (target.isDarwin() and link_mode == .dynamic) so: {
6883 test_path.clearRetainingCapacity();6883 test_path.clearRetainingCapacity();
6884 try test_path.writer().print("{s}" ++ sep ++ "lib{s}.so", .{ lib_dir_path, lib_name });6884 try test_path.writer().print("{s}" ++ sep ++ "lib{s}.so", .{ lib_dir_path, lib_name });
6885 try checked_paths.writer().print("\n {s}", .{test_path.items});6885 try checked_paths.writer().print("\n {s}", .{test_path.items});
...@@ -6894,7 +6894,7 @@ fn accessLibPath(...@@ -6894,7 +6894,7 @@ fn accessLibPath(
68946894
6895 // In the case of MinGW, the main check will be .lib but we also need to6895 // In the case of MinGW, the main check will be .lib but we also need to
6896 // look for `libfoo.a`.6896 // look for `libfoo.a`.
6897 if (target.isMinGW() and link_mode == .Static) mingw: {6897 if (target.isMinGW() and link_mode == .static) mingw: {
6898 test_path.clearRetainingCapacity();6898 test_path.clearRetainingCapacity();
6899 try test_path.writer().print("{s}" ++ sep ++ "lib{s}.a", .{6899 try test_path.writer().print("{s}" ++ sep ++ "lib{s}.a", .{
6900 lib_dir_path, lib_name,6900 lib_dir_path, lib_name,
src/musl.zig+1-1
...@@ -207,7 +207,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr...@@ -207,7 +207,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
207 const strip = comp.compilerRtStrip();207 const strip = comp.compilerRtStrip();
208 const config = try Compilation.Config.resolve(.{208 const config = try Compilation.Config.resolve(.{
209 .output_mode = .Lib,209 .output_mode = .Lib,
210 .link_mode = .Dynamic,210 .link_mode = .dynamic,
211 .resolved_target = comp.root_mod.resolved_target,211 .resolved_target = comp.root_mod.resolved_target,
212 .is_test = false,212 .is_test = false,
213 .have_zcu = false,213 .have_zcu = false,
test/behavior/export_builtin.zig+2-2
...@@ -25,7 +25,7 @@ test "exporting with internal linkage" {...@@ -25,7 +25,7 @@ test "exporting with internal linkage" {
25 const S = struct {25 const S = struct {
26 fn foo() callconv(.C) void {}26 fn foo() callconv(.C) void {}
27 comptime {27 comptime {
28 @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .Internal });28 @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });
29 }29 }
30 };30 };
31 S.foo();31 S.foo();
...@@ -41,7 +41,7 @@ test "exporting using field access" {...@@ -41,7 +41,7 @@ test "exporting using field access" {
41 const x: u32 = 5;41 const x: u32 = 5;
42 };42 };
43 comptime {43 comptime {
44 @export(Inner.x, .{ .name = "foo", .linkage = .Internal });44 @export(Inner.x, .{ .name = "foo", .linkage = .internal });
45 }45 }
46 };46 };
4747
test/standalone/global_linkage/obj1.zig+2-2
...@@ -2,6 +2,6 @@ var internal_integer: usize = 1;...@@ -2,6 +2,6 @@ var internal_integer: usize = 1;
2var obj1_integer: usize = 421;2var obj1_integer: usize = 421;
33
4comptime {4comptime {
5 @export(internal_integer, .{ .name = "internal_integer", .linkage = .Internal });5 @export(internal_integer, .{ .name = "internal_integer", .linkage = .internal });
6 @export(obj1_integer, .{ .name = "obj1_integer", .linkage = .Strong });6 @export(obj1_integer, .{ .name = "obj1_integer", .linkage = .strong });
7}7}
test/standalone/global_linkage/obj2.zig+2-2
...@@ -2,6 +2,6 @@ var internal_integer: usize = 2;...@@ -2,6 +2,6 @@ var internal_integer: usize = 2;
2var obj2_integer: usize = 422;2var obj2_integer: usize = 422;
33
4comptime {4comptime {
5 @export(internal_integer, .{ .name = "internal_integer", .linkage = .Internal });5 @export(internal_integer, .{ .name = "internal_integer", .linkage = .internal });
6 @export(obj2_integer, .{ .name = "obj2_integer", .linkage = .Strong });6 @export(obj2_integer, .{ .name = "obj2_integer", .linkage = .strong });
7}7}
tools/docgen.zig+3-3
...@@ -629,7 +629,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -629,7 +629,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
629 } else if (mem.eql(u8, end_tag_name, "link_libc")) {629 } else if (mem.eql(u8, end_tag_name, "link_libc")) {
630 link_libc = true;630 link_libc = true;
631 } else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) {631 } else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) {
632 link_mode = .Dynamic;632 link_mode = .dynamic;
633 } else if (mem.eql(u8, end_tag_name, "additonal_option")) {633 } else if (mem.eql(u8, end_tag_name, "additonal_option")) {
634 _ = try eatToken(tokenizer, .separator);634 _ = try eatToken(tokenizer, .separator);
635 const option = try eatToken(tokenizer, .tag_content);635 const option = try eatToken(tokenizer, .tag_content);
...@@ -1793,11 +1793,11 @@ fn genHtml(...@@ -1793,11 +1793,11 @@ fn genHtml(
1793 }1793 }
1794 if (code.link_mode) |link_mode| {1794 if (code.link_mode) |link_mode| {
1795 switch (link_mode) {1795 switch (link_mode) {
1796 .Static => {1796 .static => {
1797 try test_args.append("-static");1797 try test_args.append("-static");
1798 try shell_out.print("-static ", .{});1798 try shell_out.print("-static ", .{});
1799 },1799 },
1800 .Dynamic => {1800 .dynamic => {
1801 try test_args.append("-dynamic");1801 try test_args.append("-dynamic");
1802 try shell_out.print("-dynamic ", .{});1802 try shell_out.print("-dynamic ", .{});
1803 },1803 },