diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-10-17 18:10:44 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-10-18 17:46:29 -0400 |
| commit | f9a34131128dffaeac7561afe34956ec2ee17fef (patch) | |
| tree | 05a82dd2fe7865e0f5a93946be1765c767130893 /src/Compilation.zig | |
| parent | edcb17daf8c24565ace4ca98a1c0a23a40bb5f0a (diff) | |
| download | zig-f9a34131128dffaeac7561afe34956ec2ee17fef.tar.gz zig-f9a34131128dffaeac7561afe34956ec2ee17fef.zip | |
compiler: better default for valgrind
* Default to off when strip=true
* Report an error when explicitly enabled but not supported for the
target
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 5bfabfdcfc..cb5281c696 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1111,12 +1111,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { return error.StackProtectorUnavailableWithoutLibC; } - const valgrind: bool = b: { - if (!target_util.hasValgrindSupport(options.target)) - break :b false; - break :b options.want_valgrind orelse (options.optimize_mode == .Debug); - }; - const include_compiler_rt = options.want_compiler_rt orelse needs_c_symbols; const must_single_thread = target_util.isSingleThreaded(options.target); @@ -1159,6 +1153,15 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { } const strip = options.strip orelse !target_util.hasDebugInfo(options.target); + const valgrind: bool = b: { + if (!target_util.hasValgrindSupport(options.target)) break :b false; + if (options.want_valgrind) |explicit| break :b explicit; + if (strip) break :b false; + break :b options.optimize_mode == .Debug; + }; + if (!valgrind and options.want_valgrind == true) + return error.ValgrindUnsupportedOnTarget; + const red_zone = options.want_red_zone orelse target_util.hasRedZone(options.target); const omit_frame_pointer = options.omit_frame_pointer orelse (options.optimize_mode != .Debug); const linker_optimization: u8 = options.linker_optimization orelse switch (options.optimize_mode) { |
