From 68e2f46b89537d4af5db5bce3dc906a54ceb0eb9 Mon Sep 17 00:00:00 2001 From: Techatrix Date: Sat, 24 Jan 2026 22:31:57 +0100 Subject: [PATCH] add build option to enable thread safety --- build.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.zig b/build.zig index d8a9452..d32d981 100644 --- a/build.zig +++ b/build.zig @@ -7,6 +7,8 @@ pub fn build(b: *Build) void { const mbedtls_dep = b.dependency("mbedtls", .{}); + const threading = b.option(bool, "threading", "Enable thread safety") orelse false; + const mbedtls = b.addLibrary(.{ .name = "mbedtls", .linkage = .static, @@ -25,6 +27,10 @@ pub fn build(b: *Build) void { // Otherwise `explicit_bzero` cannot be found mbedtls.root_module.addCMacro("__BSD_VISIBLE", "1"); } + if (threading) { + mbedtls.root_module.addCMacro("MBEDTLS_THREADING_C", ""); + mbedtls.root_module.addCMacro("MBEDTLS_THREADING_PTHREAD", ""); + } mbedtls.installHeadersDirectory(mbedtls_dep.path("include/mbedtls"), "mbedtls", .{}); mbedtls.installHeadersDirectory(mbedtls_dep.path("include/psa"), "psa", .{});