diff --git a/pkg/simdutf/build.zig b/pkg/simdutf/build.zig index c1455dc32..95dd47483 100644 --- a/pkg/simdutf/build.zig +++ b/pkg/simdutf/build.zig @@ -85,6 +85,7 @@ pub fn build(b: *std.Build) !void { .target = target, .optimize = optimize, .link_libc = false, + .pic = true, }), }); lib.addObject(no_libc_obj); diff --git a/src/build/GhosttyZig.zig b/src/build/GhosttyZig.zig index 44c300e15..b2d6b7d93 100644 --- a/src/build/GhosttyZig.zig +++ b/src/build/GhosttyZig.zig @@ -119,11 +119,11 @@ fn initVt( .target = cfg.target, .optimize = cfg.optimize, - // SIMD requires libc. Vendored C++ dependencies are built with - // no-libcxx mode (HWY_NO_LIBCXX / SIMDUTF_NO_LIBCXX) so we - // don't need libcpp. System-provided simdutf headers still - // use C++ stdlib headers, so we need libcpp in that case. - .link_libc = if (cfg.simd) true else null, + // Vendored C++ dependencies are built with no-libcxx and + // no-libc modes so we don't need libc or libcpp. System-provided + // simdutf requires both libc and libcpp at runtime. + .link_libc = if (cfg.simd and + b.systemIntegrationOption("simdutf", .{})) true else null, .link_libcpp = if (cfg.simd and b.systemIntegrationOption("simdutf", .{}) and cfg.target.result.abi != .msvc) true else null, @@ -138,9 +138,12 @@ fn initVt( deps.addUucode(b, vt, cfg.target, cfg.optimize); // If SIMD is enabled, add all our SIMD dependencies. - if (cfg.simd) { - try SharedDeps.addSimd(b, vt, simd_libs); - } + if (cfg.simd) try SharedDeps.addSimd( + b, + vt, + simd_libs, + if (cfg.emit_lib_vt) .no_libc else .libc, + ); return vt; } diff --git a/src/build/SharedDeps.zig b/src/build/SharedDeps.zig index b68be92d0..b35a55ced 100644 --- a/src/build/SharedDeps.zig +++ b/src/build/SharedDeps.zig @@ -381,6 +381,7 @@ pub fn add( b, step.root_module, &static_libs, + .libc, ); // Wasm we do manually since it is such a different build. @@ -755,10 +756,13 @@ fn addGtkNg( /// Add only the dependencies required for `Config.simd` enabled. This also /// adds all the simd source files for compilation. +const SimdLibc = enum { libc, no_libc }; + pub fn addSimd( b: *std.Build, m: *std.Build.Module, static_libs: ?*LazyPathList, + simd_libc: SimdLibc, ) !void { const target = m.resolved_target.?; const optimize = m.optimize.?; @@ -772,6 +776,7 @@ pub fn addSimd( .target = target, .optimize = optimize, .no_libcxx = true, + .no_libc = simd_libc == .no_libc, })) |simdutf_dep| { m.linkLibrary(simdutf_dep.artifact("simdutf")); if (static_libs) |v| try v.append(