mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:24:49 +01:00
zig libc: export all symbols weak
Normally, libc goes into a static archive, making all symbols overrideable. However, Zig supports including the libc functions as part of the Zig Compilation Unit, so to support this use case we make all symbols weak.
This commit is contained in:
parent
f5d5dbd166
commit
21829a5b4a
1 changed files with 5 additions and 5 deletions
10
lib/c.zig
10
lib/c.zig
|
|
@ -15,17 +15,17 @@ pub const panic = if (builtin.is_test)
|
|||
else
|
||||
std.debug.no_panic;
|
||||
|
||||
/// It is incorrect to make this conditional on `builtin.is_test`, because it is possible that
|
||||
/// libzigc is being linked into a different test compilation, as opposed to being tested itself.
|
||||
pub const linkage: std.builtin.GlobalLinkage = .strong;
|
||||
|
||||
/// Determines the symbol's visibility to other objects.
|
||||
/// For WebAssembly this allows the symbol to be resolved to other modules, but will not
|
||||
/// export it to the host runtime.
|
||||
pub const visibility: std.builtin.SymbolVisibility = .hidden;
|
||||
|
||||
pub inline fn symbol(comptime func: *const anyopaque, comptime name: []const u8) void {
|
||||
@export(func, .{ .name = name, .linkage = linkage, .visibility = visibility });
|
||||
// Normally, libc goes into a static archive, making all symbols
|
||||
// overridable. However, Zig supports including the libc functions as part
|
||||
// of the Zig Compilation Unit, so to support this use case we make all
|
||||
// symbols weak.
|
||||
@export(func, .{ .name = name, .linkage = .weak, .visibility = visibility });
|
||||
}
|
||||
|
||||
/// Given a low-level syscall return value, sets errno and returns `-1`, or on
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue