[PATCH] D108571: [clang] allow -fstack-clash-protection on FreeBSD

Ed Maste via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 23 11:54:12 PDT 2021


emaste created this revision.
emaste added reviewers: serge-sans-paille, craig.topper, dim.
Herald added subscribers: krytarowski, arichardson.
emaste requested review of this revision.

`-fstack-clash-protection` was added in Clang commit e67cbac81211 <https://reviews.llvm.org/rGe67cbac81211d40332a79d98c9d5953624cc1202> but was enabled only on Linux.  Allow it on FreeBSD as well, as it works fine.


https://reviews.llvm.org/D108571

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


Index: clang/test/Driver/stack-clash-protection.c
===================================================================
--- clang/test/Driver/stack-clash-protection.c
+++ 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
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3198,7 +3198,7 @@
                              ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (!EffectiveTriple.isOSFreeBSD() && !EffectiveTriple.isOSLinux())
     return;
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108571.368163.patch
Type: text/x-patch
Size: 1212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210823/437f7f6c/attachment-0001.bin>


More information about the cfe-commits mailing list