| author | |
| committer | |
| log | c260b4c753d1e5f947e0d33ce39ce173e497309f |
| tree | 39b138128ab96c7abaf4b8d22fc6af1f0b95254c |
| parent | aab84a3decd784a275c0bb694c7717d3c73ae4b1 |
| signature |
15 files changed, 48 insertions(+), 48 deletions(-)
doc/langref.html.in+1-1| ... | ... | @@ -8356,7 +8356,7 @@ test "main" { |
| 8356 | 8356 | </p> |
| 8357 | 8357 | {#code_begin|obj|export_builtin#} |
| 8358 | 8358 | comptime { |
| 8359 | @export(internalName, .{ .name = "foo", .linkage = .Strong }); | |
| 8359 | @export(internalName, .{ .name = "foo", .linkage = .strong }); | |
| 8360 | 8360 | } |
| 8361 | 8361 | |
| 8362 | 8362 | fn 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 { |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.Internal else std.builtin.GlobalLinkage.Weak; | |
| 165 | const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.internal else std.builtin.GlobalLinkage.weak; | |
| 166 | 166 | |
| 167 | 167 | fn exportIt() void { |
| 168 | 168 | @export(clear_cache, .{ .name = "__clear_cache", .linkage = linkage }); |
lib/compiler_rt/common.zig+2-2| ... | ... | @@ -2,12 +2,12 @@ const std = @import("std"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | const native_endian = builtin.cpu.arch.endian(); |
| 4 | 4 | |
| 5 | pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | |
| 5 | pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak; | |
| 6 | 6 | /// Determines the symbol's visibility to other objects. |
| 7 | 7 | /// For WebAssembly this allows the symbol to be resolved to other modules, but will not |
| 8 | 8 | /// export it to the host runtime. |
| 9 | 9 | pub 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; | |
| 11 | 11 | pub const want_aeabi = switch (builtin.abi) { |
| 12 | 12 | .eabi, |
| 13 | 13 | .eabihf, |
lib/std/builtin.zig+6-6| ... | ... | @@ -64,10 +64,10 @@ pub const StackTrace = struct { |
| 64 | 64 | /// This data structure is used by the Zig language code generation and |
| 65 | 65 | /// therefore must be kept in sync with the compiler implementation. |
| 66 | 66 | pub const GlobalLinkage = enum { |
| 67 | Internal, | |
| 68 | Strong, | |
| 69 | Weak, | |
| 70 | LinkOnce, | |
| 67 | internal, | |
| 68 | strong, | |
| 69 | weak, | |
| 70 | link_once, | |
| 71 | 71 | }; |
| 72 | 72 | |
| 73 | 73 | /// This data structure is used by the Zig language code generation and |
| ... | ... | @@ -659,7 +659,7 @@ pub const PrefetchOptions = struct { |
| 659 | 659 | /// therefore must be kept in sync with the compiler implementation. |
| 660 | 660 | pub const ExportOptions = struct { |
| 661 | 661 | name: []const u8, |
| 662 | linkage: GlobalLinkage = .Strong, | |
| 662 | linkage: GlobalLinkage = .strong, | |
| 663 | 663 | section: ?[]const u8 = null, |
| 664 | 664 | visibility: SymbolVisibility = .default, |
| 665 | 665 | }; |
| ... | ... | @@ -669,7 +669,7 @@ pub const ExportOptions = struct { |
| 669 | 669 | pub const ExternOptions = struct { |
| 670 | 670 | name: []const u8, |
| 671 | 671 | library_name: ?[]const u8 = null, |
| 672 | linkage: GlobalLinkage = .Strong, | |
| 672 | linkage: GlobalLinkage = .strong, | |
| 673 | 673 | is_thread_local: bool = false, |
| 674 | 674 | }; |
| 675 | 675 |
lib/std/dynamic_library.zig+1-1| ... | ... | @@ -8,7 +8,7 @@ const windows = std.os.windows; |
| 8 | 8 | const system = std.os.system; |
| 9 | 9 | |
| 10 | 10 | pub 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) | |
| 12 | 12 | ElfDynLib |
| 13 | 13 | else |
| 14 | 14 | DlDynLib, |
src/Module.zig+1-1| ... | ... | @@ -279,7 +279,7 @@ pub const Export = struct { |
| 279 | 279 | |
| 280 | 280 | pub const Options = struct { |
| 281 | 281 | name: InternPool.NullTerminatedString, |
| 282 | linkage: std.builtin.GlobalLinkage = .Strong, | |
| 282 | linkage: std.builtin.GlobalLinkage = .strong, | |
| 283 | 283 | section: InternPool.OptionalNullTerminatedString = .none, |
| 284 | 284 | visibility: std.builtin.SymbolVisibility = .default, |
| 285 | 285 | }; |
src/Sema.zig+7-7| ... | ... | @@ -6274,7 +6274,7 @@ fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 6274 | 6274 | .needed_comptime_reason = "export target must be comptime-known", |
| 6275 | 6275 | }); |
| 6276 | 6276 | const options = try sema.resolveExportOptions(block, options_src, extra.options); |
| 6277 | if (options.linkage == .Internal) | |
| 6277 | if (options.linkage == .internal) | |
| 6278 | 6278 | return; |
| 6279 | 6279 | if (operand.val.getFunction(mod)) |function| { |
| 6280 | 6280 | const decl_index = function.owner_decl; |
| ... | ... | @@ -6301,7 +6301,7 @@ pub fn analyzeExport( |
| 6301 | 6301 | const gpa = sema.gpa; |
| 6302 | 6302 | const mod = sema.mod; |
| 6303 | 6303 | |
| 6304 | if (options.linkage == .Internal) | |
| 6304 | if (options.linkage == .internal) | |
| 6305 | 6305 | return; |
| 6306 | 6306 | |
| 6307 | 6307 | try mod.ensureDeclAnalyzed(exported_decl_index); |
| ... | ... | @@ -23802,7 +23802,7 @@ fn resolveExportOptions( |
| 23802 | 23802 | return sema.fail(block, name_src, "exported symbol name cannot be empty", .{}); |
| 23803 | 23803 | } |
| 23804 | 23804 | |
| 23805 | if (visibility != .default and linkage == .Internal) { | |
| 23805 | if (visibility != .default and linkage == .internal) { | |
| 23806 | 23806 | return sema.fail(block, visibility_src, "symbol '{s}' exported with internal linkage has non-default visibility {s}", .{ |
| 23807 | 23807 | name, @tagName(visibility), |
| 23808 | 23808 | }); |
| ... | ... | @@ -25888,7 +25888,7 @@ fn resolveExternOptions( |
| 25888 | 25888 | ) CompileError!struct { |
| 25889 | 25889 | name: InternPool.NullTerminatedString, |
| 25890 | 25890 | library_name: InternPool.OptionalNullTerminatedString = .none, |
| 25891 | linkage: std.builtin.GlobalLinkage = .Strong, | |
| 25891 | linkage: std.builtin.GlobalLinkage = .strong, | |
| 25892 | 25892 | is_thread_local: bool = false, |
| 25893 | 25893 | } { |
| 25894 | 25894 | const mod = sema.mod; |
| ... | ... | @@ -25938,7 +25938,7 @@ fn resolveExternOptions( |
| 25938 | 25938 | return sema.fail(block, name_src, "extern symbol name cannot be empty", .{}); |
| 25939 | 25939 | } |
| 25940 | 25940 | |
| 25941 | if (linkage != .Weak and linkage != .Strong) { | |
| 25941 | if (linkage != .weak and linkage != .strong) { | |
| 25942 | 25942 | return sema.fail(block, linkage_src, "extern symbol must use strong or weak linkage", .{}); |
| 25943 | 25943 | } |
| 25944 | 25944 | |
| ... | ... | @@ -25984,7 +25984,7 @@ fn zirBuiltinExtern( |
| 25984 | 25984 | else => |e| return e, |
| 25985 | 25985 | }; |
| 25986 | 25986 | |
| 25987 | if (options.linkage == .Weak and !ty.ptrAllowsZero(mod)) { | |
| 25987 | if (options.linkage == .weak and !ty.ptrAllowsZero(mod)) { | |
| 25988 | 25988 | ty = try mod.optionalType(ty.toIntern()); |
| 25989 | 25989 | } |
| 25990 | 25990 | const ptr_info = ty.ptrInfo(mod); |
| ... | ... | @@ -26010,7 +26010,7 @@ fn zirBuiltinExtern( |
| 26010 | 26010 | .is_extern = true, |
| 26011 | 26011 | .is_const = ptr_info.flags.is_const, |
| 26012 | 26012 | .is_threadlocal = options.is_thread_local, |
| 26013 | .is_weak_linkage = options.linkage == .Weak, | |
| 26013 | .is_weak_linkage = options.linkage == .weak, | |
| 26014 | 26014 | } }), |
| 26015 | 26015 | ), |
| 26016 | 26016 | }, options.name); |
src/codegen/c.zig+4-4| ... | ... | @@ -1999,7 +1999,7 @@ pub const DeclGen = struct { |
| 1999 | 1999 | try fwd.writeAll(if (is_global) "zig_extern " else "static "); |
| 2000 | 2000 | const maybe_exports = dg.module.decl_exports.get(decl_index); |
| 2001 | 2001 | const export_weak_linkage = if (maybe_exports) |exports| |
| 2002 | exports.items[0].opts.linkage == .Weak | |
| 2002 | exports.items[0].opts.linkage == .weak | |
| 2003 | 2003 | else |
| 2004 | 2004 | false; |
| 2005 | 2005 | if (variable.is_weak_linkage or export_weak_linkage) try fwd.writeAll("zig_weak_linkage "); |
| ... | ... | @@ -2689,7 +2689,7 @@ fn genExports(o: *Object) !void { |
| 2689 | 2689 | const is_variable_const = switch (ip.indexToKey(tv.val.toIntern())) { |
| 2690 | 2690 | .func => return for (exports.items[1..], 1..) |@"export", i| { |
| 2691 | 2691 | 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 "); | |
| 2693 | 2693 | try o.dg.renderFunctionSignature( |
| 2694 | 2694 | fwd, |
| 2695 | 2695 | decl_index, |
| ... | ... | @@ -2707,7 +2707,7 @@ fn genExports(o: *Object) !void { |
| 2707 | 2707 | }; |
| 2708 | 2708 | for (exports.items[1..]) |@"export"| { |
| 2709 | 2709 | 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 "); | |
| 2711 | 2711 | const export_name = ip.stringToSlice(@"export".opts.name); |
| 2712 | 2712 | try o.dg.renderTypeAndName( |
| 2713 | 2713 | fwd, |
| ... | ... | @@ -2842,7 +2842,7 @@ pub fn genFunc(f: *Function) !void { |
| 2842 | 2842 | try fwd_decl_writer.writeAll(if (is_global) "zig_extern " else "static "); |
| 2843 | 2843 | |
| 2844 | 2844 | 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 "); | |
| 2846 | 2846 | try o.dg.renderFunctionSignature(fwd_decl_writer, decl_index, .forward, .{ .export_index = 0 }); |
| 2847 | 2847 | try fwd_decl_writer.writeAll(";\n"); |
| 2848 | 2848 | try genExports(o); |
src/codegen/llvm.zig+4-4| ... | ... | @@ -1873,10 +1873,10 @@ pub const Object = struct { |
| 1873 | 1873 | if (comp.config.dll_export_fns) |
| 1874 | 1874 | global_index.setDllStorageClass(.dllexport, &o.builder); |
| 1875 | 1875 | 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, | |
| 1880 | 1880 | }, &o.builder); |
| 1881 | 1881 | global_index.setVisibility(switch (exports[0].opts.visibility) { |
| 1882 | 1882 | .default => .default, |
src/link/Coff.zig+5-5| ... | ... | @@ -1599,11 +1599,11 @@ pub fn updateExports( |
| 1599 | 1599 | } |
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | if (exp.opts.linkage == .LinkOnce) { | |
| 1602 | if (exp.opts.linkage == .link_once) { | |
| 1603 | 1603 | try mod.failed_exports.putNoClobber(gpa, exp, try Module.ErrorMsg.create( |
| 1604 | 1604 | gpa, |
| 1605 | 1605 | exp.getSrcLoc(mod), |
| 1606 | "Unimplemented: GlobalLinkage.LinkOnce", | |
| 1606 | "Unimplemented: GlobalLinkage.link_once", | |
| 1607 | 1607 | .{}, |
| 1608 | 1608 | )); |
| 1609 | 1609 | continue; |
| ... | ... | @@ -1633,11 +1633,11 @@ pub fn updateExports( |
| 1633 | 1633 | sym.type = atom.getSymbol(self).type; |
| 1634 | 1634 | |
| 1635 | 1635 | switch (exp.opts.linkage) { |
| 1636 | .Strong => { | |
| 1636 | .strong => { | |
| 1637 | 1637 | sym.storage_class = .EXTERNAL; |
| 1638 | 1638 | }, |
| 1639 | .Internal => @panic("TODO Internal"), | |
| 1640 | .Weak => @panic("TODO WeakExternal"), | |
| 1639 | .internal => @panic("TODO Internal"), | |
| 1640 | .weak => @panic("TODO WeakExternal"), | |
| 1641 | 1641 | else => unreachable, |
| 1642 | 1642 | } |
| 1643 | 1643 |
src/link/Elf/ZigObject.zig+4-4| ... | ... | @@ -1436,10 +1436,10 @@ pub fn updateExports( |
| 1436 | 1436 | } |
| 1437 | 1437 | } |
| 1438 | 1438 | 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 => { | |
| 1443 | 1443 | try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1); |
| 1444 | 1444 | mod.failed_exports.putAssumeCapacityNoClobber(exp, try Module.ErrorMsg.create( |
| 1445 | 1445 | gpa, |
src/link/MachO/ZigObject.zig+5-5| ... | ... | @@ -1216,11 +1216,11 @@ pub fn updateExports( |
| 1216 | 1216 | continue; |
| 1217 | 1217 | } |
| 1218 | 1218 | } |
| 1219 | if (exp.opts.linkage == .LinkOnce) { | |
| 1219 | if (exp.opts.linkage == .link_once) { | |
| 1220 | 1220 | try mod.failed_exports.putNoClobber(mod.gpa, exp, try Module.ErrorMsg.create( |
| 1221 | 1221 | gpa, |
| 1222 | 1222 | exp.getSrcLoc(mod), |
| 1223 | "Unimplemented: GlobalLinkage.LinkOnce", | |
| 1223 | "Unimplemented: GlobalLinkage.link_once", | |
| 1224 | 1224 | .{}, |
| 1225 | 1225 | )); |
| 1226 | 1226 | continue; |
| ... | ... | @@ -1242,12 +1242,12 @@ pub fn updateExports( |
| 1242 | 1242 | self.symtab.items(.atom)[global_nlist_index] = self.symtab.items(.atom)[nlist_idx]; |
| 1243 | 1243 | |
| 1244 | 1244 | switch (exp.opts.linkage) { |
| 1245 | .Internal => { | |
| 1245 | .internal => { | |
| 1246 | 1246 | // Symbol should be hidden, or in MachO lingo, private extern. |
| 1247 | 1247 | global_nlist.n_type |= macho.N_PEXT; |
| 1248 | 1248 | }, |
| 1249 | .Strong => {}, | |
| 1250 | .Weak => { | |
| 1249 | .strong => {}, | |
| 1250 | .weak => { | |
| 1251 | 1251 | // Weak linkage is specified as part of n_desc field. |
| 1252 | 1252 | // Symbol's n_type is like for a symbol with strong linkage. |
| 1253 | 1253 | global_nlist.n_desc |= macho.N_WEAK_DEF; |
src/link/Wasm/ZigObject.zig+4-4| ... | ... | @@ -896,14 +896,14 @@ pub fn updateExports( |
| 896 | 896 | sym.name = export_name; |
| 897 | 897 | |
| 898 | 898 | switch (exp.opts.linkage) { |
| 899 | .Internal => { | |
| 899 | .internal => { | |
| 900 | 900 | sym.setFlag(.WASM_SYM_VISIBILITY_HIDDEN); |
| 901 | 901 | }, |
| 902 | .Weak => { | |
| 902 | .weak => { | |
| 903 | 903 | sym.setFlag(.WASM_SYM_BINDING_WEAK); |
| 904 | 904 | }, |
| 905 | .Strong => {}, // symbols are strong by default | |
| 906 | .LinkOnce => { | |
| 905 | .strong => {}, // symbols are strong by default | |
| 906 | .link_once => { | |
| 907 | 907 | try mod.failed_exports.putNoClobber(gpa, exp, try Module.ErrorMsg.create( |
| 908 | 908 | gpa, |
| 909 | 909 | decl.srcLoc(mod), |
test/link/elf.zig+2-2| ... | ... | @@ -799,8 +799,8 @@ fn testEmitStaticLib(b: *Build, opts: Options) *Step { |
| 799 | 799 | \\} |
| 800 | 800 | \\export var strongBar: usize = 100; |
| 801 | 801 | \\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 }); | |
| 804 | 804 | \\} |
| 805 | 805 | , |
| 806 | 806 | }); |
test/link/macho.zig+1-1| ... | ... | @@ -1153,7 +1153,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step { |
| 1153 | 1153 | \\ return x; |
| 1154 | 1154 | \\} |
| 1155 | 1155 | \\comptime { |
| 1156 | \\ @export(foo, .{ .name = "bar", .linkage = .Strong }); | |
| 1156 | \\ @export(foo, .{ .name = "bar", .linkage = .strong }); | |
| 1157 | 1157 | \\} |
| 1158 | 1158 | }); |
| 1159 | 1159 |