Skip to content

Commit e6972f7

Browse files
committed
Allow for -fsyclbin to imply -fsycl enabling behaviors
1 parent 8d2820d commit e6972f7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,9 +1201,11 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
12011201
// We need to generate a SYCL toolchain if the user specified -fsycl.
12021202
// If -fsycl is supplied without any of these we will assume SPIR-V.
12031203
// Use of -fsycl-device-only overrides -fsycl.
1204+
// Use of -fsyclbin also enables SYCL offloading compialtion.
12041205
bool IsSYCL = C.getInputArgs().hasFlag(options::OPT_fsycl,
12051206
options::OPT_fno_sycl, false) ||
1206-
C.getInputArgs().hasArg(options::OPT_fsycl_device_only);
1207+
C.getInputArgs().hasArg(options::OPT_fsycl_device_only,
1208+
options::OPT_fsyclbin);
12071209

12081210
auto argSYCLIncompatible = [&](OptSpecifier OptId) {
12091211
if (!IsSYCL)
@@ -3482,7 +3484,7 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
34823484
Arg *InputTypeArg = nullptr;
34833485
bool IsSYCL =
34843486
Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false) ||
3485-
Args.hasArg(options::OPT_fsycl_device_only);
3487+
Args.hasArg(options::OPT_fsycl_device_only, options::OPT_fsyclbin);
34863488

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

clang/test/Driver/fsyclbin.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
/// Check tool invocation contents.
99
// RUN: %clangxx -fsycl -fsyclbin --offload-new-driver %s -### 2>&1 \
1010
// RUN: | FileCheck %s --check-prefix=CHECK_TOOLS
11+
// RUN: %clangxx -fsyclbin --offload-new-driver %s -### 2>&1 \
12+
// RUN: | FileCheck %s --check-prefix=CHECK_TOOLS
1113
// RUN: %clang_cl -fsycl -fsyclbin --offload-new-driver %s -### 2>&1 \
1214
// RUN: | FileCheck %s --check-prefix=CHECK_TOOLS
1315
// CHECK_TOOLS: clang-offload-packager
@@ -20,6 +22,9 @@
2022
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl -fsyclbin \
2123
// RUN: --offload-new-driver %s -ccc-print-phases 2>&1 \
2224
// RUN: | FileCheck %s --check-prefix=CHECK_PHASES
25+
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsyclbin \
26+
// RUN: --offload-new-driver %s -ccc-print-phases 2>&1 \
27+
// RUN: | FileCheck %s --check-prefix=CHECK_PHASES
2328
// CHECK_PHASES: 0: input, "{{.*}}", c++, (device-sycl)
2429
// CHECK_PHASES: 1: preprocessor, {0}, c++-cpp-output, (device-sycl)
2530
// CHECK_PHASES: 2: compiler, {1}, ir, (device-sycl)

0 commit comments

Comments
 (0)