Skip to content

Commit d429243

Browse files
mdtoguchibader
authored andcommitted
[SYCL] -fsycl-device-only should override -fsycl
Use of -fsycl-device-only should only produce device code even in the presence of -fsycl. The default mode of 'dpcpp' is -fsycl so the override is necessary for -fsycl-device-only to work Signed-off-by: Michael D Toguchi <michael.d.toguchi@intel.com>
1 parent b4a0e50 commit d429243

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,11 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
718718
//
719719
// We need to generate a SYCL toolchain if the user specified targets with
720720
// the -fsycl-targets, -fsycl-add-targets or -fsycl-link-targets option.
721-
// If -fsycl is supplied without any of these we will assume SPIR-V
722-
bool HasValidSYCLRuntime = C.getInputArgs().hasFlag(options::OPT_fsycl,
723-
options::OPT_fno_sycl, false);
721+
// If -fsycl is supplied without any of these we will assume SPIR-V.
722+
// Use of -fsycl-device-only overrides -fsycl.
723+
bool HasValidSYCLRuntime = (C.getInputArgs().hasFlag(options::OPT_fsycl,
724+
options::OPT_fno_sycl, false) &&
725+
!C.getInputArgs().hasArg(options::OPT_sycl_device_only));
724726

725727
Arg *SYCLTargets =
726728
C.getInputArgs().getLastArg(options::OPT_fsycl_targets_EQ);

clang/test/Driver/sycl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %clang -### --sycl -c %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
22
// RUN: %clang -### --sycl %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
3+
// RUN: %clang -### -fsycl-device-only -fsycl %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
34
// RUN: %clang -### --sycl -fno-sycl-use-bitcode -c %s 2>&1 | FileCheck %s --check-prefix=NO-BITCODE
45
// RUN: %clang -### -target spir64-unknown-linux-sycldevice -c -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=TARGET
56
// RUN: %clang -### --sycl -c -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=COMBINED

0 commit comments

Comments
 (0)