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/target.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/target.zig')
| -rw-r--r-- | src/target.zig | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/target.zig b/src/target.zig index 04c25a5f0c..68777945a9 100644 --- a/src/target.zig +++ b/src/target.zig @@ -360,6 +360,13 @@ pub fn supportsStackProtector(target: std.Target, backend: std.builtin.CompilerB }; } +pub fn clangSupportsStackProtector(target: std.Target) bool { + return switch (target.cpu.arch) { + .spirv32, .spirv64 => return false, + else => true, + }; +} + pub fn libcProvidesStackProtector(target: std.Target) bool { return !target.isMinGW() and target.os.tag != .wasi and !target.isSpirV(); } |
