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/Compilation/Config.zig | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/Compilation') diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig index e91055709c..c6ded8cfb2 100644 --- a/src/Compilation/Config.zig +++ b/src/Compilation/Config.zig @@ -12,14 +12,13 @@ link_libunwind: bool, /// True if and only if the c_source_files field will have nonzero length when /// calling Compilation.create. any_c_source_files: bool, -/// This is not `.none` if any `Module` has `unwind_tables` set explicitly to a +/// This is `true` if any `Module` has `unwind_tables` set explicitly to a /// value other than `.none`. Until `Compilation.create()` is called, it is -/// possible for this to be `.none` while in fact all `Module` instances have +/// possible for this to be `false` while in fact all `Module` instances have /// `unwind_tables != .none` due to the default. After `Compilation.create()` is /// called, this will also take into account the default setting, making this -/// value `.sync` or `.@"async"` if and only if any `Module` has -/// `unwind_tables != .none`. -any_unwind_tables: std.builtin.UnwindTables, +/// value `true` if and only if any `Module` has `unwind_tables != .none`. +any_unwind_tables: bool, /// This is true if any Module has single_threaded set explicitly to false. Until /// Compilation.create is called, it is possible for this to be false while in /// fact all Module instances have single_threaded=false due to the default @@ -88,7 +87,7 @@ pub const Options = struct { any_non_single_threaded: bool = false, any_sanitize_thread: bool = false, any_fuzz: bool = false, - any_unwind_tables: std.builtin.UnwindTables = .none, + any_unwind_tables: bool = false, any_dyn_libs: bool = false, any_c_source_files: bool = false, any_non_stripped: bool = false, @@ -359,12 +358,6 @@ pub fn resolve(options: Options) ResolveError!Config { break :b false; }; - const any_unwind_tables = b: { - if (options.any_unwind_tables != .none) break :b options.any_unwind_tables; - - break :b target_util.needUnwindTables(target, link_libunwind, options.any_sanitize_thread); - }; - const link_mode = b: { const explicitly_exe_or_dyn_lib = switch (options.output_mode) { .Obj => false, @@ -496,7 +489,7 @@ pub fn resolve(options: Options) ResolveError!Config { .link_libc = link_libc, .link_libcpp = link_libcpp, .link_libunwind = link_libunwind, - .any_unwind_tables = any_unwind_tables, + .any_unwind_tables = options.any_unwind_tables, .any_c_source_files = options.any_c_source_files, .any_non_single_threaded = options.any_non_single_threaded, .any_error_tracing = any_error_tracing, -- 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/Compilation') 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