Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6473,17 +6473,21 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
}

if (IsSYCL) {
// Host-side SYCL compilation receives the integration header file as
// Inputs[1]. Include the header with -include
if (!IsSYCLOffloadDevice && SYCLDeviceInput) {
const char *IntHeaderPath =
Args.MakeArgString(SYCLDeviceInput->getFilename());
CmdArgs.push_back("-include");
CmdArgs.push_back(IntHeaderPath);
// When creating dependency information, filter out the generated
// header file.
CmdArgs.push_back("-dependency-filter");
CmdArgs.push_back(IntHeaderPath);
// Add any options that are needed specific to SYCL offload while
// performing the host side compilation.
if (!IsSYCLOffloadDevice) {
// Host-side SYCL compilation receives the integration header file as
// Inputs[1]. Include the header with -include
if (SYCLDeviceInput) {
const char *IntHeaderPath =
Args.MakeArgString(SYCLDeviceInput->getFilename());
CmdArgs.push_back("-include");
CmdArgs.push_back(IntHeaderPath);
// When creating dependency information, filter out the generated
// header file.
CmdArgs.push_back("-dependency-filter");
CmdArgs.push_back(IntHeaderPath);
}
// Let the FE know we are doing a SYCL offload compilation, but we are
// doing the host pass.
CmdArgs.push_back("-fsycl");
Expand Down
10 changes: 10 additions & 0 deletions clang/test/Driver/sycl-offload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@
// OFFLOAD-AVX-NEXT: clang{{.*}} "-cc1" {{.*}}
// OFFLOAD-AVX-NEXT-SAME: "-fsycl-is-host"
// OFFLOAD-AVX-NEXT-SAME: "-target-cpu" "[[HOST_CPU_NAME]]" "-target-feature" "+avx"

/// Check that the needed -fsycl -fsycl-is-device and -fsycl-is-host options
/// are passed to all of the needed compilation steps regardless of final
/// phase.
// RUN: %clang -### -fsycl -c %s 2>&1 | FileCheck -check-prefix=CHECK-OPTS %s
// RUN: %clang -### -fsycl -E %s 2>&1 | FileCheck -check-prefix=CHECK-OPTS %s
// RUN: %clang -### -fsycl -S %s 2>&1 | FileCheck -check-prefix=CHECK-OPTS %s
// RUN: %clang -### -fsycl %s 2>&1 | FileCheck -check-prefix=CHECK-OPTS %s
// CHECK-OPTS: clang{{.*}} "-cc1" {{.*}} "-fsycl" "-fsycl-is-device"
// CHECK-OPTS: clang{{.*}} "-cc1" {{.*}} "-fsycl" "-fsycl-is-host"