| author | |
| committer | |
| log | 951c5b3f67e086c50ba8d0cd9318cb770fd3f724 |
| tree | 2d8e5b59801793cabd22b868312ccacd3e4b974e |
| parent | b8a8fb927b791b369234012a3d4ff5e2c4c466c9 |
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.2 files changed, 35 insertions(+), 6 deletions(-)
src/Compilation.zig+12-1| ... | ... | @@ -1198,7 +1198,12 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1198 | 1198 | |
| 1199 | 1199 | const use_llvm = options.config.use_llvm; |
| 1200 | 1200 | |
| 1201 | const any_unwind_tables = options.config.any_unwind_tables; | |
| 1201 | // The "any" values provided by resolved config only account for | |
| 1202 | // explicitly-provided settings. We now make them additionally account | |
| 1203 | // for default setting resolution. | |
| 1204 | const any_unwind_tables = options.config.any_unwind_tables or options.root_mod.unwind_tables; | |
| 1205 | const any_non_single_threaded = options.config.any_non_single_threaded or !options.root_mod.single_threaded; | |
| 1206 | const any_sanitize_thread = options.config.any_sanitize_thread or options.root_mod.sanitize_thread; | |
| 1202 | 1207 | |
| 1203 | 1208 | const link_eh_frame_hdr = options.link_eh_frame_hdr or any_unwind_tables; |
| 1204 | 1209 | const build_id = options.build_id orelse .none; |
| ... | ... | @@ -1503,6 +1508,12 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1503 | 1508 | .native_system_include_paths = options.native_system_include_paths, |
| 1504 | 1509 | }; |
| 1505 | 1510 | |
| 1511 | // Prevent some footguns by making the "any" fields of config reflect | |
| 1512 | // the default Module settings. | |
| 1513 | comp.config.any_unwind_tables = any_unwind_tables; | |
| 1514 | comp.config.any_non_single_threaded = any_non_single_threaded; | |
| 1515 | comp.config.any_sanitize_thread = any_sanitize_thread; | |
| 1516 | ||
| 1506 | 1517 | const lf_open_opts: link.File.OpenOptions = .{ |
| 1507 | 1518 | .linker_script = options.linker_script, |
| 1508 | 1519 | .z_nodelete = options.linker_z_nodelete, |
src/Compilation/Config.zig+23-5| ... | ... | @@ -1,4 +1,7 @@ |
| 1 | //! User-specified settings that have all the defaults resolved into concrete values. | |
| 1 | //! User-specified settings that have all the defaults resolved into concrete | |
| 2 | //! values. These values are observable before calling Compilation.create for | |
| 3 | //! the benefit of Module creation API, which needs access to these details in | |
| 4 | //! order to resolve per-Module defaults. | |
| 2 | 5 | |
| 3 | 6 | have_zcu: bool, |
| 4 | 7 | output_mode: std.builtin.OutputMode, |
| ... | ... | @@ -6,12 +9,27 @@ link_mode: std.builtin.LinkMode, |
| 6 | 9 | link_libc: bool, |
| 7 | 10 | link_libcpp: bool, |
| 8 | 11 | link_libunwind: bool, |
| 9 | any_unwind_tables: bool, | |
| 12 | /// True if and only if the c_source_files field will have nonzero length when | |
| 13 | /// calling Compilation.create. | |
| 10 | 14 | any_c_source_files: bool, |
| 15 | /// This is true if any Module has unwind_tables set explicitly to true. Until | |
| 16 | /// Compilation.create is called, it is possible for this to be false while in | |
| 17 | /// fact all Module instances have unwind_tables=true due to the default | |
| 18 | /// being unwind_tables=true. After Compilation.create is called this will | |
| 19 | /// also take into account the default setting, making this value true if and | |
| 20 | /// only if any Module has unwind_tables set to true. | |
| 21 | any_unwind_tables: bool, | |
| 22 | /// This is true if any Module has single_threaded set explicitly to false. Until | |
| 23 | /// Compilation.create is called, it is possible for this to be false while in | |
| 24 | /// fact all Module instances have single_threaded=false due to the default | |
| 25 | /// being non-single-threaded. After Compilation.create is called this will | |
| 26 | /// also take into account the default setting, making this value true if and | |
| 27 | /// only if any Module has single_threaded set to false. | |
| 11 | 28 | any_non_single_threaded: bool, |
| 12 | /// This is true if any Module has error_tracing set to true. Function types | |
| 13 | /// and function calling convention depend on this global value, however, other | |
| 14 | /// kinds of error tracing are omitted depending on the per-Module setting. | |
| 29 | /// This is true if and only if any Module has error_tracing set to true. | |
| 30 | /// Function types and function calling convention depend on this global value, | |
| 31 | /// however, other kinds of error tracing are omitted depending on the | |
| 32 | /// per-Module setting. | |
| 15 | 33 | any_error_tracing: bool, |
| 16 | 34 | any_sanitize_thread: bool, |
| 17 | 35 | pie: bool, |