authorgravatar for tristan.ross@midstall.comTristan Ross <tristan.ross@midstall.com> 2024-02-18 21:25:23-08:00
committergravatar for tristan.ross@midstall.comTristan Ross <tristan.ross@midstall.com> 2024-03-11 07:09:10-07:00
logc260b4c753d1e5f947e0d33ce39ce173e497309f
tree39b138128ab96c7abaf4b8d22fc6af1f0b95254c
parentaab84a3decd784a275c0bb694c7717d3c73ae4b1
signaturelock-open Commit is signed but in an unrecognized format.

std.builtin: make global linkage fields lowercase


15 files changed, 48 insertions(+), 48 deletions(-)

doc/langref.html.in+1-1
......@@ -8356,7 +8356,7 @@ test "main" {
83568356 </p>
83578357 {#code_begin|obj|export_builtin#}
83588358comptime {
8359 @export(internalName, .{ .name = "foo", .linkage = .Strong });
8359 @export(internalName, .{ .name = "foo", .linkage = .strong });
83608360}
83618361
83628362fn internalName() callconv(.C) void {}
lib/compiler_rt/clear_cache.zig+1-1
......@@ -162,7 +162,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
162162 }
163163}
164164
165const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.Internal else std.builtin.GlobalLinkage.Weak;
165const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.internal else std.builtin.GlobalLinkage.weak;
166166
167167fn exportIt() void {
168168 @export(clear_cache, .{ .name = "__clear_cache", .linkage = linkage });
lib/compiler_rt/common.zig+2-2
......@@ -2,12 +2,12 @@ const std = @import("std");
22const builtin = @import("builtin");
33const native_endian = builtin.cpu.arch.endian();
44
5pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak;
66/// Determines the symbol's visibility to other objects.
77/// For WebAssembly this allows the symbol to be resolved to other modules, but will not
88/// export it to the host runtime.
99pub const visibility: std.builtin.SymbolVisibility =
10 if (builtin.target.isWasm() and linkage != .Internal) .hidden else .default;
10 if (builtin.target.isWasm() and linkage != .internal) .hidden else .default;
1111pub const want_aeabi = switch (builtin.abi) {
1212 .eabi,
1313 .eabihf,
lib/std/builtin.zig+6-6
......@@ -64,10 +64,10 @@ pub const StackTrace = struct {
6464/// This data structure is used by the Zig language code generation and
6565/// therefore must be kept in sync with the compiler implementation.
6666pub const GlobalLinkage = enum {
67 Internal,
68 Strong,
69 Weak,
70 LinkOnce,
67 internal,
68 strong,
69 weak,
70 link_once,
7171};
7272
7373/// This data structure is used by the Zig language code generation and
......@@ -659,7 +659,7 @@ pub const PrefetchOptions = struct {
659659/// therefore must be kept in sync with the compiler implementation.
660660pub const ExportOptions = struct {
661661 name: []const u8,
662 linkage: GlobalLinkage = .Strong,
662 linkage: GlobalLinkage = .strong,
663663 section: ?[]const u8 = null,
664664 visibility: SymbolVisibility = .default,
665665};
......@@ -669,7 +669,7 @@ pub const ExportOptions = struct {
669669pub const ExternOptions = struct {
670670 name: []const u8,
671671 library_name: ?[]const u8 = null,
672 linkage: GlobalLinkage = .Strong,
672 linkage: GlobalLinkage = .strong,
673673 is_thread_local: bool = false,
674674};
675675
lib/std/dynamic_library.zig+1-1
......@@ -8,7 +8,7 @@ const windows = std.os.windows;
88const system = std.os.system;
99
1010pub const DynLib = switch (builtin.os.tag) {
11 .linux => if (!builtin.link_libc or builtin.abi == .musl and builtin.link_mode == .Static)
11 .linux => if (!builtin.link_libc or builtin.abi == .musl and builtin.link_mode == .static)
1212 ElfDynLib
1313 else
1414 DlDynLib,
src/Module.zig+1-1
......@@ -279,7 +279,7 @@ pub const Export = struct {
279279
280280 pub const Options = struct {
281281 name: InternPool.NullTerminatedString,
282 linkage: std.builtin.GlobalLinkage = .Strong,
282 linkage: std.builtin.GlobalLinkage = .strong,
283283 section: InternPool.OptionalNullTerminatedString = .none,
284284 visibility: std.builtin.SymbolVisibility = .default,
285285 };
src/Sema.zig+7-7
......@@ -6274,7 +6274,7 @@ fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
62746274 .needed_comptime_reason = "export target must be comptime-known",
62756275 });
62766276 const options = try sema.resolveExportOptions(block, options_src, extra.options);
6277 if (options.linkage == .Internal)
6277 if (options.linkage == .internal)
62786278 return;
62796279 if (operand.val.getFunction(mod)) |function| {
62806280 const decl_index = function.owner_decl;
......@@ -6301,7 +6301,7 @@ pub fn analyzeExport(
63016301 const gpa = sema.gpa;
63026302 const mod = sema.mod;
63036303
6304 if (options.linkage == .Internal)
6304 if (options.linkage == .internal)
63056305 return;
63066306
63076307 try mod.ensureDeclAnalyzed(exported_decl_index);
......@@ -23802,7 +23802,7 @@ fn resolveExportOptions(
2380223802 return sema.fail(block, name_src, "exported symbol name cannot be empty", .{});
2380323803 }
2380423804
23805 if (visibility != .default and linkage == .Internal) {
23805 if (visibility != .default and linkage == .internal) {
2380623806 return sema.fail(block, visibility_src, "symbol '{s}' exported with internal linkage has non-default visibility {s}", .{
2380723807 name, @tagName(visibility),
2380823808 });
......@@ -25888,7 +25888,7 @@ fn resolveExternOptions(
2588825888) CompileError!struct {
2588925889 name: InternPool.NullTerminatedString,
2589025890 library_name: InternPool.OptionalNullTerminatedString = .none,
25891 linkage: std.builtin.GlobalLinkage = .Strong,
25891 linkage: std.builtin.GlobalLinkage = .strong,
2589225892 is_thread_local: bool = false,
2589325893} {
2589425894 const mod = sema.mod;
......@@ -25938,7 +25938,7 @@ fn resolveExternOptions(
2593825938 return sema.fail(block, name_src, "extern symbol name cannot be empty", .{});
2593925939 }
2594025940
25941 if (linkage != .Weak and linkage != .Strong) {
25941 if (linkage != .weak and linkage != .strong) {
2594225942 return sema.fail(block, linkage_src, "extern symbol must use strong or weak linkage", .{});
2594325943 }
2594425944
......@@ -25984,7 +25984,7 @@ fn zirBuiltinExtern(
2598425984 else => |e| return e,
2598525985 };
2598625986
25987 if (options.linkage == .Weak and !ty.ptrAllowsZero(mod)) {
25987 if (options.linkage == .weak and !ty.ptrAllowsZero(mod)) {
2598825988 ty = try mod.optionalType(ty.toIntern());
2598925989 }
2599025990 const ptr_info = ty.ptrInfo(mod);
......@@ -26010,7 +26010,7 @@ fn zirBuiltinExtern(
2601026010 .is_extern = true,
2601126011 .is_const = ptr_info.flags.is_const,
2601226012 .is_threadlocal = options.is_thread_local,
26013 .is_weak_linkage = options.linkage == .Weak,
26013 .is_weak_linkage = options.linkage == .weak,
2601426014 } }),
2601526015 ),
2601626016 }, options.name);
src/codegen/c.zig+4-4
......@@ -1999,7 +1999,7 @@ pub const DeclGen = struct {
19991999 try fwd.writeAll(if (is_global) "zig_extern " else "static ");
20002000 const maybe_exports = dg.module.decl_exports.get(decl_index);
20012001 const export_weak_linkage = if (maybe_exports) |exports|
2002 exports.items[0].opts.linkage == .Weak
2002 exports.items[0].opts.linkage == .weak
20032003 else
20042004 false;
20052005 if (variable.is_weak_linkage or export_weak_linkage) try fwd.writeAll("zig_weak_linkage ");
......@@ -2689,7 +2689,7 @@ fn genExports(o: *Object) !void {
26892689 const is_variable_const = switch (ip.indexToKey(tv.val.toIntern())) {
26902690 .func => return for (exports.items[1..], 1..) |@"export", i| {
26912691 try fwd.writeAll("zig_extern ");
2692 if (@"export".opts.linkage == .Weak) try fwd.writeAll("zig_weak_linkage_fn ");
2692 if (@"export".opts.linkage == .weak) try fwd.writeAll("zig_weak_linkage_fn ");
26932693 try o.dg.renderFunctionSignature(
26942694 fwd,
26952695 decl_index,
......@@ -2707,7 +2707,7 @@ fn genExports(o: *Object) !void {
27072707 };
27082708 for (exports.items[1..]) |@"export"| {
27092709 try fwd.writeAll("zig_extern ");
2710 if (@"export".opts.linkage == .Weak) try fwd.writeAll("zig_weak_linkage ");
2710 if (@"export".opts.linkage == .weak) try fwd.writeAll("zig_weak_linkage ");
27112711 const export_name = ip.stringToSlice(@"export".opts.name);
27122712 try o.dg.renderTypeAndName(
27132713 fwd,
......@@ -2842,7 +2842,7 @@ pub fn genFunc(f: *Function) !void {
28422842 try fwd_decl_writer.writeAll(if (is_global) "zig_extern " else "static ");
28432843
28442844 if (mod.decl_exports.get(decl_index)) |exports|
2845 if (exports.items[0].opts.linkage == .Weak) try fwd_decl_writer.writeAll("zig_weak_linkage_fn ");
2845 if (exports.items[0].opts.linkage == .weak) try fwd_decl_writer.writeAll("zig_weak_linkage_fn ");
28462846 try o.dg.renderFunctionSignature(fwd_decl_writer, decl_index, .forward, .{ .export_index = 0 });
28472847 try fwd_decl_writer.writeAll(";\n");
28482848 try genExports(o);
src/codegen/llvm.zig+4-4
......@@ -1873,10 +1873,10 @@ pub const Object = struct {
18731873 if (comp.config.dll_export_fns)
18741874 global_index.setDllStorageClass(.dllexport, &o.builder);
18751875 global_index.setLinkage(switch (exports[0].opts.linkage) {
1876 .Internal => unreachable,
1877 .Strong => .external,
1878 .Weak => .weak_odr,
1879 .LinkOnce => .linkonce_odr,
1876 .internal => unreachable,
1877 .strong => .external,
1878 .weak => .weak_odr,
1879 .link_once => .linkonce_odr,
18801880 }, &o.builder);
18811881 global_index.setVisibility(switch (exports[0].opts.visibility) {
18821882 .default => .default,
src/link/Coff.zig+5-5
......@@ -1599,11 +1599,11 @@ pub fn updateExports(
15991599 }
16001600 }
16011601
1602 if (exp.opts.linkage == .LinkOnce) {
1602 if (exp.opts.linkage == .link_once) {
16031603 try mod.failed_exports.putNoClobber(gpa, exp, try Module.ErrorMsg.create(
16041604 gpa,
16051605 exp.getSrcLoc(mod),
1606 "Unimplemented: GlobalLinkage.LinkOnce",
1606 "Unimplemented: GlobalLinkage.link_once",
16071607 .{},
16081608 ));
16091609 continue;
......@@ -1633,11 +1633,11 @@ pub fn updateExports(
16331633 sym.type = atom.getSymbol(self).type;
16341634
16351635 switch (exp.opts.linkage) {
1636 .Strong => {
1636 .strong => {
16371637 sym.storage_class = .EXTERNAL;
16381638 },
1639 .Internal => @panic("TODO Internal"),
1640 .Weak => @panic("TODO WeakExternal"),
1639 .internal => @panic("TODO Internal"),
1640 .weak => @panic("TODO WeakExternal"),
16411641 else => unreachable,
16421642 }
16431643
src/link/Elf/ZigObject.zig+4-4
......@@ -1436,10 +1436,10 @@ pub fn updateExports(
14361436 }
14371437 }
14381438 const stb_bits: u8 = switch (exp.opts.linkage) {
1439 .Internal => elf.STB_LOCAL,
1440 .Strong => elf.STB_GLOBAL,
1441 .Weak => elf.STB_WEAK,
1442 .LinkOnce => {
1439 .internal => elf.STB_LOCAL,
1440 .strong => elf.STB_GLOBAL,
1441 .weak => elf.STB_WEAK,
1442 .link_once => {
14431443 try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1);
14441444 mod.failed_exports.putAssumeCapacityNoClobber(exp, try Module.ErrorMsg.create(
14451445 gpa,
src/link/MachO/ZigObject.zig+5-5
......@@ -1216,11 +1216,11 @@ pub fn updateExports(
12161216 continue;
12171217 }
12181218 }
1219 if (exp.opts.linkage == .LinkOnce) {
1219 if (exp.opts.linkage == .link_once) {
12201220 try mod.failed_exports.putNoClobber(mod.gpa, exp, try Module.ErrorMsg.create(
12211221 gpa,
12221222 exp.getSrcLoc(mod),
1223 "Unimplemented: GlobalLinkage.LinkOnce",
1223 "Unimplemented: GlobalLinkage.link_once",
12241224 .{},
12251225 ));
12261226 continue;
......@@ -1242,12 +1242,12 @@ pub fn updateExports(
12421242 self.symtab.items(.atom)[global_nlist_index] = self.symtab.items(.atom)[nlist_idx];
12431243
12441244 switch (exp.opts.linkage) {
1245 .Internal => {
1245 .internal => {
12461246 // Symbol should be hidden, or in MachO lingo, private extern.
12471247 global_nlist.n_type |= macho.N_PEXT;
12481248 },
1249 .Strong => {},
1250 .Weak => {
1249 .strong => {},
1250 .weak => {
12511251 // Weak linkage is specified as part of n_desc field.
12521252 // Symbol's n_type is like for a symbol with strong linkage.
12531253 global_nlist.n_desc |= macho.N_WEAK_DEF;
src/link/Wasm/ZigObject.zig+4-4
......@@ -896,14 +896,14 @@ pub fn updateExports(
896896 sym.name = export_name;
897897
898898 switch (exp.opts.linkage) {
899 .Internal => {
899 .internal => {
900900 sym.setFlag(.WASM_SYM_VISIBILITY_HIDDEN);
901901 },
902 .Weak => {
902 .weak => {
903903 sym.setFlag(.WASM_SYM_BINDING_WEAK);
904904 },
905 .Strong => {}, // symbols are strong by default
906 .LinkOnce => {
905 .strong => {}, // symbols are strong by default
906 .link_once => {
907907 try mod.failed_exports.putNoClobber(gpa, exp, try Module.ErrorMsg.create(
908908 gpa,
909909 decl.srcLoc(mod),
test/link/elf.zig+2-2
......@@ -799,8 +799,8 @@ fn testEmitStaticLib(b: *Build, opts: Options) *Step {
799799 \\}
800800 \\export var strongBar: usize = 100;
801801 \\comptime {
802 \\ @export(weakFoo, .{ .name = "weakFoo", .linkage = .Weak });
803 \\ @export(strongBar, .{ .name = "strongBarAlias", .linkage = .Strong });
802 \\ @export(weakFoo, .{ .name = "weakFoo", .linkage = .weak });
803 \\ @export(strongBar, .{ .name = "strongBarAlias", .linkage = .strong });
804804 \\}
805805 ,
806806 });
test/link/macho.zig+1-1
......@@ -1153,7 +1153,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step {
11531153 \\ return x;
11541154 \\}
11551155 \\comptime {
1156 \\ @export(foo, .{ .name = "bar", .linkage = .Strong });
1156 \\ @export(foo, .{ .name = "bar", .linkage = .strong });
11571157 \\}
11581158 });
11591159