[llvm-branch-commits] [clang] 4d59c8f - -fstack-clash-protection: Return an actual error when used on unsupported OS

Sylvestre Ledru via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Dec 22 03:10:49 PST 2020


Author: Sylvestre Ledru
Date: 2020-12-22T12:06:08+01:00
New Revision: 4d59c8fdb955ea0d668b854f467e12bce05a8857

URL: https://github.com/llvm/llvm-project/commit/4d59c8fdb955ea0d668b854f467e12bce05a8857
DIFF: https://github.com/llvm/llvm-project/commit/4d59c8fdb955ea0d668b854f467e12bce05a8857.diff

LOG: -fstack-clash-protection: Return an actual error when used on unsupported OS

$ clang-12: error: -fstack-clash-protection is not supported on Windows or Mac OS X

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

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticDriverKinds.td
    clang/lib/Driver/ToolChains/Clang.cpp
    llvm/test/CodeGen/X86/stack-clash-large.ll

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index e92a4bf1dac5..736950b0abb1 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -273,6 +273,8 @@ def err_drv_unsupported_embed_bitcode
     : Error<"%0 is not supported with -fembed-bitcode">;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+def err_drv_stack_clash_protection_unsupported_on_toolchain : Error<
+  "-fstack-clash-protection is not supported on %0">;
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 300ab6e815e2..c04b350dae7d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3067,12 +3067,15 @@ static void RenderSSPOptions(const Driver &D, const ToolChain &TC,
   }
 }
 
-static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
-                             ArgStringList &CmdArgs) {
+static void RenderSCPOptions(const Driver &D, const ToolChain &TC,
+                             const ArgList &Args, ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (EffectiveTriple.isOSWindows()) {
+    D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain)
+        << EffectiveTriple.getOSName();
     return;
+  }
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
       !EffectiveTriple.isPPC64())
@@ -5550,7 +5553,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
-  RenderSCPOptions(TC, Args, CmdArgs);
+  RenderSCPOptions(D, TC, Args, CmdArgs);
   RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
 
   // Translate -mstackrealign

diff  --git a/llvm/test/CodeGen/X86/stack-clash-large.ll b/llvm/test/CodeGen/X86/stack-clash-large.ll
index dd53cd8f6964..7deae310f617 100644
--- a/llvm/test/CodeGen/X86/stack-clash-large.ll
+++ b/llvm/test/CodeGen/X86/stack-clash-large.ll
@@ -1,5 +1,7 @@
 ; RUN: llc -mtriple=x86_64-linux-android < %s | FileCheck -check-prefix=CHECK-X86-64 %s 
 ; RUN: llc -mtriple=i686-linux-android < %s | FileCheck -check-prefix=CHECK-X86-32 %s 
+; RUN: llc -mtriple=x86_64-unknown-freebsd < %s | FileCheck -check-prefix=CHECK-X86-64 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu < %s | FileCheck -check-prefix=CHECK-X86-64 %s
 
 define i32 @foo() local_unnamed_addr #0 {
 


        


More information about the llvm-branch-commits mailing list