From 2c2084135bf9ef70c8f616c34c4c0b731b7b49f6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 24 Apr 2026 10:01:15 -0700 Subject: [PATCH] build: addLibrary vs addObject --- src/build/SharedDeps.zig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/build/SharedDeps.zig b/src/build/SharedDeps.zig index eac28ec3d..6bcb72230 100644 --- a/src/build/SharedDeps.zig +++ b/src/build/SharedDeps.zig @@ -881,16 +881,25 @@ pub fn addSimd( } // SIMD C++ files + // + // We use addLibrary (static) instead of addObject here because Zig's + // build-obj does not add C++ standard library include paths even when + // link_libcpp is set. addLibrary (build-lib) handles this correctly, + // and the runtime dependency is stripped because we consume the archive + // as a plain linker input via addObjectFile below. if (simd_libc == .no_libc) { - const simd_cpp = b.addObject(.{ + const simd_cpp = b.addLibrary(.{ .name = "ghostty-simd", .root_module = b.createModule(.{ .target = target, .optimize = optimize, - .link_libc = false, - .link_libcpp = false, + // We need libc + libcpp headers at compile time + // (simdutf.h unconditionally includes etc.). + .link_libc = true, + .link_libcpp = true, .pic = true, }), + .linkage = .static, }); if (system_simdutf) { simd_cpp.root_module.linkSystemLibrary("simdutf", dynamic_link_opts);