authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-06-04 10:39:18-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-06-06 23:42:14-07:00
logd6b1ff7533295eab7d6cebe75491bc4bb21e2c21
tree918d60aec99ccf1c99b4767976cd01e2e1e507f0
parent2387305b23006f23eb16d0512321c612f46abcab

Compilation.Config: eliminate the only variable from this function


1 files changed, 12 insertions(+), 15 deletions(-)

src/Compilation/Config.zig+12-15
...@@ -318,14 +318,6 @@ pub fn resolve(options: Options) ResolveError!Config {...@@ -318,14 +318,6 @@ pub fn resolve(options: Options) ResolveError!Config {
318 break :b false;318 break :b false;
319 };319 };
320320
321 var link_libunwind = b: {
322 if (link_libcpp and target_util.libCxxNeedsLibUnwind(target)) {
323 if (options.link_libunwind == false) return error.LibCppRequiresLibUnwind;
324 break :b true;
325 }
326 break :b options.link_libunwind orelse false;
327 };
328
329 const link_libc = b: {321 const link_libc = b: {
330 if (target_util.osRequiresLibC(target)) {322 if (target_util.osRequiresLibC(target)) {
331 if (options.link_libc == false) return error.OsRequiresLibC;323 if (options.link_libc == false) return error.OsRequiresLibC;
...@@ -335,7 +327,7 @@ pub fn resolve(options: Options) ResolveError!Config {...@@ -335,7 +327,7 @@ pub fn resolve(options: Options) ResolveError!Config {
335 if (options.link_libc == false) return error.LibCppRequiresLibC;327 if (options.link_libc == false) return error.LibCppRequiresLibC;
336 break :b true;328 break :b true;
337 }329 }
338 if (link_libunwind) {330 if (options.link_libunwind == true) {
339 if (options.link_libc == false) return error.LibUnwindRequiresLibC;331 if (options.link_libc == false) return error.LibUnwindRequiresLibC;
340 break :b true;332 break :b true;
341 }333 }
...@@ -406,12 +398,17 @@ pub fn resolve(options: Options) ResolveError!Config {...@@ -406,12 +398,17 @@ pub fn resolve(options: Options) ResolveError!Config {
406 break :b .static;398 break :b .static;
407 };399 };
408400
409 // This is done here to avoid excessive duplicated logic due to the complex dependencies between these options.401 const link_libunwind = b: {
410 if (options.output_mode == .Exe and link_libc and target_util.libCNeedsLibUnwind(target, link_mode)) {402 if (options.output_mode == .Exe and link_libc and target_util.libCNeedsLibUnwind(target, link_mode)) {
411 if (options.link_libunwind == false) return error.LibCRequiresLibUnwind;403 if (options.link_libunwind == false) return error.LibCRequiresLibUnwind;
412404 break :b true;
413 link_libunwind = true;405 }
414 }406 if (link_libcpp and target_util.libCxxNeedsLibUnwind(target)) {
407 if (options.link_libunwind == false) return error.LibCppRequiresLibUnwind;
408 break :b true;
409 }
410 break :b options.link_libunwind orelse false;
411 };
415412
416 const import_memory = options.import_memory orelse (options.output_mode == .Obj);413 const import_memory = options.import_memory orelse (options.output_mode == .Obj);
417 const export_memory = b: {414 const export_memory = b: {