diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-12-26 17:09:40 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-01 17:51:21 -0700 |
| commit | 951c5b3f67e086c50ba8d0cd9318cb770fd3f724 (patch) | |
| tree | 2d8e5b59801793cabd22b868312ccacd3e4b974e /src/Compilation.zig | |
| parent | b8a8fb927b791b369234012a3d4ff5e2c4c466c9 (diff) | |
| download | zig-951c5b3f67e086c50ba8d0cd9318cb770fd3f724.tar.gz zig-951c5b3f67e086c50ba8d0cd9318cb770fd3f724.zip | |
frontend: fix "any" default resolution ambiguity
In Compilation.create, update the resolved config to account for the
default resolution of the root module. This makes it so that, for
example, reading comp.config.any_non_single_threaded is valid in order
to determine whether any module has single_threaded=false.
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 00d6ec3193..15b507b7a4 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1198,7 +1198,12 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { const use_llvm = options.config.use_llvm; - const any_unwind_tables = options.config.any_unwind_tables; + // The "any" values provided by resolved config only account for + // explicitly-provided settings. We now make them additionally account + // for default setting resolution. + const any_unwind_tables = options.config.any_unwind_tables or options.root_mod.unwind_tables; + const any_non_single_threaded = options.config.any_non_single_threaded or !options.root_mod.single_threaded; + const any_sanitize_thread = options.config.any_sanitize_thread or options.root_mod.sanitize_thread; const link_eh_frame_hdr = options.link_eh_frame_hdr or any_unwind_tables; const build_id = options.build_id orelse .none; @@ -1503,6 +1508,12 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { .native_system_include_paths = options.native_system_include_paths, }; + // Prevent some footguns by making the "any" fields of config reflect + // the default Module settings. + comp.config.any_unwind_tables = any_unwind_tables; + comp.config.any_non_single_threaded = any_non_single_threaded; + comp.config.any_sanitize_thread = any_sanitize_thread; + const lf_open_opts: link.File.OpenOptions = .{ .linker_script = options.linker_script, .z_nodelete = options.linker_z_nodelete, |
