From 9d70d614ae33133f3786ec056b8660476ff49f53 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Sun, 18 Feb 2024 20:34:32 -0800 Subject: [PATCH] std.builtin: make link mode fields lowercase --- build.zig | 2 +- lib/c.zig | 20 ++++---- lib/compiler_rt/os_version_check.zig | 2 +- lib/compiler_rt/stack_probe.zig | 4 +- lib/std/Build.zig | 2 +- lib/std/Build/Module.zig | 2 +- lib/std/Build/Step/Compile.zig | 31 +++++------- lib/std/Build/Step/TranslateC.zig | 2 +- lib/std/builtin.zig | 4 +- lib/std/c/darwin.zig | 2 +- lib/std/dynamic_library.zig | 2 +- lib/std/os/linux.zig | 2 +- lib/std/start.zig | 2 +- lib/std/zig.zig | 24 +++++----- src/Compilation.zig | 12 ++--- src/Compilation/Config.zig | 24 +++++----- src/Package/Module.zig | 2 +- src/arch/x86_64/Emit.zig | 4 +- src/arch/x86_64/Lower.zig | 2 +- src/glibc.zig | 2 +- src/libcxx.zig | 4 +- src/libtsan.zig | 2 +- src/libunwind.zig | 2 +- src/link.zig | 12 ++--- src/link/Coff.zig | 2 +- src/link/Coff/lld.zig | 10 ++-- src/link/Elf.zig | 52 ++++++++++---------- src/link/MachO/load_commands.zig | 2 +- src/link/Wasm.zig | 6 +-- src/main.zig | 64 ++++++++++++------------- src/musl.zig | 2 +- test/behavior/export_builtin.zig | 4 +- test/standalone/global_linkage/obj1.zig | 4 +- test/standalone/global_linkage/obj2.zig | 4 +- tools/docgen.zig | 6 +-- 35 files changed, 159 insertions(+), 164 deletions(-) diff --git a/build.zig b/build.zig index 1380ff7c36..243df2967a 100644 --- a/build.zig +++ b/build.zig @@ -855,7 +855,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void { } const CMakeConfig = struct { - llvm_linkage: std.Build.Step.Compile.Linkage, + llvm_linkage: std.builtin.LinkMode, cmake_binary_dir: []const u8, cmake_prefix_path: []const u8, cmake_static_library_prefix: []const u8, diff --git a/lib/c.zig b/lib/c.zig index 5d5040de7e..0534013d3b 100644 --- a/lib/c.zig +++ b/lib/c.zig @@ -26,7 +26,7 @@ const is_freestanding = switch (native_os) { comptime { if (is_freestanding and is_wasm and builtin.link_libc) { - @export(wasm_start, .{ .name = "_start", .linkage = .Strong }); + @export(wasm_start, .{ .name = "_start", .linkage = .strong }); } if (native_os == .linux) { @@ -34,16 +34,16 @@ comptime { } if (builtin.link_libc) { - @export(strcmp, .{ .name = "strcmp", .linkage = .Strong }); - @export(strncmp, .{ .name = "strncmp", .linkage = .Strong }); - @export(strerror, .{ .name = "strerror", .linkage = .Strong }); - @export(strlen, .{ .name = "strlen", .linkage = .Strong }); - @export(strcpy, .{ .name = "strcpy", .linkage = .Strong }); - @export(strncpy, .{ .name = "strncpy", .linkage = .Strong }); - @export(strcat, .{ .name = "strcat", .linkage = .Strong }); - @export(strncat, .{ .name = "strncat", .linkage = .Strong }); + @export(strcmp, .{ .name = "strcmp", .linkage = .strong }); + @export(strncmp, .{ .name = "strncmp", .linkage = .strong }); + @export(strerror, .{ .name = "strerror", .linkage = .strong }); + @export(strlen, .{ .name = "strlen", .linkage = .strong }); + @export(strcpy, .{ .name = "strcpy", .linkage = .strong }); + @export(strncpy, .{ .name = "strncpy", .linkage = .strong }); + @export(strcat, .{ .name = "strcat", .linkage = .strong }); + @export(strncat, .{ .name = "strncat", .linkage = .strong }); } else if (is_msvc) { - @export(_fltused, .{ .name = "_fltused", .linkage = .Strong }); + @export(_fltused, .{ .name = "_fltused", .linkage = .strong }); } } diff --git a/lib/compiler_rt/os_version_check.zig b/lib/compiler_rt/os_version_check.zig index 8b68154832..80353d5e5f 100644 --- a/lib/compiler_rt/os_version_check.zig +++ b/lib/compiler_rt/os_version_check.zig @@ -1,7 +1,7 @@ const std = @import("std"); const testing = std.testing; const builtin = @import("builtin"); -const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; +const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak; const panic = @import("common.zig").panic; const have_availability_version_check = builtin.os.tag.isDarwin() and diff --git a/lib/compiler_rt/stack_probe.zig b/lib/compiler_rt/stack_probe.zig index 09d535bd51..5533464dcd 100644 --- a/lib/compiler_rt/stack_probe.zig +++ b/lib/compiler_rt/stack_probe.zig @@ -8,8 +8,8 @@ const is_test = builtin.is_test; const is_gnu = abi.isGnu(); const is_mingw = os_tag == .windows and is_gnu; -const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; -const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Strong; +const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak; +const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .strong; pub const panic = @import("common.zig").panic; comptime { diff --git a/lib/std/Build.zig b/lib/std/Build.zig index 3892b9ca73..9ad4d0a69b 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -645,7 +645,7 @@ pub const ExecutableOptions = struct { version: ?std.SemanticVersion = null, optimize: std.builtin.OptimizeMode = .Debug, code_model: std.builtin.CodeModel = .default, - linkage: ?Step.Compile.Linkage = null, + linkage: ?std.builtin.LinkMode = null, max_rss: usize = 0, link_libc: ?bool = null, single_threaded: ?bool = null, diff --git a/lib/std/Build/Module.zig b/lib/std/Build/Module.zig index c6d908158c..12cbda39a0 100644 --- a/lib/std/Build/Module.zig +++ b/lib/std/Build/Module.zig @@ -414,7 +414,7 @@ pub const LinkSystemLibraryOptions = struct { needed: bool = false, weak: bool = false, use_pkg_config: SystemLib.UsePkgConfig = .yes, - preferred_link_mode: std.builtin.LinkMode = .Dynamic, + preferred_link_mode: std.builtin.LinkMode = .dynamic, search_strategy: SystemLib.SearchStrategy = .paths_first, }; diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig index a7f6911b2f..75f01dbf5e 100644 --- a/lib/std/Build/Step/Compile.zig +++ b/lib/std/Build/Step/Compile.zig @@ -28,7 +28,7 @@ linker_script: ?LazyPath = null, version_script: ?LazyPath = null, out_filename: []const u8, out_lib_filename: []const u8, -linkage: ?Linkage = null, +linkage: ?std.builtin.LinkMode = null, version: ?std.SemanticVersion, kind: Kind, major_only_filename: ?[]const u8, @@ -223,7 +223,7 @@ pub const Options = struct { name: []const u8, root_module: Module.CreateOptions, kind: Kind, - linkage: ?Linkage = null, + linkage: ?std.builtin.LinkMode = null, version: ?std.SemanticVersion = null, max_rss: usize = 0, filters: []const []const u8 = &.{}, @@ -246,8 +246,6 @@ pub const Kind = enum { @"test", }; -pub const Linkage = enum { dynamic, static }; - pub fn create(owner: *std.Build, options: Options) *Compile { const name = owner.dupe(options.name); 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 { .obj => .Obj, .exe, .@"test" => .Exe, }, - .link_mode = if (options.linkage) |some| @as(std.builtin.LinkMode, switch (some) { - .dynamic => .Dynamic, - .static => .Static, - }) else null, + .link_mode = options.linkage, .version = options.version, }) catch @panic("OOM"); @@ -531,11 +526,11 @@ pub fn dependsOnSystemLibrary(self: *const Compile, name: []const u8) bool { } pub fn isDynamicLibrary(self: *const Compile) bool { - return self.kind == .lib and self.linkage == Linkage.dynamic; + return self.kind == .lib and self.linkage == .dynamic; } pub fn isStaticLibrary(self: *const Compile) bool { - return self.kind == .lib and self.linkage != Linkage.dynamic; + return self.kind == .lib and self.linkage != .dynamic; } pub fn producesPdbFile(self: *Compile) bool { @@ -988,7 +983,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { var prev_has_cflags = false; var prev_has_rcflags = false; var prev_search_strategy: Module.SystemLib.SearchStrategy = .paths_first; - var prev_preferred_link_mode: std.builtin.LinkMode = .Dynamic; + var prev_preferred_link_mode: std.builtin.LinkMode = .dynamic; // Track the number of positional arguments so that a nice error can be // emitted if there is nothing to link. 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 { { switch (system_lib.search_strategy) { .no_fallback => switch (system_lib.preferred_link_mode) { - .Dynamic => try zig_args.append("-search_dylibs_only"), - .Static => try zig_args.append("-search_static_only"), + .dynamic => try zig_args.append("-search_dylibs_only"), + .static => try zig_args.append("-search_static_only"), }, .paths_first => switch (system_lib.preferred_link_mode) { - .Dynamic => try zig_args.append("-search_paths_first"), - .Static => try zig_args.append("-search_paths_first_static"), + .dynamic => try zig_args.append("-search_paths_first"), + .static => try zig_args.append("-search_paths_first_static"), }, .mode_first => switch (system_lib.preferred_link_mode) { - .Dynamic => try zig_args.append("-search_dylibs_first"), - .Static => try zig_args.append("-search_static_first"), + .dynamic => try zig_args.append("-search_dylibs_first"), + .static => try zig_args.append("-search_static_first"), }, } prev_search_strategy = system_lib.search_strategy; @@ -1138,7 +1133,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { try zig_args.append(full_path_lib); total_linker_objects += 1; - if (other.linkage == Linkage.dynamic and + if (other.linkage == .dynamic and self.rootModuleTarget().os.tag != .windows) { if (fs.path.dirname(full_path_lib)) |dirname| { diff --git a/lib/std/Build/Step/TranslateC.zig b/lib/std/Build/Step/TranslateC.zig index 223b004993..7d69ffa8b0 100644 --- a/lib/std/Build/Step/TranslateC.zig +++ b/lib/std/Build/Step/TranslateC.zig @@ -55,7 +55,7 @@ pub const AddExecutableOptions = struct { version: ?std.SemanticVersion = null, target: ?std.Build.ResolvedTarget = null, optimize: ?std.builtin.OptimizeMode = null, - linkage: ?Step.Compile.Linkage = null, + linkage: ?std.builtin.LinkMode = null, }; pub fn getOutput(self: *TranslateC) std.Build.LazyPath { diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 6ebe955291..7e7fe951d2 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -500,8 +500,8 @@ pub const OutputMode = enum { /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. pub const LinkMode = enum { - Static, - Dynamic, + static, + dynamic, }; /// This data structure is used by the Zig language code generation and diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig index 947abe58c9..a58ce6e2dd 100644 --- a/lib/std/c/darwin.zig +++ b/lib/std/c/darwin.zig @@ -202,7 +202,7 @@ var dummy_execute_header: mach_hdr = undefined; pub extern var _mh_execute_header: mach_hdr; comptime { if (builtin.target.isDarwin()) { - @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .Weak }); + @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak }); } } diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig index ebfe8fe0ee..a37e4f6d40 100644 --- a/lib/std/dynamic_library.zig +++ b/lib/std/dynamic_library.zig @@ -56,7 +56,7 @@ const RDebug = extern struct { /// TODO make it possible to reference this same external symbol 2x so we don't need this /// helper function. pub fn get_DYNAMIC() ?[*]elf.Dyn { - return @extern([*]elf.Dyn, .{ .name = "_DYNAMIC", .linkage = .Weak }); + return @extern([*]elf.Dyn, .{ .name = "_DYNAMIC", .linkage = .weak }); } pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator { diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 6ec92cce4e..440d854120 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -394,7 +394,7 @@ const extern_getauxval = switch (builtin.zig_backend) { comptime { if (extern_getauxval) { - @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .Weak }); + @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak }); } } diff --git a/lib/std/start.zig b/lib/std/start.zig index 9e9872fe93..49695a3a25 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -50,7 +50,7 @@ comptime { } } } else { - if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) { + if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) { if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) { @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" }); } diff --git a/lib/std/zig.zig b/lib/std/zig.zig index c887030ae6..ce446e59b6 100644 --- a/lib/std/zig.zig +++ b/lib/std/zig.zig @@ -155,9 +155,9 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe .coff => switch (options.output_mode) { .Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, t.exeFileExt() }), .Lib => { - const suffix = switch (options.link_mode orelse .Static) { - .Static => ".lib", - .Dynamic => ".dll", + const suffix = switch (options.link_mode orelse .static) { + .static => ".lib", + .dynamic => ".dll", }; return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, suffix }); }, @@ -166,11 +166,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe .elf => switch (options.output_mode) { .Exe => return allocator.dupe(u8, root_name), .Lib => { - switch (options.link_mode orelse .Static) { - .Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ + switch (options.link_mode orelse .static) { + .static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ t.libPrefix(), root_name, }), - .Dynamic => { + .dynamic => { if (options.version) |ver| { return std.fmt.allocPrint(allocator, "{s}{s}.so.{d}.{d}.{d}", .{ t.libPrefix(), root_name, ver.major, ver.minor, ver.patch, @@ -188,11 +188,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe .macho => switch (options.output_mode) { .Exe => return allocator.dupe(u8, root_name), .Lib => { - switch (options.link_mode orelse .Static) { - .Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ + switch (options.link_mode orelse .static) { + .static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ t.libPrefix(), root_name, }), - .Dynamic => { + .dynamic => { if (options.version) |ver| { return std.fmt.allocPrint(allocator, "{s}{s}.{d}.{d}.{d}.dylib", .{ t.libPrefix(), root_name, ver.major, ver.minor, ver.patch, @@ -210,11 +210,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe .wasm => switch (options.output_mode) { .Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, t.exeFileExt() }), .Lib => { - switch (options.link_mode orelse .Static) { - .Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ + switch (options.link_mode orelse .static) { + .static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ t.libPrefix(), root_name, }), - .Dynamic => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}), + .dynamic => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}), } }, .Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}), diff --git a/src/Compilation.zig b/src/Compilation.zig index 13fb672042..0fdfb6038f 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1201,7 +1201,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil const output_mode = options.config.output_mode; const is_dyn_lib = switch (output_mode) { .Obj, .Exe => false, - .Lib => options.config.link_mode == .Dynamic, + .Lib => options.config.link_mode == .dynamic, }; const is_exe_or_dyn_lib = switch (output_mode) { .Obj => false, @@ -1806,8 +1806,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil .{ .musl_crt_file = .scrt1_o }, .{ .musl_crt_file = .rcrt1_o }, switch (comp.config.link_mode) { - .Static => .{ .musl_crt_file = .libc_a }, - .Dynamic => .{ .musl_crt_file = .libc_so }, + .static => .{ .musl_crt_file = .libc_a }, + .dynamic => .{ .musl_crt_file = .libc_so }, }, }); } @@ -6087,7 +6087,7 @@ pub fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const fn wantBuildLibCFromSource(comp: Compilation) bool { const is_exe_or_dyn_lib = switch (comp.config.output_mode) { .Obj => false, - .Lib => comp.config.link_mode == .Dynamic, + .Lib => comp.config.link_mode == .dynamic, .Exe => true, }; const ofmt = comp.root_mod.resolved_target.result.ofmt; @@ -6116,7 +6116,7 @@ fn wantBuildMinGWFromSource(comp: Compilation) bool { fn wantBuildLibUnwindFromSource(comp: *Compilation) bool { const is_exe_or_dyn_lib = switch (comp.config.output_mode) { .Obj => false, - .Lib => comp.config.link_mode == .Dynamic, + .Lib => comp.config.link_mode == .dynamic, .Exe => true, }; const ofmt = comp.root_mod.resolved_target.result.ofmt; @@ -6310,7 +6310,7 @@ fn buildOutputFromZig( const config = try Config.resolve(.{ .output_mode = output_mode, - .link_mode = .Static, + .link_mode = .static, .resolved_target = comp.root_mod.resolved_target, .is_test = false, .have_zcu = true, diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig index 2f6422b28a..d692fe5623 100644 --- a/src/Compilation/Config.zig +++ b/src/Compilation/Config.zig @@ -348,26 +348,26 @@ pub fn resolve(options: Options) ResolveError!Config { const link_mode = b: { const explicitly_exe_or_dyn_lib = switch (options.output_mode) { .Obj => false, - .Lib => (options.link_mode orelse .Static) == .Dynamic, + .Lib => (options.link_mode orelse .static) == .dynamic, .Exe => true, }; if (target_util.cannotDynamicLink(target)) { - if (options.link_mode == .Dynamic) return error.TargetCannotDynamicLink; - break :b .Static; + if (options.link_mode == .dynamic) return error.TargetCannotDynamicLink; + break :b .static; } if (explicitly_exe_or_dyn_lib and link_libc and (target.isGnuLibC() or target_util.osRequiresLibC(target))) { - if (options.link_mode == .Static) return error.LibCRequiresDynamicLinking; - break :b .Dynamic; + if (options.link_mode == .static) return error.LibCRequiresDynamicLinking; + break :b .dynamic; } // When creating a executable that links to system libraries, we // require dynamic linking, but we must not link static libraries // or object files dynamically! if (options.any_dyn_libs and options.output_mode == .Exe) { - if (options.link_mode == .Static) return error.SharedLibrariesRequireDynamicLinking; - break :b .Dynamic; + if (options.link_mode == .static) return error.SharedLibrariesRequireDynamicLinking; + break :b .dynamic; } if (options.link_mode) |link_mode| break :b link_mode; @@ -377,16 +377,16 @@ pub fn resolve(options: Options) ResolveError!Config { { // If targeting the system's native ABI and the system's libc is // musl, link dynamically by default. - break :b .Dynamic; + break :b .dynamic; } // Static is generally a better default. Fight me. - break :b .Static; + break :b .static; }; const import_memory = options.import_memory orelse (options.output_mode == .Obj); const export_memory = b: { - if (link_mode == .Dynamic) { + if (link_mode == .dynamic) { if (options.export_memory == true) return error.ExportMemoryAndDynamicIncompatible; break :b false; } @@ -397,7 +397,7 @@ pub fn resolve(options: Options) ResolveError!Config { const pie: bool = b: { switch (options.output_mode) { .Obj, .Exe => {}, - .Lib => if (link_mode == .Dynamic) { + .Lib => if (link_mode == .dynamic) { if (options.pie == true) return error.DynamicLibraryPrecludesPie; break :b false; }, @@ -467,7 +467,7 @@ pub fn resolve(options: Options) ResolveError!Config { if (rdynamic) break :b true; break :b switch (options.output_mode) { .Obj, .Exe => false, - .Lib => link_mode == .Dynamic, + .Lib => link_mode == .dynamic, }; }; diff --git a/src/Package/Module.zig b/src/Package/Module.zig index c6eb1e8c90..d6b89efb41 100644 --- a/src/Package/Module.zig +++ b/src/Package/Module.zig @@ -178,7 +178,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { return error.PieRequiresPic; break :b true; } - if (options.global.link_mode == .Dynamic) { + if (options.global.link_mode == .dynamic) { if (options.inherited.pic == false) return error.DynamicLinkingRequiresPic; break :b true; diff --git a/src/arch/x86_64/Emit.zig b/src/arch/x86_64/Emit.zig index 0975104db3..ae54904aaf 100644 --- a/src/arch/x86_64/Emit.zig +++ b/src/arch/x86_64/Emit.zig @@ -110,7 +110,7 @@ pub fn emitMir(emit: *Emit) Error!void { const is_obj_or_static_lib = switch (emit.lower.output_mode) { .Exe => false, .Obj => true, - .Lib => emit.lower.link_mode == .Static, + .Lib => emit.lower.link_mode == .static, }; const atom = elf_file.symbol(data.atom_index).atom(elf_file).?; const sym_index = elf_file.zigObjectPtr().?.symbol(data.sym_index); @@ -158,7 +158,7 @@ pub fn emitMir(emit: *Emit) Error!void { const is_obj_or_static_lib = switch (emit.lower.output_mode) { .Exe => false, .Obj => true, - .Lib => emit.lower.link_mode == .Static, + .Lib => emit.lower.link_mode == .static, }; const atom = macho_file.getSymbol(data.atom_index).getAtom(macho_file).?; const sym_index = macho_file.getZigObject().?.symbols.items[data.sym_index]; diff --git a/src/arch/x86_64/Lower.zig b/src/arch/x86_64/Lower.zig index 13b97b551a..578fc022a0 100644 --- a/src/arch/x86_64/Lower.zig +++ b/src/arch/x86_64/Lower.zig @@ -329,7 +329,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand) const is_obj_or_static_lib = switch (lower.output_mode) { .Exe => false, .Obj => true, - .Lib => lower.link_mode == .Static, + .Lib => lower.link_mode == .static, }; const emit_prefix = prefix; diff --git a/src/glibc.zig b/src/glibc.zig index 5a2caa6809..9765e0ad78 100644 --- a/src/glibc.zig +++ b/src/glibc.zig @@ -1084,7 +1084,7 @@ fn buildSharedLib( const strip = comp.compilerRtStrip(); const config = try Compilation.Config.resolve(.{ .output_mode = .Lib, - .link_mode = .Dynamic, + .link_mode = .dynamic, .resolved_target = comp.root_mod.resolved_target, .is_test = false, .have_zcu = false, diff --git a/src/libcxx.zig b/src/libcxx.zig index 980836b682..dc1930be4d 100644 --- a/src/libcxx.zig +++ b/src/libcxx.zig @@ -115,7 +115,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { const root_name = "c++"; const output_mode = .Lib; - const link_mode = .Static; + const link_mode = .static; const target = comp.root_mod.resolved_target.result; const basename = try std.zig.binNameAlloc(arena, .{ .root_name = root_name, @@ -327,7 +327,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { const root_name = "c++abi"; const output_mode = .Lib; - const link_mode = .Static; + const link_mode = .static; const target = comp.root_mod.resolved_target.result; const basename = try std.zig.binNameAlloc(arena, .{ .root_name = root_name, diff --git a/src/libtsan.zig b/src/libtsan.zig index 95b44dad76..8f8ecce67d 100644 --- a/src/libtsan.zig +++ b/src/libtsan.zig @@ -27,7 +27,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!v const root_name = "tsan"; const output_mode = .Lib; - const link_mode = .Static; + const link_mode = .static; const target = comp.getTarget(); const basename = try std.zig.binNameAlloc(arena, .{ .root_name = root_name, diff --git a/src/libunwind.zig b/src/libunwind.zig index 8de6f5a99a..2fae6a65f9 100644 --- a/src/libunwind.zig +++ b/src/libunwind.zig @@ -62,7 +62,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void { }); const root_name = "unwind"; - const link_mode = .Static; + const link_mode = .static; const target = comp.root_mod.resolved_target.result; const basename = try std.zig.binNameAlloc(arena, .{ .root_name = root_name, diff --git a/src/link.zig b/src/link.zig index be64325f30..631768a4de 100644 --- a/src/link.zig +++ b/src/link.zig @@ -287,8 +287,8 @@ pub const File = struct { switch (output_mode) { .Obj => return, .Lib => switch (link_mode) { - .Static => return, - .Dynamic => {}, + .static => return, + .dynamic => {}, }, .Exe => {}, } @@ -582,7 +582,7 @@ pub const File = struct { const use_lld = build_options.have_llvm and comp.config.use_lld; const output_mode = comp.config.output_mode; const link_mode = comp.config.link_mode; - if (use_lld and output_mode == .Lib and link_mode == .Static) { + if (use_lld and output_mode == .Lib and link_mode == .static) { return base.linkAsArchive(arena, prog_node); } switch (base.tag) { @@ -957,8 +957,8 @@ pub const File = struct { const executable_mode = if (builtin.target.os.tag == .windows) 0 else 0o777; switch (effectiveOutputMode(use_lld, output_mode)) { .Lib => return switch (link_mode) { - .Dynamic => executable_mode, - .Static => fs.File.default_mode, + .dynamic => executable_mode, + .static => fs.File.default_mode, }, .Exe => return executable_mode, .Obj => return fs.File.default_mode, @@ -966,7 +966,7 @@ pub const File = struct { } pub fn isStatic(self: File) bool { - return self.comp.config.link_mode == .Static; + return self.comp.config.link_mode == .static; } pub fn isObject(self: File) bool { diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 5bf83b52ea..adea78ca73 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -2275,7 +2275,7 @@ fn writeHeader(self: *Coff) !void { .p32 => flags.@"32BIT_MACHINE" = 1, .p64 => flags.LARGE_ADDRESS_AWARE = 1, } - if (self.base.comp.config.output_mode == .Lib and self.base.comp.config.link_mode == .Dynamic) { + if (self.base.comp.config.output_mode == .Lib and self.base.comp.config.link_mode == .dynamic) { flags.DLL = 1; } diff --git a/src/link/Coff/lld.zig b/src/link/Coff/lld.zig index 475090c31d..405c107628 100644 --- a/src/link/Coff/lld.zig +++ b/src/link/Coff/lld.zig @@ -45,7 +45,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) defer sub_prog_node.end(); const is_lib = comp.config.output_mode == .Lib; - const is_dyn_lib = comp.config.link_mode == .Dynamic and is_lib; + const is_dyn_lib = comp.config.link_mode == .dynamic and is_lib; const is_exe_or_dyn_lib = is_dyn_lib or comp.config.output_mode == .Exe; const link_in_crt = comp.config.link_libc and is_exe_or_dyn_lib; const target = comp.root_mod.resolved_target.result; @@ -411,16 +411,16 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) try argv.append(try comp.get_libc_crt_file(arena, "mingwex.lib")); } else { const lib_str = switch (comp.config.link_mode) { - .Dynamic => "", - .Static => "lib", + .dynamic => "", + .static => "lib", }; const d_str = switch (optimize_mode) { .Debug => "d", else => "", }; switch (comp.config.link_mode) { - .Static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})), - .Dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})), + .static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})), + .dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})), } try argv.append(try allocPrint(arena, "{s}vcruntime{s}.lib", .{ lib_str, d_str })); diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 85ef62b4bc..d26f49ca09 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -262,7 +262,7 @@ pub fn createEmpty( .sparc64 => 0x2000, else => 0x1000, }; - const is_dyn_lib = output_mode == .Lib and link_mode == .Dynamic; + const is_dyn_lib = output_mode == .Lib and link_mode == .dynamic; const default_sym_version: elf.Elf64_Versym = if (is_dyn_lib or comp.config.rdynamic) elf.VER_NDX_GLOBAL else @@ -349,7 +349,7 @@ pub fn createEmpty( } const is_obj = output_mode == .Obj; - const is_obj_or_ar = is_obj or (output_mode == .Lib and link_mode == .Static); + const is_obj_or_ar = is_obj or (output_mode == .Lib and link_mode == .static); // What path should this ELF linker code output to? // 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) success: { if (!self.base.isStatic()) { - if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .Dynamic)) + if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .dynamic)) break :success; } - if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .Static)) + if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .static)) break :success; try self.reportMissingLibraryError( @@ -1211,8 +1211,8 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) }); } else if (target.isMusl()) { const path = try comp.get_libc_crt_file(arena, switch (link_mode) { - .Static => "libc.a", - .Dynamic => "libc.so", + .static => "libc.a", + .dynamic => "libc.so", }); try system_libs.append(.{ .path = path }); } else { @@ -1628,7 +1628,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { // libc dep if (comp.config.link_libc) { if (self.base.comp.libc_installation != null) { - const needs_grouping = link_mode == .Static; + const needs_grouping = link_mode == .static; if (needs_grouping) try argv.append("--start-group"); try argv.appendSlice(target_util.libcFullLinkFlags(target)); if (needs_grouping) try argv.append("--end-group"); @@ -1642,8 +1642,8 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { try argv.append(try comp.get_libc_crt_file(arena, "libc_nonshared.a")); } else if (target.isMusl()) { try argv.append(try comp.get_libc_crt_file(arena, switch (link_mode) { - .Static => "libc.a", - .Dynamic => "libc.so", + .static => "libc.a", + .dynamic => "libc.so", })); } } @@ -1797,10 +1797,10 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void { // Maybe we should hoist search-strategy all the way here? for (self.lib_dirs) |lib_dir| { if (!self.base.isStatic()) { - if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .Dynamic)) + if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .dynamic)) break :success; } - if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .Static)) + if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .static)) break :success; } } else { @@ -1858,8 +1858,8 @@ fn accessLibPath( test_path.clearRetainingCapacity(); const prefix = if (link_mode != null) "lib" else ""; const suffix = if (link_mode) |mode| switch (mode) { - .Static => target.staticLibSuffix(), - .Dynamic => target.dynamicLibSuffix(), + .static => target.staticLibSuffix(), + .dynamic => target.dynamicLibSuffix(), } else ""; try test_path.writer().print("{s}" ++ sep ++ "{s}{s}{s}", .{ lib_dir_path, @@ -2150,10 +2150,10 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi const is_obj = output_mode == .Obj; const is_lib = output_mode == .Lib; const link_mode = comp.config.link_mode; - const is_dyn_lib = link_mode == .Dynamic and is_lib; + const is_dyn_lib = link_mode == .dynamic and is_lib; const is_exe_or_dyn_lib = is_dyn_lib or output_mode == .Exe; const have_dynamic_linker = comp.config.link_libc and - link_mode == .Dynamic and is_exe_or_dyn_lib; + link_mode == .dynamic and is_exe_or_dyn_lib; const target = comp.root_mod.resolved_target.result; const compiler_rt_path: ?[]const u8 = blk: { 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 try argv.append(arg); } - if (link_mode == .Static) { + if (link_mode == .static) { if (target.cpu.arch.isArmOrThumb()) { try argv.append("-Bstatic"); } else { @@ -2647,7 +2647,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi comp.link_error_flags.missing_libc = false; if (comp.config.link_libc) { if (comp.libc_installation != null) { - const needs_grouping = link_mode == .Static; + const needs_grouping = link_mode == .static; if (needs_grouping) try argv.append("--start-group"); try argv.appendSlice(target_util.libcFullLinkFlags(target)); if (needs_grouping) try argv.append("--end-group"); @@ -2661,8 +2661,8 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi try argv.append(try comp.get_libc_crt_file(arena, "libc_nonshared.a")); } else if (target.isMusl()) { try argv.append(try comp.get_libc_crt_file(arena, switch (link_mode) { - .Static => "libc.a", - .Dynamic => "libc.so", + .static => "libc.a", + .dynamic => "libc.so", })); } else { comp.link_error_flags.missing_libc = true; @@ -2928,8 +2928,8 @@ pub fn writeElfHeader(self: *Elf) !void { .Exe => if (comp.config.pie) .DYN else .EXEC, .Obj => .REL, .Lib => switch (link_mode) { - .Static => @as(elf.ET, .REL), - .Dynamic => .DYN, + .static => @as(elf.ET, .REL), + .dynamic => .DYN, }, }; mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(elf_type), endian); @@ -3216,7 +3216,7 @@ fn allocateLinkerDefinedSymbols(self: *Elf) void { // __rela_iplt_start, __rela_iplt_end if (self.rela_dyn_section_index) |shndx| blk: { - if (link_mode != .Static or comp.config.pie) break :blk; + if (link_mode != .static or comp.config.pie) break :blk; const shdr = &self.shdrs.items[shndx]; const end_addr = shdr.sh_addr + shdr.sh_size; const start_addr = end_addr - self.calcNumIRelativeRelocs() * @sizeOf(elf.Elf64_Rela); @@ -5061,12 +5061,12 @@ const CsuObjects = struct { } = switch (comp.config.output_mode) { .Obj => return CsuObjects{}, .Lib => switch (comp.config.link_mode) { - .Dynamic => .dynamic_lib, - .Static => return CsuObjects{}, + .dynamic => .dynamic_lib, + .static => return CsuObjects{}, }, .Exe => switch (comp.config.link_mode) { - .Dynamic => if (comp.config.pie) .dynamic_pie else .dynamic_exe, - .Static => if (comp.config.pie) .static_pie else .static_exe, + .dynamic => if (comp.config.pie) .dynamic_pie else .dynamic_exe, + .static => if (comp.config.pie) .static_pie else .static_exe, }, }; diff --git a/src/link/MachO/load_commands.zig b/src/link/MachO/load_commands.zig index 778fdd74c7..394253db48 100644 --- a/src/link/MachO/load_commands.zig +++ b/src/link/MachO/load_commands.zig @@ -222,7 +222,7 @@ pub fn writeDylibLC(ctx: WriteDylibLCCtx, writer: anytype) !void { pub fn writeDylibIdLC(macho_file: *MachO, writer: anytype) !void { const comp = macho_file.base.comp; const gpa = comp.gpa; - assert(comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic); + assert(comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic); const emit = macho_file.base.emit; const install_name = macho_file.install_name orelse try emit.directory.join(gpa, &.{emit.sub_path}); diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index c32a472213..128cec5b6e 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -2518,7 +2518,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) // When the target os is WASI, we allow linking with WASI-LIBC if (target.os.tag == .wasi) { const is_exe_or_dyn_lib = output_mode == .Exe or - (output_mode == .Lib and link_mode == .Dynamic); + (output_mode == .Lib and link_mode == .dynamic); if (is_exe_or_dyn_lib) { for (comp.wasi_emulated_libs) |crt_file| { 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 try argv.append("--allow-undefined"); } - if (comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic) { + if (comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic) { try argv.append("--shared"); } if (comp.config.pie) { @@ -3569,7 +3569,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo if (target.os.tag == .wasi) { const is_exe_or_dyn_lib = comp.config.output_mode == .Exe or - (comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic); + (comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic); if (is_exe_or_dyn_lib) { for (comp.wasi_emulated_libs) |crt_file| { try argv.append(try comp.get_libc_crt_file( diff --git a/src/main.zig b/src/main.zig index 5a187c65e9..2c9cd3e3e5 100644 --- a/src/main.zig +++ b/src/main.zig @@ -755,8 +755,8 @@ const SystemLib = struct { fn fallbackMode(this: SystemLib) std.builtin.LinkMode { assert(this.search_strategy != .no_fallback); return switch (this.preferred_mode) { - .Dynamic => .Static, - .Static => .Dynamic, + .dynamic => .static, + .static => .dynamic, }; } }; @@ -892,7 +892,7 @@ fn buildOutputType( var entitlements: ?[]const u8 = null; var pagezero_size: ?u64 = null; var lib_search_strategy: SystemLib.SearchStrategy = .paths_first; - var lib_preferred_mode: std.builtin.LinkMode = .Dynamic; + var lib_preferred_mode: std.builtin.LinkMode = .dynamic; var headerpad_size: ?u32 = null; var headerpad_max_install_names: bool = false; var dead_strip_dylibs: bool = false; @@ -1166,22 +1166,22 @@ fn buildOutputType( }; } else if (mem.eql(u8, arg, "-search_paths_first")) { lib_search_strategy = .paths_first; - lib_preferred_mode = .Dynamic; + lib_preferred_mode = .dynamic; } else if (mem.eql(u8, arg, "-search_paths_first_static")) { lib_search_strategy = .paths_first; - lib_preferred_mode = .Static; + lib_preferred_mode = .static; } else if (mem.eql(u8, arg, "-search_dylibs_first")) { lib_search_strategy = .mode_first; - lib_preferred_mode = .Dynamic; + lib_preferred_mode = .dynamic; } else if (mem.eql(u8, arg, "-search_static_first")) { lib_search_strategy = .mode_first; - lib_preferred_mode = .Static; + lib_preferred_mode = .static; } else if (mem.eql(u8, arg, "-search_dylibs_only")) { lib_search_strategy = .no_fallback; - lib_preferred_mode = .Dynamic; + lib_preferred_mode = .dynamic; } else if (mem.eql(u8, arg, "-search_static_only")) { lib_search_strategy = .no_fallback; - lib_preferred_mode = .Static; + lib_preferred_mode = .static; } else if (mem.eql(u8, arg, "-headerpad")) { const next_arg = args_iter.nextOrFatal(); headerpad_size = std.fmt.parseUnsigned(u32, eatIntPrefix(next_arg, 16), 16) catch |err| { @@ -1478,12 +1478,12 @@ fn buildOutputType( emit_implib = .no; emit_implib_arg_provided = true; } else if (mem.eql(u8, arg, "-dynamic")) { - create_module.opts.link_mode = .Dynamic; - lib_preferred_mode = .Dynamic; + create_module.opts.link_mode = .dynamic; + lib_preferred_mode = .dynamic; lib_search_strategy = .mode_first; } else if (mem.eql(u8, arg, "-static")) { - create_module.opts.link_mode = .Static; - lib_preferred_mode = .Static; + create_module.opts.link_mode = .static; + lib_preferred_mode = .static; lib_search_strategy = .no_fallback; } else if (mem.eql(u8, arg, "-fdll-export-fns")) { create_module.opts.dll_export_fns = true; @@ -1904,7 +1904,7 @@ fn buildOutputType( }, .nostdlib_cpp => create_module.opts.ensure_libcpp_on_non_freestanding = false, .shared => { - create_module.opts.link_mode = .Dynamic; + create_module.opts.link_mode = .dynamic; is_shared_lib = true; }, .rdynamic => create_module.opts.rdynamic = true, @@ -1961,20 +1961,20 @@ fn buildOutputType( mem.eql(u8, linker_arg, "-call_shared")) { lib_search_strategy = .no_fallback; - lib_preferred_mode = .Dynamic; + lib_preferred_mode = .dynamic; } else if (mem.eql(u8, linker_arg, "-Bstatic") or mem.eql(u8, linker_arg, "-dn") or mem.eql(u8, linker_arg, "-non_shared") or mem.eql(u8, linker_arg, "-static")) { lib_search_strategy = .no_fallback; - lib_preferred_mode = .Static; + lib_preferred_mode = .static; } else if (mem.eql(u8, linker_arg, "-search_paths_first")) { lib_search_strategy = .paths_first; - lib_preferred_mode = .Dynamic; + lib_preferred_mode = .dynamic; } else if (mem.eql(u8, linker_arg, "-search_dylibs_first")) { lib_search_strategy = .mode_first; - lib_preferred_mode = .Dynamic; + lib_preferred_mode = .dynamic; } else { try linker_args.append(linker_arg); } @@ -3033,7 +3033,7 @@ fn buildOutputType( const is_exe_or_dyn_lib = switch (create_module.resolved_options.output_mode) { .Obj => false, - .Lib => create_module.resolved_options.link_mode == .Dynamic, + .Lib => create_module.resolved_options.link_mode == .dynamic, .Exe => true, }; // Note that cmake when targeting Windows will try to execute @@ -3770,8 +3770,8 @@ fn createModule( )) { const path = try arena.dupe(u8, test_path.items); switch (info.preferred_mode) { - .Static => try create_module.link_objects.append(arena, .{ .path = path }), - .Dynamic => try create_module.resolved_system_libs.append(arena, .{ + .static => try create_module.link_objects.append(arena, .{ .path = path }), + .dynamic => try create_module.resolved_system_libs.append(arena, .{ .name = lib_name, .lib = .{ .needed = info.needed, @@ -3804,8 +3804,8 @@ fn createModule( )) { const path = try arena.dupe(u8, test_path.items); switch (info.fallbackMode()) { - .Static => try create_module.link_objects.append(arena, .{ .path = path }), - .Dynamic => try create_module.resolved_system_libs.append(arena, .{ + .static => try create_module.link_objects.append(arena, .{ .path = path }), + .dynamic => try create_module.resolved_system_libs.append(arena, .{ .name = lib_name, .lib = .{ .needed = info.needed, @@ -3838,8 +3838,8 @@ fn createModule( )) { const path = try arena.dupe(u8, test_path.items); switch (info.preferred_mode) { - .Static => try create_module.link_objects.append(arena, .{ .path = path }), - .Dynamic => try create_module.resolved_system_libs.append(arena, .{ + .static => try create_module.link_objects.append(arena, .{ .path = path }), + .dynamic => try create_module.resolved_system_libs.append(arena, .{ .name = lib_name, .lib = .{ .needed = info.needed, @@ -3862,8 +3862,8 @@ fn createModule( )) { const path = try arena.dupe(u8, test_path.items); switch (info.fallbackMode()) { - .Static => try create_module.link_objects.append(arena, .{ .path = path }), - .Dynamic => try create_module.resolved_system_libs.append(arena, .{ + .static => try create_module.link_objects.append(arena, .{ .path = path }), + .dynamic => try create_module.resolved_system_libs.append(arena, .{ .name = lib_name, .lib = .{ .needed = info.needed, @@ -6842,7 +6842,7 @@ fn accessLibPath( ) !bool { const sep = fs.path.sep_str; - if (target.isDarwin() and link_mode == .Dynamic) tbd: { + if (target.isDarwin() and link_mode == .dynamic) tbd: { // Prefer .tbd over .dylib. test_path.clearRetainingCapacity(); try test_path.writer().print("{s}" ++ sep ++ "lib{s}.tbd", .{ lib_dir_path, lib_name }); @@ -6863,8 +6863,8 @@ fn accessLibPath( target.libPrefix(), lib_name, switch (link_mode) { - .Static => target.staticLibSuffix(), - .Dynamic => target.dynamicLibSuffix(), + .static => target.staticLibSuffix(), + .dynamic => target.dynamicLibSuffix(), }, }); try checked_paths.writer().print("\n {s}", .{test_path.items}); @@ -6879,7 +6879,7 @@ fn accessLibPath( // In the case of Darwin, the main check will be .dylib, so here we // additionally check for .so files. - if (target.isDarwin() and link_mode == .Dynamic) so: { + if (target.isDarwin() and link_mode == .dynamic) so: { test_path.clearRetainingCapacity(); try test_path.writer().print("{s}" ++ sep ++ "lib{s}.so", .{ lib_dir_path, lib_name }); try checked_paths.writer().print("\n {s}", .{test_path.items}); @@ -6894,7 +6894,7 @@ fn accessLibPath( // In the case of MinGW, the main check will be .lib but we also need to // look for `libfoo.a`. - if (target.isMinGW() and link_mode == .Static) mingw: { + if (target.isMinGW() and link_mode == .static) mingw: { test_path.clearRetainingCapacity(); try test_path.writer().print("{s}" ++ sep ++ "lib{s}.a", .{ lib_dir_path, lib_name, diff --git a/src/musl.zig b/src/musl.zig index ed943b7bf5..3228faf271 100644 --- a/src/musl.zig +++ b/src/musl.zig @@ -207,7 +207,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr const strip = comp.compilerRtStrip(); const config = try Compilation.Config.resolve(.{ .output_mode = .Lib, - .link_mode = .Dynamic, + .link_mode = .dynamic, .resolved_target = comp.root_mod.resolved_target, .is_test = false, .have_zcu = false, diff --git a/test/behavior/export_builtin.zig b/test/behavior/export_builtin.zig index 6755a127f5..e93dc6107a 100644 --- a/test/behavior/export_builtin.zig +++ b/test/behavior/export_builtin.zig @@ -25,7 +25,7 @@ test "exporting with internal linkage" { const S = struct { fn foo() callconv(.C) void {} comptime { - @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .Internal }); + @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal }); } }; S.foo(); @@ -41,7 +41,7 @@ test "exporting using field access" { const x: u32 = 5; }; comptime { - @export(Inner.x, .{ .name = "foo", .linkage = .Internal }); + @export(Inner.x, .{ .name = "foo", .linkage = .internal }); } }; diff --git a/test/standalone/global_linkage/obj1.zig b/test/standalone/global_linkage/obj1.zig index 83b66f336b..31d472eadb 100644 --- a/test/standalone/global_linkage/obj1.zig +++ b/test/standalone/global_linkage/obj1.zig @@ -2,6 +2,6 @@ var internal_integer: usize = 1; var obj1_integer: usize = 421; comptime { - @export(internal_integer, .{ .name = "internal_integer", .linkage = .Internal }); - @export(obj1_integer, .{ .name = "obj1_integer", .linkage = .Strong }); + @export(internal_integer, .{ .name = "internal_integer", .linkage = .internal }); + @export(obj1_integer, .{ .name = "obj1_integer", .linkage = .strong }); } diff --git a/test/standalone/global_linkage/obj2.zig b/test/standalone/global_linkage/obj2.zig index 2908a627fd..aa387ea6d6 100644 --- a/test/standalone/global_linkage/obj2.zig +++ b/test/standalone/global_linkage/obj2.zig @@ -2,6 +2,6 @@ var internal_integer: usize = 2; var obj2_integer: usize = 422; comptime { - @export(internal_integer, .{ .name = "internal_integer", .linkage = .Internal }); - @export(obj2_integer, .{ .name = "obj2_integer", .linkage = .Strong }); + @export(internal_integer, .{ .name = "internal_integer", .linkage = .internal }); + @export(obj2_integer, .{ .name = "obj2_integer", .linkage = .strong }); } diff --git a/tools/docgen.zig b/tools/docgen.zig index 559b1937e9..b7e1aa1652 100644 --- a/tools/docgen.zig +++ b/tools/docgen.zig @@ -629,7 +629,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { } else if (mem.eql(u8, end_tag_name, "link_libc")) { link_libc = true; } else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) { - link_mode = .Dynamic; + link_mode = .dynamic; } else if (mem.eql(u8, end_tag_name, "additonal_option")) { _ = try eatToken(tokenizer, .separator); const option = try eatToken(tokenizer, .tag_content); @@ -1793,11 +1793,11 @@ fn genHtml( } if (code.link_mode) |link_mode| { switch (link_mode) { - .Static => { + .static => { try test_args.append("-static"); try shell_out.print("-static ", .{}); }, - .Dynamic => { + .dynamic => { try test_args.append("-dynamic"); try shell_out.print("-dynamic ", .{}); },