[clang] 6609892 - [clang] allow -fstack-clash-protection on FreeBSD

Ed Maste via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 24 18:03:13 PDT 2021


Author: Ed Maste
Date: 2021-08-24T21:02:36-04:00
New Revision: 6609892a2dcdd1a4f6adefe191b55524861f020c

URL: https://github.com/llvm/llvm-project/commit/6609892a2dcdd1a4f6adefe191b55524861f020c
DIFF: https://github.com/llvm/llvm-project/commit/6609892a2dcdd1a4f6adefe191b55524861f020c.diff

LOG: [clang] allow -fstack-clash-protection on FreeBSD

-fstack-clash-protection was added in Clang commit e67cbac81211 but was
enabled only on Linux.  Allow it on FreeBSD as well, as it works fine.

Reviewed By: serge-sans-paille

Differential Revision: https://reviews.llvm.org/D108571

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 e19e1222f702e..b973428549820 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3198,7 +3198,7 @@ static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
                              ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (!EffectiveTriple.isOSFreeBSD() && !EffectiveTriple.isOSLinux())
     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 5217ed26a5b19..048668fc951e3 100644
--- a/clang/test/Driver/stack-clash-protection.c
+++ b/clang/test/Driver/stack-clash-protection.c
@@ -5,6 +5,7 @@
 // SCP-i386-NO-NOT: "-fstack-clash-protection"
 
 // RUN: %clang -target x86_64-scei-linux -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-x86
+// RUN: %clang -target x86_64-unknown-freebsd -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-x86
 // SCP-x86: "-fstack-clash-protection"
 
 // RUN: %clang -target armv7k-apple-linux -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-armv7


        


More information about the cfe-commits mailing list