Skip to content

Commit bf8dbd2

Browse files
Add tests. Fix unsupported target errors.
1 parent 0e3d407 commit bf8dbd2

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2618,7 +2618,13 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26182618
DwarfVersion, llvm::DebuggerKind::Default);
26192619
}
26202620
} else if (Value == "--gsframe") {
2621-
CmdArgs.push_back("--gsframe");
2621+
if (Triple.isOSBinFormatELF() && Triple.isX86()) {
2622+
CmdArgs.push_back("--gsframe");
2623+
} else {
2624+
D.Diag(diag::err_drv_unsupported_opt_for_target)
2625+
<< Value << D.getTargetTriple();
2626+
break;
2627+
}
26222628
} else if (Value.starts_with("-mcpu") || Value.starts_with("-mfpu") ||
26232629
Value.starts_with("-mhwdiv") || Value.starts_with("-march")) {
26242630
// Do nothing, we'll validate it later.

clang/test/Driver/sframe.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang -### -c --target=x86_64 -Wa,--gsframe %s -Werror 2>&1 | FileCheck %s
2+
// CHECK: "-cc1" {{.*}}"--gsframe"
3+
4+
// RUN: %clang -### -c --target=x86_64 %s 2>&1 | FileCheck %s --check-prefix=NO
5+
// NO: "-cc1"
6+
7+
// RUN: %clang -### -c --target=x86_64 -Werror -Wa,--gsframe -x assembler %s -Werror 2>&1 | FileCheck %s --check-prefix=ASM
8+
// ASM: "-cc1as" {{.*}}"--gsframe"
9+
10+
// RUN: not %clang -### -c --target=mips64 -Wa,--gsframe %s 2>&1 | FileCheck %s --check-prefix=NOTARGETC
11+
// NOTARGETC: error: unsupported option '--gsframe' for target '{{.*}}'
12+
13+
// RUN: not %clang -### -c --target=mips64 -Wa,--gsframe -x assembler %s 2>&1 | FileCheck %s --check-prefix=NOTARGETASM
14+
// NOTARGETASM: error: unsupported option '--gsframe' for target '{{.*}}'
15+

clang/test/Misc/cc1as-sframe.s

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// REQUIRES: x86-registered-target
2+
// RUN: %clang -cc1as -triple x86_64 %s -filetype obj --gsframe -o %t.o
3+
// RUN: llvm-readelf -S %t.o | FileCheck %s
4+
5+
// CHECK: .sframe
6+
.cfi_startproc
7+
call foo
8+
.cfi_endproc

0 commit comments

Comments
 (0)