[clang] allow -fstack-clash-protection on FreeBSD
authorEd Maste <emaste@FreeBSD.org>
Mon, 23 Aug 2021 16:12:43 +0000 (12:12 -0400)
committerEd Maste <emaste@FreeBSD.org>
Wed, 25 Aug 2021 01:02:36 +0000 (21:02 -0400)
-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

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

index e19e122..b973428 100644 (file)
@@ -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() &&
index 5217ed2..048668f 100644 (file)
@@ -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