[clang] tune the default stack protector level as SSPOn on Windows platform (PR #107043)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 3 00:49:41 PDT 2024


https://github.com/wenqinI updated https://github.com/llvm/llvm-project/pull/107043

>From dd5a44532e2d50348bfdcaef1ae297fd4688ce8c Mon Sep 17 00:00:00 2001
From: "wenqin.yang" <wenqin.yang at intel.com>
Date: Tue, 3 Sep 2024 10:42:12 +0800
Subject: [PATCH 1/2] tune the default stack protector level as SSPOn on
 Windows platform

---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index df86941950e46e..d94791f8621197 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -8326,7 +8326,7 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
   if (!isNVPTX && Args.hasFlag(options::OPT__SLASH_GS, options::OPT__SLASH_GS_,
                                /*Default=*/true)) {
     CmdArgs.push_back("-stack-protector");
-    CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
+    CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPOn)));
   }
 
   const Driver &D = getToolChain().getDriver();

>From 62ac3c61371aeadf0e95f2d212248d2f2243408c Mon Sep 17 00:00:00 2001
From: "wenqin.yang" <wenqin.yang at intel.com>
Date: Tue, 3 Sep 2024 15:22:22 +0800
Subject: [PATCH 2/2] --amend

---
 clang/test/Driver/cl-options.c  | 4 ++--
 clang/test/Driver/cl-options.cu | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index a6f338533ad763..e70676f99508e3 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -112,10 +112,10 @@
 
 // Security Buffer Check is on by default.
 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=GS-default %s
-// GS-default: "-stack-protector" "2"
+// GS-default: "-stack-protector" "1"
 
 // RUN: %clang_cl /GS -### -- %s 2>&1 | FileCheck -check-prefix=GS %s
-// GS: "-stack-protector" "2"
+// GS: "-stack-protector" "1"
 
 // RUN: %clang_cl /GS- -### -- %s 2>&1 | FileCheck -check-prefix=GS_ %s
 // GS_-NOT: -stack-protector
diff --git a/clang/test/Driver/cl-options.cu b/clang/test/Driver/cl-options.cu
index b241ec6672d851..b60f3479293928 100644
--- a/clang/test/Driver/cl-options.cu
+++ b/clang/test/Driver/cl-options.cu
@@ -8,7 +8,7 @@
 // GS-default: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
 // GS-default-NOT: "-stack-protector"
 // GS-default: "-cc1" "-triple"
-// GS-default: "-stack-protector" "2"
+// GS-default: "-stack-protector" "1"
 
 // -exceptions should be passed to device-side compilation.
 // RUN: not %clang_cl /c /GX -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck -check-prefix=GX %s



More information about the cfe-commits mailing list