Skip to content

Commit 6c8cc47

Browse files
author
aidan.belton
committed
Partly undo CMake changes based on feedback
1 parent 2826576 commit 6c8cc47

File tree

5 files changed

+77
-34
lines changed

5 files changed

+77
-34
lines changed

sycl/plugins/CMakeLists.txt

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,3 @@ if (NOT MSVC)
2222
add_subdirectory(esimd_cpu)
2323
endif()
2424
endif()
25-
26-
set( SYCL_PLUGIN_TARGETS
27-
pi_opencl
28-
pi_level_zero)
29-
30-
if(SYCL_BUILD_PI_ESIMD_CPU)
31-
list(APPEND SYCL_PLUGIN_TARGETS pi_esimd_cpu)
32-
endif()
33-
34-
if(SYCL_BUILD_PI_CUDA)
35-
list(APPEND SYCL_PLUGIN_TARGETS pi_cuda)
36-
endif()
37-
38-
foreach(pi_plugin ${SYCL_PLUGIN_TARGETS})
39-
if (MSVC)
40-
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
41-
# which are individually tagged for all pi* symbols in pi.h
42-
target_compile_definitions(${pi_plugin} PRIVATE __SYCL_BUILD_SYCL_DLL)
43-
else()
44-
# we set the visibility of all symbols 'hidden' by default.
45-
# In pi.h file, we set exported symbols with visibility==default individually
46-
target_compile_options(${pi_plugin} PUBLIC -fvisibility=hidden)
47-
48-
# This script file is used to allow exporting pi* symbols only.
49-
# All other symbols are regarded as local (hidden)
50-
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
51-
52-
# Filter symbols based on the scope defined in the script file,
53-
# and export pi* function symbols in the library.
54-
target_link_libraries(${pi_plugin} PRIVATE "-Wl,--version-script=${linker_script}")
55-
endif()
56-
57-
endforeach()
58-

sycl/plugins/cuda/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ target_link_libraries(pi_cuda
4545
cudadrv
4646
)
4747

48+
if (MSVC)
49+
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
50+
# which are individually tagged for all pi* symbols in pi.h
51+
target_compile_definitions(pi_cuda PRIVATE __SYCL_BUILD_SYCL_DLL)
52+
else()
53+
# we set the visibility of all symbols 'hidden' by default.
54+
# In pi.h file, we set exported symbols with visibility==default individually
55+
target_compile_options(pi_cuda PUBLIC -fvisibility=hidden)
56+
57+
# This script file is used to allow exporting pi* symbols only.
58+
# All other symbols are regarded as local (hidden)
59+
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
60+
61+
# Filter symbols based on the scope defined in the script file,
62+
# and export pi* function symbols in the library.
63+
target_link_libraries(pi_cuda PRIVATE "-Wl,--version-script=${linker_script}")
64+
endif()
65+
4866
add_common_options(pi_cuda)
4967

5068
install(TARGETS pi_cuda

sycl/plugins/esimd_cpu/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,26 @@ add_library(pi_esimd_cpu SHARED
101101
"pi_esimd_cpu.cpp"
102102
)
103103

104+
if (MSVC)
105+
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
106+
# which are individually tagged for all pi* symbols in pi.h
107+
target_compile_definitions(pi_esimd_cpu PRIVATE __SYCL_BUILD_SYCL_DLL)
108+
else()
109+
# we set the visibility of all symbols 'hidden' by default.
110+
# In pi.h file, we set exported symbols with visibility==default individually
111+
target_compile_options(pi_esimd_cpu PUBLIC -fvisibility=hidden)
112+
113+
# This script file is used to allow exporting pi* symbols only.
114+
# All other symbols are regarded as local (hidden)
115+
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
116+
117+
# Filter symbols based on the scope defined in the script file,
118+
# and export pi* function symbols in the library.
119+
target_link_libraries( pi_esimd_cpu
120+
PRIVATE "-Wl,--version-script=${linker_script}"
121+
)
122+
endif()
123+
104124
add_dependencies(pi_esimd_cpu OpenCL-Headers)
105125
add_dependencies(pi_esimd_cpu cm-emu)
106126
add_dependencies(sycl-toolchain pi_esimd_cpu)

sycl/plugins/level_zero/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,26 @@ add_library(pi_level_zero SHARED
110110
"${CMAKE_CURRENT_SOURCE_DIR}/usm_allocator.hpp"
111111
)
112112

113+
if (MSVC)
114+
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
115+
# which are individually tagged for all pi* symbols in pi.h
116+
target_compile_definitions(pi_level_zero PRIVATE __SYCL_BUILD_SYCL_DLL)
117+
else()
118+
# we set the visibility of all symbols 'hidden' by default.
119+
# In pi.h file, we set exported symbols with visibility==default individually
120+
target_compile_options(pi_level_zero PUBLIC -fvisibility=hidden)
121+
122+
# This script file is used to allow exporting pi* symbols only.
123+
# All other symbols are regarded as local (hidden)
124+
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
125+
126+
# Filter symbols based on the scope defined in the script file,
127+
# and export pi* function symbols in the library.
128+
target_link_libraries( pi_level_zero
129+
PRIVATE "-Wl,--version-script=${linker_script}"
130+
)
131+
endif()
132+
113133
if (TARGET level-zero-loader)
114134
add_dependencies(pi_level_zero level-zero-loader)
115135
endif()

sycl/plugins/opencl/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ target_link_libraries(pi_opencl
2828
OpenCL-Headers
2929
OpenCL-ICD
3030
)
31+
if (MSVC)
32+
# by defining __SYCL_BUILD_SYCL_DLL, we can use __declspec(dllexport)
33+
# which are individually tagged for all pi* symbols in pi.h
34+
target_compile_definitions(pi_opencl PRIVATE __SYCL_BUILD_SYCL_DLL)
35+
else()
36+
# we set the visibility of all symbols 'hidden' by default.
37+
# In pi.h file, we set exported symbols with visibility==default individually
38+
target_compile_options(pi_opencl PUBLIC -fvisibility=hidden)
39+
40+
# This script file is used to allow exporting pi* symbols only.
41+
# All other symbols are regarded as local (hidden)
42+
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/../ld-version-script.txt")
43+
44+
# Filter symbols based on the scope defined in the script file,
45+
# and export pi* function symbols in the library.
46+
target_link_libraries( pi_opencl
47+
PRIVATE "-Wl,--version-script=${linker_script}"
48+
)
49+
endif()
3150

3251
add_common_options(pi_opencl)
3352

0 commit comments

Comments
 (0)