Skip to content

Commit 24d179c

Browse files
authored
[SYCL] Move sycl.hpp in install directory and adjust driver to match (#3523)
Default location in which the driver adds the header searches for sycl headers is 'include/sycl'. With the change to the location of sycl.hpp we also need to adjust (add) the 'include' location for default searches Also update tests to reflect being able to find the 'CL' dir with new %sycl_include setting
1 parent a1c2cbf commit 24d179c

File tree

9 files changed

+26
-14
lines changed

9 files changed

+26
-14
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -705,10 +705,14 @@ SYCLToolChain::GetCXXStdlibType(const ArgList &Args) const {
705705
void SYCLToolChain::AddSYCLIncludeArgs(const clang::driver::Driver &Driver,
706706
const ArgList &DriverArgs,
707707
ArgStringList &CC1Args) {
708+
// Add ../include/sycl and ../include (in that order)
708709
SmallString<128> P(Driver.getInstalledDir());
709710
llvm::sys::path::append(P, "..");
710711
llvm::sys::path::append(P, "include");
711-
llvm::sys::path::append(P, "sycl");
712+
SmallString<128> SYCLP(P);
713+
llvm::sys::path::append(SYCLP, "sycl");
714+
CC1Args.push_back("-internal-isystem");
715+
CC1Args.push_back(DriverArgs.MakeArgString(SYCLP));
712716
CC1Args.push_back("-internal-isystem");
713717
CC1Args.push_back(DriverArgs.MakeArgString(P));
714718
}

clang/test/Driver/sycl-device.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/// Check "-fsycl-is-device" is passed when compiling for device:
77
// RUN: %clang -### -fsycl-device-only %s 2>&1 \
88
// RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s
9-
// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"
9+
// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"
1010

1111
/// Check that "-Wno-sycl-strict" is set on compiler invocation with "-fsycl"
1212
/// or "-fsycl-device-only" or both:

clang/test/Driver/sycl-offload.c

+6
Original file line numberDiff line numberDiff line change
@@ -921,3 +921,9 @@
921921
// CHK-POST-LINK-OPT-LEVEL-O3: sycl-post-link{{.*}} "-O3"
922922
// CHK-POST-LINK-OPT-LEVEL-Os: sycl-post-link{{.*}} "-Os"
923923
// CHK-POST-LINK-OPT-LEVEL-Oz: sycl-post-link{{.*}} "-Oz"
924+
925+
// Verify header search dirs are added with -fsycl
926+
// RUN: %clang -### -fsycl %s 2>&1 | FileCheck %s -check-prefixes=CHECK-HEADER-DIR
927+
// RUN: %clang_cl -### -fsycl %s 2>&1 | FileCheck %s -check-prefixes=CHECK-HEADER-DIR
928+
// CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"
929+
// CHECK-HEADER-DIR: clang{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"{{.*}} "-fsycl-is-host"

sycl/CMakeLists.txt

+8-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ endif()
6767
# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX.
6868
set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}")
6969

70-
set(SYCL_INCLUDE_DIR "include/sycl")
70+
set(SYCL_INCLUDE_DIR "include")
7171
set(SYCL_INCLUDE_BUILD_DIR ${LLVM_BINARY_DIR}/${SYCL_INCLUDE_DIR})
7272
set(SYCL_INCLUDE_DEPLOY_DIR ${CMAKE_INSTALL_PREFIX}/${SYCL_INCLUDE_DIR})
7373

@@ -104,7 +104,7 @@ if( NOT OpenCL_INCLUDE_DIRS )
104104
UPDATE_DISCONNECTED ${SYCL_EP_OCL_HEADERS_SKIP_AUTO_UPDATE}
105105
SOURCE_DIR ${OpenCL_INCLUDE_DIRS}
106106
CONFIGURE_COMMAND ""
107-
BUILD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${OpenCL_INCLUDE_DIRS}/CL ${SYCL_INCLUDE_BUILD_DIR}/CL
107+
BUILD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${OpenCL_INCLUDE_DIRS}/CL ${SYCL_INCLUDE_BUILD_DIR}/sycl/CL
108108
INSTALL_COMMAND ""
109109
STEP_TARGETS build
110110
COMMENT "Downloading OpenCL headers."
@@ -116,7 +116,7 @@ if( NOT OpenCL_INCLUDE_DIRS )
116116
else()
117117
add_custom_target( ocl-headers ALL
118118
DEPENDS ${OpenCL_INCLUDE_DIRS}
119-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${OpenCL_INCLUDE_DIRS}/CL ${SYCL_INCLUDE_BUILD_DIR}/CL
119+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${OpenCL_INCLUDE_DIRS}/CL ${SYCL_INCLUDE_BUILD_DIR}/sycl/CL
120120
COMMENT "Copying OpenCL headers ..."
121121
)
122122
endif()
@@ -192,7 +192,7 @@ target_include_directories(OpenCL-Headers
192192
INTERFACE ${OPENCL_INCLUDE}
193193
)
194194
install(DIRECTORY ${OPENCL_INCLUDE}/CL
195-
DESTINATION ${SYCL_INCLUDE_DEPLOY_DIR}
195+
DESTINATION ${SYCL_INCLUDE_DEPLOY_DIR}/sycl
196196
COMPONENT opencl-headers
197197
)
198198

@@ -209,11 +209,13 @@ configure_file("${version_header}.in" "${version_header}")
209209

210210
# Copy SYCL headers
211211
add_custom_target(sycl-headers ALL
212-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir} ${SYCL_INCLUDE_BUILD_DIR}
212+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/sycl ${SYCL_INCLUDE_BUILD_DIR}/sycl
213+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/CL ${SYCL_INCLUDE_BUILD_DIR}/sycl/CL
213214
COMMENT "Copying SYCL headers ...")
214215

215216
# Configure SYCL headers
216-
install(DIRECTORY "${sycl_inc_dir}/." DESTINATION ${SYCL_INCLUDE_DEPLOY_DIR} COMPONENT sycl-headers)
217+
install(DIRECTORY "${sycl_inc_dir}/sycl" DESTINATION ${SYCL_INCLUDE_DEPLOY_DIR} COMPONENT sycl-headers)
218+
install(DIRECTORY "${sycl_inc_dir}/CL" DESTINATION ${SYCL_INCLUDE_DEPLOY_DIR}/sycl COMPONENT sycl-headers)
217219

218220
set(SYCL_RT_LIBS sycl)
219221
if (MSVC)

sycl/test/basic_tests/image_accessor_types.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not %clangxx -fsyntax-only %s -I %sycl_include 2>&1 | FileCheck %s
1+
// RUN: not %clangxx -fsyntax-only %s -I %sycl_include/sycl 2>&1 | FileCheck %s
22
#include <CL/sycl.hpp>
33
#include <iostream>
44

sycl/test/basic_tests/vectors/ctad_fail.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected
1+
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include/sycl -Xclang -verify-ignore-unexpected
22
//==--------------- ctad.cpp - SYCL vector CTAD fail test ------------------==//
33
//
44
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

sycl/test/gdb/accessors.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -c -fno-color-diagnostics -I %sycl_include -Xclang -ast-dump %s | FileCheck %s
1+
// RUN: %clangxx -c -fno-color-diagnostics -I %sycl_include/sycl -Xclang -ast-dump %s | FileCheck %s
22
// UNSUPPORTED: windows
33
#include <CL/sycl/accessor.hpp>
44

sycl/test/gdb/printers.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -c -fno-color-diagnostics -I %sycl_include -Xclang -ast-dump %s | FileCheck %s
1+
// RUN: %clangxx -c -fno-color-diagnostics -I %sycl_include/sycl -Xclang -ast-dump %s | FileCheck %s
22
// UNSUPPORTED: windows
33
#include <CL/sycl/buffer.hpp>
44
#include <CL/sycl/detail/array.hpp>

sycl/test/separate-compile/test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
// >> host compilation...
88
// Driver automatically adds -D_DLL and -D_MT on Windows with -fsycl.
99
// Add those defines required for Windows and harmless for Linux.
10-
// RUN: %clangxx -D_DLL -D_MT -include sycl_ihdr_a.h -g -c %s -o a.o -I %sycl_include -Wno-sycl-strict
10+
// RUN: %clangxx -D_DLL -D_MT -include sycl_ihdr_a.h -g -c %s -o a.o -I %sycl_include/sycl -Wno-sycl-strict
1111
//
1212
// >> ---- compile src2
1313
// >> device compilation...
1414
// RUN: %clangxx -DB_CPP=1 -fsycl-device-only -Xclang -fsycl-int-header=sycl_ihdr_b.h %s -c -o b_kernel.bc -Wno-sycl-strict
1515
// >> host compilation...
16-
// RUN: %clangxx -DB_CPP=1 -D_DLL -D_MT -include sycl_ihdr_b.h -g -c %s -o b.o -I %sycl_include -Wno-sycl-strict
16+
// RUN: %clangxx -DB_CPP=1 -D_DLL -D_MT -include sycl_ihdr_b.h -g -c %s -o b.o -I %sycl_include/sycl -Wno-sycl-strict
1717
//
1818
// >> ---- bundle .o with .spv
1919
// >> run bundler

0 commit comments

Comments
 (0)