[clang] [clang][Driver] Allow `-fstack-clash-protection` for Fuchsia targets (PR #119633)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 11 15:30:30 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Paul Kirth (ilovepi)
<details>
<summary>Changes</summary>
Fuchsia uses guard pages for the stack, similar to Linux
and other targets, which are required for stack-clash-protection.
This patch adds Fuchsia to the list of allowed targets.
---
Full diff: https://github.com/llvm/llvm-project/pull/119633.diff
2 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+2-1)
- (modified) clang/test/Driver/stack-clash-protection.c (+5)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index d3206c3e8e25ed..a020e00cd17392 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3773,7 +3773,8 @@ static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
- if (!EffectiveTriple.isOSFreeBSD() && !EffectiveTriple.isOSLinux())
+ if (!EffectiveTriple.isOSFreeBSD() && !EffectiveTriple.isOSLinux() &&
+ !EffectiveTriple.isOSFuchsia())
return;
if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
diff --git a/clang/test/Driver/stack-clash-protection.c b/clang/test/Driver/stack-clash-protection.c
index 222452f7897a6f..3b0476db9d3cb1 100644
--- a/clang/test/Driver/stack-clash-protection.c
+++ b/clang/test/Driver/stack-clash-protection.c
@@ -22,6 +22,11 @@
// SCP-ll-win64-NOT: attributes {{.*}} "probe-stack"="inline-asm"
// SCP-ll-win64: argument unused during compilation: '-fstack-clash-protection'
+// RUN: %clang -target x86_64-unknown-fuchsia -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-FUCHSIA
+// RUN: %clang -target aarch64-unknown-fuchsia -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-FUCHSIA
+// RUN: %clang -target riscv64-unknown-fuchsia -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-FUCHSIA
+// SCP-FUCHSIA: "-fstack-clash-protection"
+
int foo(int c) {
int r;
__asm__("sub %0, %%rsp"
``````````
</details>
https://github.com/llvm/llvm-project/pull/119633
More information about the cfe-commits
mailing list