Skip to content

Commit 9397cbc

Browse files
authored
[Driver][SYCL] Update diagnostic behavior for -fsanitize with -fsycl (#6292)
When using -fsanitize for spir64 targets, the driver would error out not allowing for compilation to move forward. -fsanitize is currently not supported for spir64 targets, but it is supported for host. Restrict the -fsanitize option to only be used for the Host compilation but also emit a diagnostic that -fsanitize is being ignored for the target compilation.
1 parent 6db064a commit 9397cbc

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,12 @@ SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
622622
// Lookup binaries into the driver directory, this is used to
623623
// discover the clang-offload-bundler executable.
624624
getProgramPaths().push_back(getDriver().Dir);
625+
626+
// Diagnose unsupported options only once.
627+
// All sanitizer options are not currently supported.
628+
for (auto A : Args.filtered(options::OPT_fsanitize_EQ))
629+
D.getDiags().Report(clang::diag::warn_drv_unsupported_option_for_target)
630+
<< A->getAsString(Args) << getTriple().str();
625631
}
626632

627633
void SYCLToolChain::addClangTargetOptions(
@@ -643,6 +649,8 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
643649
// Filter out any options we do not want to pass along to the device
644650
// compilation.
645651
switch ((options::ID)A->getOption().getID()) {
652+
case options::OPT_fsanitize_EQ:
653+
break;
646654
default:
647655
DAL->append(A);
648656
break;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// Diagnose unsupported options specific to SYCL compilations
2+
// RUN: %clangxx -fsycl -fsanitize=address -### %s 2>&1 \
3+
// RUN: | FileCheck %s --check-prefix=SANITIZE -DARCH=spir64
4+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen -fsanitize=address -### %s 2>&1 \
5+
// RUN: | FileCheck %s --check-prefix=SANITIZE -DARCH=spir64_gen
6+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_fpga -fsanitize=address -### %s 2>&1 \
7+
// RUN: | FileCheck %s --check-prefix=SANITIZE -DARCH=spir64_fpga
8+
// 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]

0 commit comments

Comments
 (0)