Skip to content

Commit c29d17c

Browse files
committed
Explicitly link to libc when building Zig projects to avoid it being statically linked.
1 parent 8cc3312 commit c29d17c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/sdk/Zig.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ protected override string GenerateCommandLineCommands()
205205
{
206206
builder.AppendSwitchIfNotNull("-rpath ", "$ORIGIN");
207207

208+
// When building Zig code, the compiler links to libc statically
209+
// by default. We do not want that behavior when building code
210+
// that might be loaded in a .NET process.
211+
builder.AppendSwitch("-lc");
212+
208213
if (_configuration == ZigConfiguration.Release)
209214
builder.AppendSwitch($"-O Release{_releaseMode}");
210215

0 commit comments

Comments
 (0)