pkg/highway: always linkLibC

This commit is contained in:
Mitchell Hashimoto
2026-04-24 09:26:12 -07:00
parent ca3288ca93
commit 1c3a571312
3 changed files with 9 additions and 8 deletions

View File

@@ -3,7 +3,6 @@ const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const no_libc = b.option(bool, "no_libc", "Avoid linking libc when embedding Highway into no-libc builds") orelse false;
const upstream_ = b.lazyDependency("highway", .{});
@@ -23,9 +22,9 @@ pub fn build(b: *std.Build) !void {
.linkage = .static,
});
// Our highway package is free of libc at runtime, so only libc-backed
// consumers should request it explicitly.
if (!no_libc) lib.linkLibC();
// We don't use libc at runtime but we do need the headers at
// compile time.
lib.linkLibC();
lib.addIncludePath(b.path("src/cpp"));
if (upstream_) |upstream| {

View File

@@ -29,15 +29,18 @@ pub fn build(b: *std.Build) !void {
.linkage = .static,
});
lib.addIncludePath(b.path("vendor"));
if (!no_libc) lib.linkLibC();
libcpp: {
libc: {
// We always link libc because we require the headers even with
// no_libc set.
lib.linkLibC();
if (target.result.abi == .msvc) {
// On MSVC, we must not use linkLibCpp because Zig unconditionally
// passes -nostdinc++ and then adds its bundled libc++/libc++abi
// include paths, which conflict with MSVC's own C++ runtime headers.
// The MSVC SDK include directories (added via linkLibC) contain
// both C and C++ headers, so linkLibCpp is not needed.
break :libcpp;
break :libc;
}
// We link libcpp even with no_libcxx because simdutf requires

View File

@@ -802,7 +802,6 @@ pub fn addSimd(
} else if (b.lazyDependency("highway", .{
.target = target,
.optimize = optimize,
.no_libc = simd_libc == .no_libc,
})) |highway_dep| lib: {
const lib = highway_dep.artifact("highway");
if (simd_libc == .no_libc) {