Skip to content

Commit 6642d84

Browse files
committed
[SYCL] Move SYCL headers from standard clang location
SYCL headers were moved from default clang include directory (lib/clang/11.0.0/include) to (include/sycl) to support mixed compilers (e.g. gcc for host code and clang for device code) during build of SYCL application. Clang driver adds new directory to system include search path. For non-clang compilers the user should add option below to compiler command line to let it find SYCL headers: -I <path_to_sycl_compiler>/include/sycl Additional diagnostic can be raised depending on compiler which is used (see examples for clang below). It can be ignored. /localdisk2/bbsycl/res/include/sycl/CL/__spirv/spirv_ops.hpp:74:8: error: SYCL 1.2.1 specification does not allow 'sycl_device' attribute applied to a function with a raw pointer parameter type [-Wsycl-strict] extern SYCL_EXTERNAL __ocl_event_t __spirv_GroupAsyncCopy( /localdisk2/bbsycl/res/include/sycl/CL/sycl/ordered_queue.hpp:267:37: warning: 'ordered_queue' is deprecated: Replaced by in_order queue property [-Wdeprecated-declarations] size_t operator()(const cl::sycl::ordered_queue &q) const { Signed-off-by: Vladimir Lazarev [email protected]
1 parent 0caff4d commit 6642d84

34 files changed

+51
-45
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,12 @@ SYCLToolChain::GetCXXStdlibType(const ArgList &Args) const {
532532

533533
void SYCLToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
534534
ArgStringList &CC1Args) const {
535+
SmallString<128> P(getDriver().getInstalledDir());
536+
llvm::sys::path::append(P, "..");
537+
llvm::sys::path::append(P, "include");
538+
llvm::sys::path::append(P, "sycl");
539+
CC1Args.push_back("-internal-isystem");
540+
CC1Args.push_back(DriverArgs.MakeArgString(P));
535541
HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
536542
}
537543

clang/test/Driver/sycl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// RUN: %clangxx -### %s 2>&1 | FileCheck %s --check-prefix=DISABLED
88

99
// ENABLED: "-cc1"{{.*}} "-fsycl-is-device"
10+
// ENABLED: "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"
1011
// DISABLED-NOT: "-fsycl-is-device"
1112

1213
// RUN: %clang -### -fsycl-device-only -c %s 2>&1 | FileCheck %s --check-prefix=DEFAULT

sycl/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ endif()
5454
# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX.
5555
set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}")
5656

57-
set(LLVM_INST_INC_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include")
58-
set(dst_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
59-
set(dst_deploy_dir ${CMAKE_INSTALL_PREFIX}/lib/clang/${CLANG_VERSION}/include)
57+
set(SYCL_INST_INC_DIRECTORY "include/sycl")
58+
set(dst_dir ${LLVM_BINARY_DIR}/${SYCL_INST_INC_DIRECTORY})
59+
set(dst_deploy_dir ${CMAKE_INSTALL_PREFIX}/${SYCL_INST_INC_DIRECTORY})
6060

6161
# Find OpenCL headers and libraries installed in the system and use them to
6262
# build SYCL runtime.
@@ -137,7 +137,7 @@ target_include_directories(OpenCL-Headers
137137
INTERFACE ${OPENCL_INCLUDE}
138138
)
139139
install(DIRECTORY ${OPENCL_INCLUDE}/CL
140-
DESTINATION ${LLVM_INST_INC_DIRECTORY}
140+
DESTINATION ${dst_deploy_dir}
141141
COMPONENT opencl-headers
142142
)
143143

@@ -159,7 +159,7 @@ COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/CL ${dst_dir}/CL
159159
COMMENT "Copying SYCL headers ...")
160160

161161
# Configure SYCL headers
162-
install(DIRECTORY "${sycl_inc_dir}/." DESTINATION "${LLVM_INST_INC_DIRECTORY}" COMPONENT sycl-headers)
162+
install(DIRECTORY "${sycl_inc_dir}/." DESTINATION ${dst_deploy_dir} COMPONENT sycl-headers)
163163

164164
set(SYCL_RT_LIBS sycl)
165165
if (MSVC)

sycl/test/basic_tests/buffer/buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: opencl
22

3-
// RUN: %clangxx %s -o %t1.out -lsycl
3+
// RUN: %clangxx %s -o %t1.out -lsycl -I %sycl_include
44
// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out
55
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t2.out
66
// RUN: env SYCL_DEVICE_TYPE=HOST %t2.out

sycl/test/basic_tests/buffer/buffer_ctad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s
1+
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33
//==------------------- buffer_ctad.cpp - SYCL buffer CTAD test ----------------==//
44
//

sycl/test/basic_tests/buffer/buffer_dev_to_dev.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/basic_tests/buffer/buffer_full_copy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %clangxx %s -o %t1.out -lsycl
1+
// RUN: %clangxx %s -o %t1.out -lsycl -I %sycl_include
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out
3-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t2.out
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t2.out
44
// RUN: env SYCL_DEVICE_TYPE=HOST %t2.out
55
// RUN: %CPU_RUN_PLACEHOLDER %t2.out
66
// RUN: %GPU_RUN_PLACEHOLDER %t2.out

sycl/test/basic_tests/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx %s -o %t.out -lsycl
1+
// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
33

44
//==--------------- context.cpp - SYCL context test ------------------------==//

sycl/test/basic_tests/device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx %s -o %t.out -lsycl
1+
// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
33

44
//==--------------- device.cpp - SYCL device test --------------------------==//

sycl/test/basic_tests/id_ctad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s
1+
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33
//==--------------- id_ctad.cpp - SYCL id CTAD test ----------------------==//
44
//

0 commit comments

Comments
 (0)