From 750c665ab38e7a5ff59fc6206740f82bbfab5fda Mon Sep 17 00:00:00 2001 From: Max Coplan Date: Tue, 18 Aug 2026 01:16:35 -0700 Subject: [PATCH] build(zig): keep all symbols for native Lua modules #41361 Native Lua modules loaded with `require` or `package.loadlib` resolve Lua C API symbols from the nvim executable itself. Those symbols must stay in the binary even when nothing inside nvim references them. `rdynamic` is enough on Linux. On macOS the linker dead-strips unreferenced symbols before rdynamic exports them, so `_lua_tothread` is missing from the executable and loading such a module fails with: symbol not found in flat namespace '_lua_tothread' Disable section garbage collection so all non-static symbols are kept. --- build.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/build.zig b/build.zig index 3519786ec7..bcae54f001 100644 --- a/build.zig +++ b/build.zig @@ -498,6 +498,7 @@ pub fn build(b: *std.Build) !void { .root_module = nvim_mod, }) else b.addExecutable(.{ .name = "nvim", .root_module = nvim_mod }); nvim_exe.rdynamic = true; // -E + nvim_exe.link_gc_sections = false; // prevent linker from gc:ing exported symbols #40622 if (emscripten_libc_path) |lp| nvim_exe.setLibCFile(lp); if (is_wasm) nvim_exe.entry = .disabled; if (is_wasm) nvim_exe.linker_allow_shlib_undefined = true;