motiejus/zig

fork of https://codeberg.org/ziglang/zig
git clone https://git.jakstys.lt/motiejus/zig.git
Log | Tree | Refs | README | LICENSE

commit d6b1ff7533295eab7d6cebe75491bc4bb21e2c21 (tree)
parent 2387305b23006f23eb16d0512321c612f46abcab
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed,  4 Jun 2025 10:39:18 -0700

Compilation.Config: eliminate the only variable from this function

Diffstat:
Msrc/Compilation/Config.zig | 27++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig @@ -318,14 +318,6 @@ pub fn resolve(options: Options) ResolveError!Config { break :b false; }; - var link_libunwind = b: { - if (link_libcpp and target_util.libCxxNeedsLibUnwind(target)) { - if (options.link_libunwind == false) return error.LibCppRequiresLibUnwind; - break :b true; - } - break :b options.link_libunwind orelse false; - }; - const link_libc = b: { if (target_util.osRequiresLibC(target)) { if (options.link_libc == false) return error.OsRequiresLibC; @@ -335,7 +327,7 @@ pub fn resolve(options: Options) ResolveError!Config { if (options.link_libc == false) return error.LibCppRequiresLibC; break :b true; } - if (link_libunwind) { + if (options.link_libunwind == true) { if (options.link_libc == false) return error.LibUnwindRequiresLibC; break :b true; } @@ -406,12 +398,17 @@ pub fn resolve(options: Options) ResolveError!Config { break :b .static; }; - // This is done here to avoid excessive duplicated logic due to the complex dependencies between these options. - if (options.output_mode == .Exe and link_libc and target_util.libCNeedsLibUnwind(target, link_mode)) { - if (options.link_libunwind == false) return error.LibCRequiresLibUnwind; - - link_libunwind = true; - } + const link_libunwind = b: { + if (options.output_mode == .Exe and link_libc and target_util.libCNeedsLibUnwind(target, link_mode)) { + if (options.link_libunwind == false) return error.LibCRequiresLibUnwind; + break :b true; + } + if (link_libcpp and target_util.libCxxNeedsLibUnwind(target)) { + if (options.link_libunwind == false) return error.LibCppRequiresLibUnwind; + break :b true; + } + break :b options.link_libunwind orelse false; + }; const import_memory = options.import_memory orelse (options.output_mode == .Obj); const export_memory = b: {