| ... | @@ -15,17 +15,17 @@ pub const panic = if (builtin.is_test) | ... | @@ -15,17 +15,17 @@ pub const panic = if (builtin.is_test) |
| 15 | else | 15 | else |
| 16 | std.debug.no_panic; | 16 | std.debug.no_panic; |
| 17 | | 17 | |
| 18 | /// It is incorrect to make this conditional on `builtin.is_test`, because it is possible that | | |
| 19 | /// libzigc is being linked into a different test compilation, as opposed to being tested itself. | | |
| 20 | pub const linkage: std.builtin.GlobalLinkage = .strong; | | |
| 21 | | | |
| 22 | /// Determines the symbol's visibility to other objects. | 18 | /// Determines the symbol's visibility to other objects. |
| 23 | /// For WebAssembly this allows the symbol to be resolved to other modules, but will not | 19 | /// For WebAssembly this allows the symbol to be resolved to other modules, but will not |
| 24 | /// export it to the host runtime. | 20 | /// export it to the host runtime. |
| 25 | pub const visibility: std.builtin.SymbolVisibility = .hidden; | 21 | pub const visibility: std.builtin.SymbolVisibility = .hidden; |
| 26 | | 22 | |
| 27 | pub inline fn symbol(comptime func: *const anyopaque, comptime name: []const u8) void { | 23 | pub inline fn symbol(comptime func: *const anyopaque, comptime name: []const u8) void { |
| 28 | @export(func, .{ .name = name, .linkage = linkage, .visibility = visibility }); | 24 | // Normally, libc goes into a static archive, making all symbols |
| | 25 | // overridable. However, Zig supports including the libc functions as part |
| | 26 | // of the Zig Compilation Unit, so to support this use case we make all |
| | 27 | // symbols weak. |
| | 28 | @export(func, .{ .name = name, .linkage = .weak, .visibility = visibility }); |
| 29 | } | 29 | } |
| 30 | | 30 | |
| 31 | /// Given a low-level syscall return value, sets errno and returns `-1`, or on | 31 | /// Given a low-level syscall return value, sets errno and returns `-1`, or on |