From ef4d7f01a5c26d8ed6fa8236d1b64e4091a51be3 Mon Sep 17 00:00:00 2001 From: Alex Rønne Petersen Date: Thu, 23 Jan 2025 01:38:20 +0100 Subject: compiler: Fix computation of Compilation.Config.any_unwind_tables. This moves the default value logic to Package.Module.create() instead and makes it so that Compilation.Config.any_unwind_tables is computed similarly to any_sanitize_thread, any_fuzz, etc. It turns out that for any_unwind_tables, we only actually care if unwind tables are enabled at all, not at what level. --- src/Package/Module.zig | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/Package/Module.zig') diff --git a/src/Package/Module.zig b/src/Package/Module.zig index 433a9b6ade..62b7f075dd 100644 --- a/src/Package/Module.zig +++ b/src/Package/Module.zig @@ -112,7 +112,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { if (options.inherited.sanitize_thread == true) assert(options.global.any_sanitize_thread); if (options.inherited.fuzz == true) assert(options.global.any_fuzz); if (options.inherited.single_threaded == false) assert(options.global.any_non_single_threaded); - if (options.inherited.unwind_tables) |uwt| if (uwt != .none) assert(options.global.any_unwind_tables != .none); + if (options.inherited.unwind_tables) |uwt| if (uwt != .none) assert(options.global.any_unwind_tables); if (options.inherited.error_tracing == true) assert(options.global.any_error_tracing); const resolved_target = options.inherited.resolved_target orelse options.parent.?.resolved_target; @@ -121,9 +121,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { const optimize_mode = options.inherited.optimize_mode orelse if (options.parent) |p| p.optimize_mode else .Debug; - const unwind_tables = options.inherited.unwind_tables orelse - if (options.parent) |p| p.unwind_tables else options.global.any_unwind_tables; - const strip = b: { if (options.inherited.strip) |x| break :b x; if (options.parent) |p| break :b p.strip; @@ -220,6 +217,17 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { break :b false; }; + const unwind_tables = b: { + if (options.inherited.unwind_tables) |x| break :b x; + if (options.parent) |p| break :b p.unwind_tables; + + break :b target_util.defaultUnwindTables( + target, + options.global.link_libunwind, + sanitize_thread or options.global.any_sanitize_thread, + ); + }; + const fuzz = b: { if (options.inherited.fuzz) |x| break :b x; if (options.parent) |p| break :b p.fuzz; -- cgit v1.2.3 From 41185d297ffcaf61776aa8e7610aea9d00fce3a4 Mon Sep 17 00:00:00 2001 From: Alex Rønne Petersen Date: Thu, 23 Jan 2025 01:43:57 +0100 Subject: Package.Module: Make create() fall back on options.global.root_optimize_mode. As is done for root_strip and root_error_tracing. --- src/Compilation/Config.zig | 2 ++ src/Package/Module.zig | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Package/Module.zig') diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig index c6ded8cfb2..41a8077203 100644 --- a/src/Compilation/Config.zig +++ b/src/Compilation/Config.zig @@ -56,6 +56,7 @@ export_memory: bool, shared_memory: bool, is_test: bool, debug_format: DebugFormat, +root_optimize_mode: std.builtin.OptimizeMode, root_strip: bool, root_error_tracing: bool, dll_export_fns: bool, @@ -508,6 +509,7 @@ pub fn resolve(options: Options) ResolveError!Config { .use_lld = use_lld, .wasi_exec_model = wasi_exec_model, .debug_format = debug_format, + .root_optimize_mode = root_optimize_mode, .root_strip = root_strip, .dll_export_fns = dll_export_fns, .rdynamic = rdynamic, diff --git a/src/Package/Module.zig b/src/Package/Module.zig index 62b7f075dd..5b3a487a49 100644 --- a/src/Package/Module.zig +++ b/src/Package/Module.zig @@ -119,7 +119,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { const target = resolved_target.result; const optimize_mode = options.inherited.optimize_mode orelse - if (options.parent) |p| p.optimize_mode else .Debug; + if (options.parent) |p| p.optimize_mode else options.global.root_optimize_mode; const strip = b: { if (options.inherited.strip) |x| break :b x; -- cgit v1.2.3