zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f04799dc9c60189b11f0bbcd4f0027b9928ef6e4 (tree)
parent 7ee6e7d61edcd19c594cb40fdb64703f58e32994
Author: Zhalkhas <jalgas1998@gmail.com>
Date:   Thu, 28 May 2026 04:32:23 +0200

implicitly enable LLVM when TSan is enabled (#35311)

FIxes #32127

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35311

Diffstat:
Msrc/Compilation/Config.zig | 7+++++++
Msrc/main.zig | 1+
2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig @@ -146,6 +146,7 @@ pub const ResolveError = error{ DynamicLibraryPrecludesPie, TargetRequiresPie, SanitizeThreadRequiresPie, + SanitizeThreadRequiresLlvmBackend, BackendLacksErrorTracing, LlvmLibraryUnavailable, LldUnavailable, @@ -342,6 +343,12 @@ pub fn resolve(options: Options) ResolveError!Config { break :b true; } + if (options.any_sanitize_thread) { + // Thread sanitization instrumentation requires the LLVM backend. + if (options.use_llvm == false) return error.SanitizeThreadRequiresLlvmBackend; + break :b true; + } + if (options.use_llvm) |x| break :b x; // If we cannot use LLVM libraries, then our own backends will be a diff --git a/src/main.zig b/src/main.zig @@ -4131,6 +4131,7 @@ fn createModule( error.DynamicLibraryPrecludesPie => fatal("dynamic libraries cannot be position independent executables", .{}), error.TargetRequiresPie => fatal("the specified target requires position independent executables", .{}), error.SanitizeThreadRequiresPie => fatal("thread sanitization requires position independent executables", .{}), + error.SanitizeThreadRequiresLlvmBackend => fatal("thread sanitization requires the LLVM backend", .{}), error.BackendLacksErrorTracing => fatal("the selected backend has not yet implemented error return tracing", .{}), error.LlvmLibraryUnavailable => fatal("zig was compiled without LLVM libraries", .{}), error.LldUnavailable => fatal("zig was compiled without LLD libraries", .{}),