| author | |
| committer | |
| log | 3cb5bbb36d09baf4f08464c1d047607a1f09a967 |
| tree | 3069bd3aeaba4a7be8445f2c473d9ce70caa41bd |
| parent | 9a810ff16e1969b7be4a3e0799741fda0077b2f7 |
| parent | 476efc5b701c2a33cfd09b09989ccf400641a2ac |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36956
Reviewed-by: mlugg <mlugg@mlugg.co.uk>
Reviewed-by: Andrew Kelley <andrew@ziglang.org>21 files changed, 42 insertions(+), 169 deletions(-)
lib/compiler/aro/aro/TypeStore.zig+1-2| ... | ... | @@ -1201,9 +1201,8 @@ pub const QualType = packed struct(u32) { |
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | pub fn linkage(qt: QualType, comp: *const Compilation) std.builtin.GlobalLinkage { |
| 1204 | if (qt.hasAttribute(comp, .internal_linkage)) return .internal; | |
| 1205 | 1204 | if (qt.hasAttribute(comp, .weak)) return .weak; |
| 1206 | if (qt.hasAttribute(comp, .selectany)) return .link_once; | |
| 1205 | if (qt.hasAttribute(comp, .selectany)) return .weak; | |
| 1207 | 1206 | return .strong; |
| 1208 | 1207 | } |
| 1209 | 1208 |
lib/compiler_rt.zig+7-19| ... | ... | @@ -23,27 +23,15 @@ else |
| 23 | 23 | unreachable; |
| 24 | 24 | |
| 25 | 25 | pub inline fn symbol(comptime func: *const anyopaque, comptime name: []const u8) void { |
| 26 | @export(func, .{ .name = name, .linkage = linkage, .visibility = visibility }); | |
| 26 | // The function shouldn't be exported at all when testing compiler_rt. | |
| 27 | // Instead, we just need to reference the function so that it's compiled. | |
| 28 | if (!builtin.is_test) @export(func, .{ | |
| 29 | .name = name, | |
| 30 | .linkage = if (ofmt_c) .strong else .weak, | |
| 31 | .visibility = .hidden, | |
| 32 | }); | |
| 27 | 33 | } |
| 28 | 34 | |
| 29 | /// For now, we prefer weak linkage because some of the routines we implement here may also be | |
| 30 | /// provided by system/dynamic libc. Eventually we should be more disciplined about this on a | |
| 31 | /// per-symbol, per-target basis: https://github.com/ziglang/zig/issues/11883 | |
| 32 | pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) | |
| 33 | .internal | |
| 34 | else if (ofmt_c) | |
| 35 | .strong | |
| 36 | else | |
| 37 | .weak; | |
| 38 | ||
| 39 | /// Determines the symbol's visibility to other objects. | |
| 40 | /// For WebAssembly this allows the symbol to be resolved to other modules, but will not | |
| 41 | /// export it to the host runtime. | |
| 42 | pub const visibility: std.builtin.SymbolVisibility = if (linkage == .internal or builtin.link_mode == .dynamic) | |
| 43 | .default | |
| 44 | else | |
| 45 | .hidden; | |
| 46 | ||
| 47 | 35 | pub const test_safety = switch (builtin.zig_backend) { |
| 48 | 36 | .stage2_aarch64 => false, |
| 49 | 37 | else => builtin.is_test, |
lib/compiler_rt/memcpy.zig+2-10| ... | ... | @@ -1,20 +1,12 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const assert = std.debug.assert; |
| 3 | 3 | const compiler_rt = @import("../compiler_rt.zig"); |
| 4 | const symbol = compiler_rt.symbol; | |
| 4 | 5 | const builtin = @import("builtin"); |
| 5 | 6 | |
| 6 | 7 | comptime { |
| 7 | 8 | if (builtin.object_format != .c) { |
| 8 | const export_options: std.builtin.ExportOptions = .{ | |
| 9 | .name = "memcpy", | |
| 10 | .linkage = compiler_rt.linkage, | |
| 11 | .visibility = compiler_rt.visibility, | |
| 12 | }; | |
| 13 | ||
| 14 | if (builtin.mode == .small or builtin.zig_backend == .stage2_aarch64) | |
| 15 | @export(&memcpySmall, export_options) | |
| 16 | else | |
| 17 | @export(&memcpyFast, export_options); | |
| 9 | symbol(if (builtin.mode == .small or builtin.zig_backend == .stage2_aarch64) &memcpySmall else &memcpyFast, "memcpy"); | |
| 18 | 10 | } |
| 19 | 11 | } |
| 20 | 12 |
lib/compiler_rt/memmove.zig+2-10| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const compiler_rt = @import("../compiler_rt.zig"); |
| 3 | const symbol = compiler_rt.symbol; | |
| 3 | 4 | const builtin = @import("builtin"); |
| 4 | 5 | const assert = std.debug.assert; |
| 5 | 6 | const memcpy = @import("memcpy.zig"); |
| ... | ... | @@ -8,16 +9,7 @@ const Element = compiler_rt.PreferredLoadStoreElement; |
| 8 | 9 | |
| 9 | 10 | comptime { |
| 10 | 11 | if (builtin.object_format != .c) { |
| 11 | const export_options: std.builtin.ExportOptions = .{ | |
| 12 | .name = "memmove", | |
| 13 | .linkage = compiler_rt.linkage, | |
| 14 | .visibility = compiler_rt.visibility, | |
| 15 | }; | |
| 16 | ||
| 17 | if (builtin.mode == .small or builtin.zig_backend == .stage2_aarch64) | |
| 18 | @export(&memmoveSmall, export_options) | |
| 19 | else | |
| 20 | @export(&memmoveFast, export_options); | |
| 12 | symbol(if (builtin.mode == .small or builtin.zig_backend == .stage2_aarch64) &memmoveSmall else &memmoveFast, "memmove"); | |
| 21 | 13 | } |
| 22 | 14 | } |
| 23 | 15 |
lib/compiler_rt/ssp.zig+1-1| ... | ... | @@ -22,7 +22,7 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call |
| 22 | 22 | extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.c) ?[*]u8; |
| 23 | 23 | |
| 24 | 24 | comptime { |
| 25 | @export(&__stack_chk_fail, .{ .name = if (builtin.os.tag == .openbsd) "__stack_smash_handler" else "__stack_chk_fail", .linkage = compiler_rt.linkage, .visibility = compiler_rt.visibility }); | |
| 25 | symbol(&__stack_chk_fail, if (builtin.os.tag == .openbsd) "__stack_smash_handler" else "__stack_chk_fail"); | |
| 26 | 26 | symbol(&__chk_fail, "__chk_fail"); |
| 27 | 27 | symbol(&__stack_chk_guard, if (builtin.os.tag == .openbsd) "__guard_local" else "__stack_chk_guard"); |
| 28 | 28 | symbol(&__strcpy_chk, "__strcpy_chk"); |
lib/std/lang.zig+1-3| ... | ... | @@ -15,11 +15,9 @@ pub const StackTrace = struct { |
| 15 | 15 | |
| 16 | 16 | /// This data structure is used by the Zig language code generation and |
| 17 | 17 | /// therefore must be kept in sync with the compiler implementation. |
| 18 | pub const GlobalLinkage = enum(u2) { | |
| 19 | internal, | |
| 18 | pub const GlobalLinkage = enum(u1) { | |
| 20 | 19 | strong, |
| 21 | 20 | weak, |
| 22 | link_once, | |
| 23 | 21 | }; |
| 24 | 22 | |
| 25 | 23 | /// This data structure is used by the Zig language code generation and |
src/InternPool.zig+1-1| ... | ... | @@ -5433,7 +5433,7 @@ pub const Tag = enum(u8) { |
| 5433 | 5433 | relocation: std.lang.ExternOptions.Relocation, |
| 5434 | 5434 | source: Source, |
| 5435 | 5435 | decoration_type: DecorationType, |
| 5436 | _: u23 = 0, | |
| 5436 | _: u24 = 0, | |
| 5437 | 5437 | |
| 5438 | 5438 | pub const Source = enum(u1) { builtin, syntax }; |
| 5439 | 5439 | pub const DecorationType = enum(u2) { none, location, descriptor, flat }; |
src/Sema.zig-13| ... | ... | @@ -23107,12 +23107,6 @@ fn resolveExportOptions( |
| 23107 | 23107 | return sema.fail(block, name_src, "exported symbol name cannot be empty", .{}); |
| 23108 | 23108 | } |
| 23109 | 23109 | |
| 23110 | if (visibility != .default and linkage == .internal) { | |
| 23111 | return sema.fail(block, visibility_src, "symbol '{s}' exported with internal linkage has non-default visibility {s}", .{ | |
| 23112 | name, @tagName(visibility), | |
| 23113 | }); | |
| 23114 | } | |
| 23115 | ||
| 23116 | 23110 | return .{ |
| 23117 | 23111 | .name = try ip.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls), |
| 23118 | 23112 | .linkage = linkage, |
| ... | ... | @@ -25290,13 +25284,6 @@ fn zirBuiltinExtern( |
| 25290 | 25284 | } |
| 25291 | 25285 | |
| 25292 | 25286 | const options = try sema.resolveExternOptions(block, options_src, extra.rhs); |
| 25293 | switch (options.linkage) { | |
| 25294 | .internal => if (options.visibility != .default) { | |
| 25295 | return sema.fail(block, options_src, "internal symbol cannot have non-default visibility", .{}); | |
| 25296 | }, | |
| 25297 | .strong, .weak => {}, | |
| 25298 | .link_once => return sema.fail(block, options_src, "external symbol cannot have link once linkage", .{}), | |
| 25299 | } | |
| 25300 | 25287 | switch (options.relocation) { |
| 25301 | 25288 | .any => {}, |
| 25302 | 25289 | .pcrel => if (options.visibility == .default) return sema.fail(block, options_src, "cannot require a pc-relative relocation to a symbol with default visibility", .{}), |
src/Zcu/PerThread.zig+1-1| ... | ... | @@ -3657,7 +3657,7 @@ pub fn processExports(pt: Zcu.PerThread) (Allocator.Error || Io.Cancelable)!void |
| 3657 | 3657 | const exp = export_index.ptr(zcu); |
| 3658 | 3658 | switch (exp.opts.linkage) { |
| 3659 | 3659 | .strong => {}, |
| 3660 | .weak, .internal, .link_once => continue, | |
| 3660 | .weak => continue, | |
| 3661 | 3661 | } |
| 3662 | 3662 | const gop = exports_by_name.getOrPutAssumeCapacity(exp.opts.name); |
| 3663 | 3663 | if (gop.found_existing) { |
src/codegen.zig+24-40| ... | ... | @@ -830,53 +830,37 @@ pub fn genNavRef( |
| 830 | 830 | log.debug("genNavRef({f})", .{nav.fqn.fmt(ip)}); |
| 831 | 831 | |
| 832 | 832 | const is_threadlocal = nav.resolved.?.@"threadlocal" and zcu.comp.config.any_non_single_threaded; |
| 833 | const lib_name, const linkage = if (nav.getExtern(ip)) |e| | |
| 834 | .{ e.lib_name, e.linkage } | |
| 835 | else | |
| 836 | .{ .none, .internal }; | |
| 837 | 833 | if (lf.cast(.elf)) |elf_file| { |
| 838 | 834 | const zo = elf_file.zigObjectPtr().?; |
| 839 | switch (linkage) { | |
| 840 | .internal => { | |
| 841 | const sym_index = try zo.getOrCreateMetadataForNav(zcu, nav_index); | |
| 842 | if (is_threadlocal) zo.symbol(sym_index).flags.is_tls = true; | |
| 843 | return @fromBackingInt(@intCast(sym_index)); | |
| 844 | }, | |
| 845 | .strong, .weak => { | |
| 846 | const sym_index = try elf_file.getGlobalSymbol(nav.name.toSlice(ip), lib_name.toSlice(ip)); | |
| 847 | switch (linkage) { | |
| 848 | .internal => unreachable, | |
| 849 | .strong => {}, | |
| 850 | .weak => zo.symbol(sym_index).flags.weak = true, | |
| 851 | .link_once => unreachable, | |
| 852 | } | |
| 853 | if (is_threadlocal) zo.symbol(sym_index).flags.is_tls = true; | |
| 854 | return @fromBackingInt(@intCast(sym_index)); | |
| 855 | }, | |
| 856 | .link_once => unreachable, | |
| 835 | if (nav.getExtern(ip)) |e| { | |
| 836 | const sym_index = try elf_file.getGlobalSymbol(nav.name.toSlice(ip), e.lib_name.toSlice(ip)); | |
| 837 | switch (e.linkage) { | |
| 838 | .strong => {}, | |
| 839 | .weak => zo.symbol(sym_index).flags.weak = true, | |
| 840 | } | |
| 841 | if (is_threadlocal) zo.symbol(sym_index).flags.is_tls = true; | |
| 842 | return @fromBackingInt(@intCast(sym_index)); | |
| 843 | } else { | |
| 844 | const sym_index = try zo.getOrCreateMetadataForNav(zcu, nav_index); | |
| 845 | if (is_threadlocal) zo.symbol(sym_index).flags.is_tls = true; | |
| 846 | return @fromBackingInt(@intCast(sym_index)); | |
| 857 | 847 | } |
| 858 | 848 | } else if (lf.cast(.elf2)) |elf| { |
| 859 | 849 | return elf.navSymbol(nav_index); |
| 860 | 850 | } else if (lf.cast(.macho)) |macho_file| { |
| 861 | 851 | const zo = macho_file.getZigObject().?; |
| 862 | switch (linkage) { | |
| 863 | .internal => { | |
| 864 | const sym_index = try zo.getOrCreateMetadataForNav(macho_file, nav_index); | |
| 865 | if (is_threadlocal) zo.symbols.items[sym_index].flags.tlv = true; | |
| 866 | return @fromBackingInt(@intCast(sym_index)); | |
| 867 | }, | |
| 868 | .strong, .weak => { | |
| 869 | const sym_index = try macho_file.getGlobalSymbol(nav.name.toSlice(ip), lib_name.toSlice(ip)); | |
| 870 | switch (linkage) { | |
| 871 | .internal => unreachable, | |
| 872 | .strong => {}, | |
| 873 | .weak => zo.symbols.items[sym_index].flags.weak = true, | |
| 874 | .link_once => unreachable, | |
| 875 | } | |
| 876 | if (is_threadlocal) zo.symbols.items[sym_index].flags.tlv = true; | |
| 877 | return @fromBackingInt(@intCast(sym_index)); | |
| 878 | }, | |
| 879 | .link_once => unreachable, | |
| 852 | if (nav.getExtern(ip)) |e| { | |
| 853 | const sym_index = try macho_file.getGlobalSymbol(nav.name.toSlice(ip), e.lib_name.toSlice(ip)); | |
| 854 | switch (e.linkage) { | |
| 855 | .strong => {}, | |
| 856 | .weak => zo.symbols.items[sym_index].flags.weak = true, | |
| 857 | } | |
| 858 | if (is_threadlocal) zo.symbols.items[sym_index].flags.tlv = true; | |
| 859 | return @fromBackingInt(@intCast(sym_index)); | |
| 860 | } else { | |
| 861 | const sym_index = try zo.getOrCreateMetadataForNav(macho_file, nav_index); | |
| 862 | if (is_threadlocal) zo.symbols.items[sym_index].flags.tlv = true; | |
| 863 | return @fromBackingInt(@intCast(sym_index)); | |
| 880 | 864 | } |
| 881 | 865 | } else if (lf.cast(.coff2)) |coff| { |
| 882 | 866 | return @fromBackingInt(@intCast(@backingInt(try coff.navSymbol(zcu, nav_index)))); |
src/codegen/c.zig-2| ... | ... | @@ -2515,10 +2515,8 @@ pub fn genDeclFwd(dg: *DeclGen, w: *Writer) Error!void { |
| 2515 | 2515 | }, |
| 2516 | 2516 | else => { |
| 2517 | 2517 | switch (@"extern".linkage) { |
| 2518 | .internal => try w.writeAll("static "), | |
| 2519 | 2518 | .strong => try w.print("zig_extern zig_visibility({t}) ", .{@"extern".visibility}), |
| 2520 | 2519 | .weak => try w.print("zig_extern zig_weak_linkage zig_visibility({t}) ", .{@"extern".visibility}), |
| 2521 | .link_once => return dg.fail("TODO: CBE: implement linkonce linkage?", .{}), | |
| 2522 | 2520 | } |
| 2523 | 2521 | if (nav.resolved.?.@"threadlocal" and !dg.mod.single_threaded) { |
| 2524 | 2522 | try w.writeAll("zig_threadlocal "); |
src/codegen/llvm.zig-4| ... | ... | @@ -1077,10 +1077,8 @@ pub const Object = struct { |
| 1077 | 1077 | false => .default, |
| 1078 | 1078 | }; |
| 1079 | 1079 | llvm_global.ptr(&o.builder).linkage = switch (@"extern".linkage) { |
| 1080 | .internal => if (o.builder.strip and !workaroundPrivateSymbolBugs(zcu.getTarget(), &resolved)) .private else .internal, | |
| 1081 | 1080 | .strong => .external, |
| 1082 | 1081 | .weak => .extern_weak, |
| 1083 | .link_once => unreachable, | |
| 1084 | 1082 | }; |
| 1085 | 1083 | llvm_global.ptr(&o.builder).visibility = .fromSymbolVisibility(@"extern".visibility); |
| 1086 | 1084 | } else { |
| ... | ... | @@ -1304,10 +1302,8 @@ pub const Object = struct { |
| 1304 | 1302 | if (comp.config.dll_export_fns and exp.opts.visibility != .hidden) |
| 1305 | 1303 | alias_global.setDllStorageClass(.dllexport, &o.builder); |
| 1306 | 1304 | alias_global.setLinkage(switch (exp.opts.linkage) { |
| 1307 | .internal => if (o.builder.strip) .private else .internal, // we still did useful work in replacing an existing symbol if there was one | |
| 1308 | 1305 | .strong => .external, |
| 1309 | 1306 | .weak => .weak_odr, |
| 1310 | .link_once => .linkonce_odr, | |
| 1311 | 1307 | }, &o.builder); |
| 1312 | 1308 | alias_global.setVisibility(switch (exp.opts.visibility) { |
| 1313 | 1309 | .default => .default, |
src/link/Elf/ZigObject.zig-11| ... | ... | @@ -1910,19 +1910,8 @@ pub fn updateExports( |
| 1910 | 1910 | } |
| 1911 | 1911 | } |
| 1912 | 1912 | const stb_bits: u8 = switch (exp.opts.linkage) { |
| 1913 | .internal => elf.STB_LOCAL, | |
| 1914 | 1913 | .strong => elf.STB_GLOBAL, |
| 1915 | 1914 | .weak => elf.STB_WEAK, |
| 1916 | .link_once => { | |
| 1917 | try zcu.failed_exports.ensureUnusedCapacity(gpa, 1); | |
| 1918 | zcu.failed_exports.putAssumeCapacityNoClobber(export_index, try Zcu.ErrorMsg.create( | |
| 1919 | gpa, | |
| 1920 | exp.src, | |
| 1921 | "Unimplemented: GlobalLinkage.LinkOnce", | |
| 1922 | .{}, | |
| 1923 | )); | |
| 1924 | continue; | |
| 1925 | }, | |
| 1926 | 1915 | }; |
| 1927 | 1916 | const stt_bits: u8 = @as(u4, @truncate(esym.st_info)); |
| 1928 | 1917 | const exp_name = exp.opts.name.toSlice(&zcu.intern_pool); |
src/link/Elf2.zig+1-5| ... | ... | @@ -4245,8 +4245,6 @@ fn externSymbolInner(elf: *Elf, opts: ExternSymbolOpts) Error!Symbol.Id { |
| 4245 | 4245 | .bind = switch (opts.linkage) { |
| 4246 | 4246 | .strong => .strong, |
| 4247 | 4247 | .weak => .weak, |
| 4248 | .internal => return elf.base.comp.link_diags.fail("TODO(Elf2): '.internal' linkage", .{}), | |
| 4249 | .link_once => return elf.base.comp.link_diags.fail("TODO(Elf2): '.link_once' linkage", .{}), | |
| 4250 | 4248 | }, |
| 4251 | 4249 | .visibility = switch (opts.visibility) { |
| 4252 | 4250 | .default => .DEFAULT, |
| ... | ... | @@ -7066,7 +7064,7 @@ fn uavMapIndex( |
| 7066 | 7064 | const abi_align = Value.fromInterned(uav_val).typeOf(zcu).abiAlignment(zcu); |
| 7067 | 7065 | const resolved_align: Alignment = switch (uav_align) { |
| 7068 | 7066 | .none => .fromIp(abi_align), |
| 7069 | else => |a| .fromIp(a.minStrict(abi_align)), | |
| 7067 | else => |a| .fromIp(a.maxStrict(abi_align)), | |
| 7070 | 7068 | }; |
| 7071 | 7069 | |
| 7072 | 7070 | const uav_gop = elf.uavs.getOrPutAssumeCapacity(uav_val); |
| ... | ... | @@ -12205,8 +12203,6 @@ fn updateExportInner( |
| 12205 | 12203 | .bind = switch (@"export".opts.linkage) { |
| 12206 | 12204 | .strong => .strong, |
| 12207 | 12205 | .weak => .weak, |
| 12208 | .internal => return elf.base.comp.link_diags.fail("TODO(Elf2): '.internal' linkage", .{}), | |
| 12209 | .link_once => return elf.base.comp.link_diags.fail("TODO(Elf2): '.link_once' linkage", .{}), | |
| 12210 | 12206 | }, |
| 12211 | 12207 | .visibility = switch (@"export".opts.visibility) { |
| 12212 | 12208 | .default => .DEFAULT, |
src/link/MachO/ZigObject.zig-15| ... | ... | @@ -1301,15 +1301,6 @@ pub fn updateExports( |
| 1301 | 1301 | continue; |
| 1302 | 1302 | } |
| 1303 | 1303 | } |
| 1304 | if (exp.opts.linkage == .link_once) { | |
| 1305 | try zcu.failed_exports.putNoClobber(zcu.gpa, export_index, try Zcu.ErrorMsg.create( | |
| 1306 | gpa, | |
| 1307 | exp.src, | |
| 1308 | "Unimplemented: GlobalLinkage.link_once", | |
| 1309 | .{}, | |
| 1310 | )); | |
| 1311 | continue; | |
| 1312 | } | |
| 1313 | 1304 | |
| 1314 | 1305 | const exp_name = exp.opts.name.toSlice(&zcu.intern_pool); |
| 1315 | 1306 | const global_nlist_index = try self.getGlobalSymbol(macho_file, exp_name, null); |
| ... | ... | @@ -1326,11 +1317,6 @@ pub fn updateExports( |
| 1326 | 1317 | global_sym.atom_ref = .{ .index = atom_index, .file = self.index }; |
| 1327 | 1318 | |
| 1328 | 1319 | switch (exp.opts.linkage) { |
| 1329 | .internal => { | |
| 1330 | // Symbol should be hidden, or in MachO lingo, private extern. | |
| 1331 | global_nlist.n_type.bits.pext = true; | |
| 1332 | global_sym.visibility = .hidden; | |
| 1333 | }, | |
| 1334 | 1320 | .strong => { |
| 1335 | 1321 | global_sym.visibility = .global; |
| 1336 | 1322 | }, |
| ... | ... | @@ -1341,7 +1327,6 @@ pub fn updateExports( |
| 1341 | 1327 | global_sym.visibility = .global; |
| 1342 | 1328 | global_sym.flags.weak = true; |
| 1343 | 1329 | }, |
| 1344 | else => unreachable, | |
| 1345 | 1330 | } |
| 1346 | 1331 | } |
| 1347 | 1332 | } |
src/link/Wasm.zig-6| ... | ... | @@ -972,10 +972,8 @@ pub const ZcuFunc = union { |
| 972 | 972 | const name_string = wasm.getExistingString(name_slice).?; |
| 973 | 973 | return .{ |
| 974 | 974 | .binding = switch (ext.linkage) { |
| 975 | .internal => .local, | |
| 976 | 975 | .strong => .strong, |
| 977 | 976 | .weak => .weak, |
| 978 | .link_once => @panic("TODO: COMDAT"), | |
| 979 | 977 | }, |
| 980 | 978 | .visibility_hidden = switch (ext.visibility) { |
| 981 | 979 | .default => false, |
| ... | ... | @@ -1952,10 +1950,8 @@ pub const ObjectDataImport = extern struct { |
| 1952 | 1950 | const name_string = wasm.getExistingString(name_slice).?; |
| 1953 | 1951 | return .{ |
| 1954 | 1952 | .binding = switch (ext.linkage) { |
| 1955 | .internal => .local, | |
| 1956 | 1953 | .strong => .strong, |
| 1957 | 1954 | .weak => .weak, |
| 1958 | .link_once => @panic("TODO: COMDAT"), | |
| 1959 | 1955 | }, |
| 1960 | 1956 | .visibility_hidden = switch (ext.visibility) { |
| 1961 | 1957 | .default => false, |
| ... | ... | @@ -2591,10 +2587,8 @@ pub const ZcuImportIndex = enum(u32) { |
| 2591 | 2587 | const name_string = wasm.getExistingString(name_slice).?; |
| 2592 | 2588 | return .{ |
| 2593 | 2589 | .binding = switch (ext.linkage) { |
| 2594 | .internal => .local, | |
| 2595 | 2590 | .strong => .strong, |
| 2596 | 2591 | .weak => .weak, |
| 2597 | .link_once => @panic("TODO: COMDAT"), | |
| 2598 | 2592 | }, |
| 2599 | 2593 | .visibility_hidden = switch (ext.visibility) { |
| 2600 | 2594 | .default => false, |
src/link/Wasm/Flush.zig-6| ... | ... | @@ -319,10 +319,8 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 319 | 319 | .function_index = function_index, |
| 320 | 320 | .flags = .{ |
| 321 | 321 | .binding = switch (opts.linkage) { |
| 322 | .internal => .local, | |
| 323 | 322 | .strong => .strong, |
| 324 | 323 | .weak => .weak, |
| 325 | .link_once => @panic("TODO: COMDAT"), | |
| 326 | 324 | }, |
| 327 | 325 | .visibility_hidden = is_hidden, |
| 328 | 326 | .exported = !is_hidden, |
| ... | ... | @@ -346,10 +344,8 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 346 | 344 | .resolution = .fromIpNav(wasm, nav_export.nav_index), |
| 347 | 345 | .flags = if (is_obj) .{ |
| 348 | 346 | .binding = switch (opts.linkage) { |
| 349 | .internal => .local, | |
| 350 | 347 | .strong => .strong, |
| 351 | 348 | .weak => .weak, |
| 352 | .link_once => @panic("TODO: COMDAT"), | |
| 353 | 349 | }, |
| 354 | 350 | .visibility_hidden = !explicit and switch (opts.visibility) { |
| 355 | 351 | .default => false, |
| ... | ... | @@ -383,10 +379,8 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 383 | 379 | .resolution = .fromIpIndex(wasm, uav_export.uav_index), |
| 384 | 380 | .flags = if (is_obj) .{ |
| 385 | 381 | .binding = switch (opts.linkage) { |
| 386 | .internal => .local, | |
| 387 | 382 | .strong => .strong, |
| 388 | 383 | .weak => .weak, |
| 389 | .link_once => @panic("TODO: COMDAT"), | |
| 390 | 384 | }, |
| 391 | 385 | .visibility_hidden = !explicit and switch (opts.visibility) { |
| 392 | 386 | .default => false, |
test/behavior/export_builtin.zig+1-13| ... | ... | @@ -16,18 +16,6 @@ test "exporting enum value" { |
| 16 | 16 | try expect(S.e == .two); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | test "exporting with internal linkage" { | |
| 20 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 21 | ||
| 22 | const S = struct { | |
| 23 | fn foo() callconv(.c) void {} | |
| 24 | comptime { | |
| 25 | @export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal }); | |
| 26 | } | |
| 27 | }; | |
| 28 | S.foo(); | |
| 29 | } | |
| 30 | ||
| 31 | 19 | test "exporting using namespace access" { |
| 32 | 20 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 33 | 21 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| ... | ... | @@ -37,7 +25,7 @@ test "exporting using namespace access" { |
| 37 | 25 | const x: u32 = 5; |
| 38 | 26 | }; |
| 39 | 27 | comptime { |
| 40 | @export(&Inner.x, .{ .name = "foo", .linkage = .internal }); | |
| 28 | @export(&Inner.x, .{ .name = "foo", .linkage = .strong }); | |
| 41 | 29 | } |
| 42 | 30 | }; |
| 43 | 31 |
test/standalone/global_linkage/obj1.zig-2| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | var internal_integer: usize = 1; | |
| 2 | 1 | var obj1_integer: usize = 421; |
| 3 | 2 | |
| 4 | 3 | comptime { |
| 5 | @export(&internal_integer, .{ .name = "internal_integer", .linkage = .internal }); | |
| 6 | 4 | @export(&obj1_integer, .{ .name = "obj1_integer", .linkage = .strong }); |
| 7 | 5 | } |
test/standalone/global_linkage/obj2.zig-2| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | var internal_integer: usize = 2; | |
| 2 | 1 | var obj2_integer: usize = 422; |
| 3 | 2 | |
| 4 | 3 | comptime { |
| 5 | @export(&internal_integer, .{ .name = "internal_integer", .linkage = .internal }); | |
| 6 | 4 | @export(&obj2_integer, .{ .name = "obj2_integer", .linkage = .strong }); |
| 7 | 5 | } |
test/tests.zig-3| ... | ... | @@ -1294,7 +1294,6 @@ const module_test_targets = blk: { |
| 1294 | 1294 | .os_tag = .linux, |
| 1295 | 1295 | }, |
| 1296 | 1296 | .new_linker = true, |
| 1297 | .skip_modules = &.{ "compiler-rt", "behavior" }, // '@export' with '.internal' linkage | |
| 1298 | 1297 | }, |
| 1299 | 1298 | .{ |
| 1300 | 1299 | .target = .{ |
| ... | ... | @@ -1304,7 +1303,6 @@ const module_test_targets = blk: { |
| 1304 | 1303 | }, |
| 1305 | 1304 | .link_libc = true, |
| 1306 | 1305 | .new_linker = true, |
| 1307 | .skip_modules = &.{ "compiler-rt", "behavior" }, // '@export' with '.internal' linkage | |
| 1308 | 1306 | }, |
| 1309 | 1307 | .{ |
| 1310 | 1308 | .target = .{ |
| ... | ... | @@ -1314,7 +1312,6 @@ const module_test_targets = blk: { |
| 1314 | 1312 | }, |
| 1315 | 1313 | .link_libc = true, |
| 1316 | 1314 | .new_linker = true, |
| 1317 | .skip_modules = &.{ "compiler-rt", "behavior" }, // '@export' with '.internal' linkage | |
| 1318 | 1315 | }, |
| 1319 | 1316 | |
| 1320 | 1317 | // Darwin Targets |