Skip to content

Commit c08b568

Browse files
committed
Use of -fsycl-device-only will win against -fsyclbin
1 parent e3d48cc commit c08b568

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,8 +1204,8 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
12041204
// Use of -fsyclbin also enables SYCL offloading compialtion.
12051205
bool IsSYCL = C.getInputArgs().hasFlag(options::OPT_fsycl,
12061206
options::OPT_fno_sycl, false) ||
1207-
C.getInputArgs().hasArg(options::OPT_fsycl_device_only,
1208-
options::OPT_fsyclbin);
1207+
C.getInputArgs().hasArgNoClaim(options::OPT_fsycl_device_only,
1208+
options::OPT_fsyclbin);
12091209

12101210
auto argSYCLIncompatible = [&](OptSpecifier OptId) {
12111211
if (!IsSYCL)
@@ -3484,7 +3484,7 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
34843484
Arg *InputTypeArg = nullptr;
34853485
bool IsSYCL =
34863486
Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false) ||
3487-
Args.hasArg(options::OPT_fsycl_device_only, options::OPT_fsyclbin);
3487+
Args.hasArgNoClaim(options::OPT_fsycl_device_only, options::OPT_fsyclbin);
34883488

34893489
// The last /TC or /TP option sets the input type to C or C++ globally.
34903490
if (Arg *TCTP = Args.getLastArgNoClaim(options::OPT__SLASH_TC,

clang/test/Driver/fsyclbin.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
// RUN: | FileCheck %s --check-prefix=UNUSED
66
// UNUSED: warning: argument unused during compilation: '-fsyclbin'
77

8+
/// -fsyclbin -fsycl-device-only usage. -fsycl-device-only will 'win' and
9+
/// -fsyclbin is effectively ignored.
10+
// RUN: %clangxx -fsycl-device-only -fsyclbin --offload-new-driver %s -### 2>&1 \
11+
// RUN: | FileCheck %s --check-prefix=SYCLBIN_UNUSED
12+
// RUN: %clang_cl -fsycl-device-only -fsyclbin --offload-new-driver %s -### 2>&1 \
13+
// RUN: | FileCheck %s --check-prefix=SYCLBIN_UNUSED
14+
// SYCLBIN_UNUSED: warning: argument unused during compilation: '-fsyclbin'
15+
816
/// Check tool invocation contents.
917
// RUN: %clangxx -fsycl -fsyclbin --offload-new-driver %s -### 2>&1 \
1018
// RUN: | FileCheck %s --check-prefix=CHECK_TOOLS

0 commit comments

Comments
 (0)