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