aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2024-12-13 03:09:24 +0100
committerGitHub <noreply@github.com>2024-12-13 03:09:24 +0100
commit130f7c2ed8e3358e24bb2fc7cca57f7a6f1f85c3 (patch)
treeebb88312b13fb8b1e67b852bcb0e42903ad11193 /src/Compilation
parentd48611ba67c7871cb348f28a01b89d8771170dd8 (diff)
parentc666ebb1f8aac440a4d0d554e9f8aa836bf58060 (diff)
downloadzig-130f7c2ed8e3358e24bb2fc7cca57f7a6f1f85c3.tar.gz
zig-130f7c2ed8e3358e24bb2fc7cca57f7a6f1f85c3.zip
Merge pull request #22035 from alexrp/unwind-fixes
Better unwind table support + unwind protection in `_start()` and `clone()`
Diffstat (limited to 'src/Compilation')
-rw-r--r--src/Compilation/Config.zig24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig
index 4458d474bb..baaa6c9f47 100644
--- a/src/Compilation/Config.zig
+++ b/src/Compilation/Config.zig
@@ -12,13 +12,14 @@ 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 true if any Module has unwind_tables set explicitly to true. Until
-/// Compilation.create is called, it is possible for this to be false while in
-/// fact all Module instances have unwind_tables=true due to the default
-/// being unwind_tables=true. After Compilation.create is called this will
-/// also take into account the default setting, making this value true if and
-/// only if any Module has unwind_tables set to true.
-any_unwind_tables: bool,
+/// This is not `.none` 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
+/// `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,
/// 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
@@ -85,7 +86,7 @@ pub const Options = struct {
any_non_single_threaded: bool = false,
any_sanitize_thread: bool = false,
any_fuzz: bool = false,
- any_unwind_tables: bool = false,
+ any_unwind_tables: std.builtin.UnwindTables = .none,
any_dyn_libs: bool = false,
any_c_source_files: bool = false,
any_non_stripped: bool = false,
@@ -356,8 +357,11 @@ pub fn resolve(options: Options) ResolveError!Config {
break :b false;
};
- const any_unwind_tables = options.any_unwind_tables or
- link_libunwind or target_util.needUnwindTables(target);
+ 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) {