Skip to content

Commit 0be05ee

Browse files
committed
add single-threaded build option and enable mbedtls threading by default
1 parent 5962ca4 commit 0be05ee

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

build.zig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub fn build(b: *std.Build) !void {
88
const target = b.standardTargetOptions(.{});
99
const optimize = b.standardOptimizeOption(.{});
1010

11+
const single_threaded = b.option(bool, "single-threaded", "Build in single threaded mode");
1112
const linkage = b.option(std.builtin.LinkMode, "linkage", "Link mode") orelse .static;
1213
const strip = b.option(bool, "strip", "Omit debug information");
1314
const pic = b.option(bool, "pie", "Produce Position Independent Code");
@@ -55,7 +56,7 @@ pub fn build(b: *std.Build) !void {
5556

5657
var enable_windows_sspi = b.option(bool, "windows-sspi", "Enable SSPI on Windows (default: use-schannel)") orelse use_schannel;
5758
const enable_ipv6 = b.option(bool, "enable-ipv6", "Enable IPv6 support (default: true)") orelse true;
58-
const enable_threaded_resolver = dependentBoolOption(b, "threaded-resolver", "Enable threaded DNS lookup", true, !enable_ares, false);
59+
const enable_threaded_resolver = dependentBoolOption(b, "threaded-resolver", "Enable threaded DNS lookup", true, !(single_threaded orelse false) and !enable_ares, false);
5960
const enable_unicode = b.option(bool, "unicode", "Use the Unicode version of the Windows API functions (default: false)") orelse false;
6061
const enable_unix_sockets = b.option(bool, "unix-sockets", "Enable Unix domain sockets support (default: true)") orelse true;
6162
const ech = b.option(bool, "ech", "Enable ECH support (default: false)") orelse false;
@@ -133,6 +134,7 @@ pub fn build(b: *std.Build) !void {
133134
.target = target,
134135
.optimize = optimize,
135136
.link_libc = true,
137+
.single_threaded = single_threaded,
136138
.strip = strip,
137139
.pic = pic,
138140
}),
@@ -153,6 +155,7 @@ pub fn build(b: *std.Build) !void {
153155
.target = target,
154156
.optimize = optimize,
155157
.link_libc = true,
158+
.single_threaded = single_threaded,
156159
.strip = strip,
157160
.pic = pic,
158161
}),
@@ -326,6 +329,7 @@ pub fn build(b: *std.Build) !void {
326329
if (b.lazyDependency("mbedtls", .{
327330
.target = target,
328331
.optimize = optimize,
332+
.threading = !(single_threaded orelse false),
329333
})) |dependency| {
330334
curl.root_module.linkLibrary(dependency.artifact("mbedtls"));
331335
// TODO infer the version
@@ -385,6 +389,7 @@ pub fn build(b: *std.Build) !void {
385389
if (b.lazyDependency("zstd", .{
386390
.target = target,
387391
.optimize = optimize,
392+
.@"multi-thread" = if (single_threaded orelse false) false else null,
388393
})) |dependency| {
389394
curl.root_module.linkLibrary(dependency.artifact("zstd"));
390395
}
@@ -893,7 +898,7 @@ pub fn build(b: *std.Build) !void {
893898
.PACKAGE_VERSION = b.fmt("{f}", .{version}),
894899
.STDC_HEADERS = true,
895900
.USE_ARES = enable_ares,
896-
.USE_THREADS_POSIX = target.result.os.tag != .windows and !target.result.os.tag.isBSD(),
901+
.USE_THREADS_POSIX = enable_threaded_resolver and target.result.os.tag != .windows and !target.result.os.tag.isBSD(),
897902
.USE_THREADS_WIN32 = enable_threaded_resolver and target.result.os.tag == .windows,
898903
.USE_GNUTLS = use_gnutls,
899904
.USE_SSLS_EXPORT = use_ssls_export,

0 commit comments

Comments
 (0)