[clang] 357d00d - [clang][Driver] Allow `-fstack-clash-protection` for Fuchsia targets (#119633)

via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 12 09:47:15 PST 2024


Author: Paul Kirth
Date: 2024-12-12T09:47:10-08:00
New Revision: 357d00d7c7c81768047e9e9668c6f507c6c24cb3

URL: https://github.com/llvm/llvm-project/commit/357d00d7c7c81768047e9e9668c6f507c6c24cb3
DIFF: https://github.com/llvm/llvm-project/commit/357d00d7c7c81768047e9e9668c6f507c6c24cb3.diff

LOG: [clang][Driver] Allow `-fstack-clash-protection`  for Fuchsia targets (#119633)

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.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/stack-clash-protection.c

Removed: 
    


################################################################################
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"


        


More information about the cfe-commits mailing list