libghostty: use no_libc mode for simd

This commit is contained in:
Mitchell Hashimoto
2026-04-24 06:45:32 -07:00
parent a6d5f2ea23
commit 423d8bb327
3 changed files with 17 additions and 8 deletions

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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(