Skip to content

Commit b6f61f6

Browse files
authored
[Driver][SYCL] Allow for -fcf-protection to run on host only (#7251)
The -fcf-protection option is not supported for spir64 targets. This causes an error during device compilation when compiled with -fsycl. Allow the option to be accepted and work on the host compilation side only, emitting a diagnostic that the option is being ignored for the target compiles. before: clang++ -fsycl -fcf-protection -c a.cpp error: option 'cf-protection=return' cannot be specified on this target error: option 'cf-protection=branch' cannot be specified on this target 2 errors generated. after: clang++ -fsycl -fcf-protection -c a.cpp clang-16: warning: ignoring '-fcf-protection' option as it is not currently supported for target 'spir64-unknown-unknown' [-Woption-ignored]
1 parent 77b6f34 commit b6f61f6

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,8 @@ SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
700700

701701
// Diagnose unsupported options only once.
702702
// All sanitizer options are not currently supported.
703-
for (auto A : Args.filtered(options::OPT_fsanitize_EQ))
703+
for (auto A :
704+
Args.filtered(options::OPT_fsanitize_EQ, options::OPT_fcf_protection_EQ))
704705
D.getDiags().Report(clang::diag::warn_drv_unsupported_option_for_target)
705706
<< A->getAsString(Args) << getTriple().str();
706707
}
@@ -725,6 +726,7 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
725726
// compilation.
726727
switch ((options::ID)A->getOption().getID()) {
727728
case options::OPT_fsanitize_EQ:
729+
case options::OPT_fcf_protection_EQ:
728730
break;
729731
default:
730732
DAL->append(A);
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
/// Diagnose unsupported options specific to SYCL compilations
22
// RUN: %clangxx -fsycl -fsanitize=address -fsycl-targets=spir64 -### %s 2>&1 \
3-
// RUN: | FileCheck %s --check-prefix=SANITIZE -DARCH=spir64
3+
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-fsanitize=address
44
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen -fsanitize=address -### %s 2>&1 \
5-
// RUN: | FileCheck %s --check-prefix=SANITIZE -DARCH=spir64_gen
5+
// RUN: | FileCheck %s -DARCH=spir64_gen -DOPT=-fsanitize=address
66
// RUN: %clangxx -fsycl -fsycl-targets=spir64_fpga -fsanitize=address -### %s 2>&1 \
7-
// RUN: | FileCheck %s --check-prefix=SANITIZE -DARCH=spir64_fpga
7+
// RUN: | FileCheck %s -DARCH=spir64_fpga -DOPT=-fsanitize=address
88
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64 -fsanitize=address -### %s 2>&1 \
9-
// RUN: | FileCheck %s --check-prefix=SANITIZE -DARCH=spir64_x86_64
10-
// SANITIZE: ignoring '-fsanitize=address' option as it is not currently supported for target '[[ARCH]]{{.*}}' [-Woption-ignored]
9+
// RUN: | FileCheck %s -DARCH=spir64_x86_64 -DOPT=-fsanitize=address
10+
11+
// RUN: %clangxx -fsycl -fcf-protection -fsycl-targets=spir64 -### %s 2>&1 \
12+
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-fcf-protection
13+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen -fcf-protection -### %s 2>&1 \
14+
// RUN: | FileCheck %s -DARCH=spir64_gen -DOPT=-fcf-protection
15+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_fpga -fcf-protection -### %s 2>&1 \
16+
// RUN: | FileCheck %s -DARCH=spir64_fpga -DOPT=-fcf-protection
17+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64 -fcf-protection -### %s 2>&1 \
18+
// RUN: | FileCheck %s -DARCH=spir64_x86_64 -DOPT=-fcf-protection
19+
20+
// CHECK: ignoring '[[OPT]]' option as it is not currently supported for target '[[ARCH]]{{.*}}' [-Woption-ignored]

0 commit comments

Comments
 (0)