diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-12-12 13:00:13 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-01 17:51:19 -0700 |
| commit | 43720be04af8ddb8334b210ff936a834fb8871a7 (patch) | |
| tree | 884a175200dc948e2a1bb40fb10472f356f2a9af /src/Package/Module.zig | |
| parent | 5a6a1f8a8ad1475d328c998824981c7b310987d2 (diff) | |
| download | zig-43720be04af8ddb8334b210ff936a834fb8871a7.tar.gz zig-43720be04af8ddb8334b210ff936a834fb8871a7.zip | |
frontend: fix stack protector option logic
Commit 97e23896a9168132b6d36ca22ae1af10dd53d80d regressed this behavior
because it made target_util.supportsStackProtector *correctly*
notice which zig backend is being used to generate code, while the
logic calling that function *incorrectly assumed* that .zig code is being
compiled, when in reality it might be only C code being compiled.
This commit adjusts the option resolution logic for stack protector so
that it takes into account the zig backend only if there is a zig
compilation unit. A separate piece of logic checks whether clang
supports stack protector for a given target.
closes #18009
closes #18114
closes #18254
Diffstat (limited to 'src/Package/Module.zig')
| -rw-r--r-- | src/Package/Module.zig | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Package/Module.zig b/src/Package/Module.zig index 94431856ac..f1e7091855 100644 --- a/src/Package/Module.zig +++ b/src/Package/Module.zig @@ -229,7 +229,18 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { }; const stack_protector: u32 = sp: { - if (!target_util.supportsStackProtector(target, zig_backend)) { + const use_zig_backend = options.global.have_zcu or + (options.global.any_c_source_files and options.global.c_frontend == .aro); + if (use_zig_backend and !target_util.supportsStackProtector(target, zig_backend)) { + if (options.inherited.stack_protector) |x| { + if (x > 0) return error.StackProtectorUnsupportedByTarget; + } + break :sp 0; + } + + if (options.global.any_c_source_files and options.global.c_frontend == .clang and + !target_util.clangSupportsStackProtector(target)) + { if (options.inherited.stack_protector) |x| { if (x > 0) return error.StackProtectorUnsupportedByTarget; } |
