Skip to content

Commit 357d00d

Browse files
authored
[clang][Driver] Allow -fstack-clash-protection for Fuchsia targets (#119633)
Fuchsia uses guard pages for the stack, similar to Linux and other targets, which are required for stack-clash-protection. This patch adds Fuchsia to the list of allowed targets.
1 parent 9b14ded commit 357d00d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3773,7 +3773,8 @@ static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
37733773
ArgStringList &CmdArgs) {
37743774
const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
37753775

3776-
if (!EffectiveTriple.isOSFreeBSD() && !EffectiveTriple.isOSLinux())
3776+
if (!EffectiveTriple.isOSFreeBSD() && !EffectiveTriple.isOSLinux() &&
3777+
!EffectiveTriple.isOSFuchsia())
37773778
return;
37783779

37793780
if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&

clang/test/Driver/stack-clash-protection.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
// SCP-ll-win64-NOT: attributes {{.*}} "probe-stack"="inline-asm"
2323
// SCP-ll-win64: argument unused during compilation: '-fstack-clash-protection'
2424

25+
// RUN: %clang -target x86_64-unknown-fuchsia -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-FUCHSIA
26+
// RUN: %clang -target aarch64-unknown-fuchsia -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-FUCHSIA
27+
// RUN: %clang -target riscv64-unknown-fuchsia -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-FUCHSIA
28+
// SCP-FUCHSIA: "-fstack-clash-protection"
29+
2530
int foo(int c) {
2631
int r;
2732
__asm__("sub %0, %%rsp"

0 commit comments

Comments
 (0)