File tree Expand file tree Collapse file tree 4 files changed +24
-1
lines changed Expand file tree Collapse file tree 4 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ set(CMAKE_CXX_STANDARD 14)
6
6
set (CMAKE_CXX_STANDARD_REQUIRED ON )
7
7
set (CMAKE_CXX_EXTENSIONS OFF )
8
8
option (SYCL_ENABLE_WERROR "Treat all warnings as errors in SYCL project" OFF )
9
+ option (SYCL_DISABLE_STL_ASSERTIONS "Disable assertions in STL containers" OFF )
9
10
option (SYCL_ADD_DEV_VERSION_POSTFIX "Adds -V postfix to version string" ON )
10
11
11
12
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /cmake/modules" )
@@ -248,6 +249,17 @@ function( add_common_options LIB_NAME)
248
249
endif ()
249
250
endfunction (add_common_options )
250
251
252
+
253
+ if (LLVM_ENABLE_ASSERTIONS AND NOT SYCL_DISABLE_STL_ASSERTIONS )
254
+ if (SYCL_USE_LIBCXX )
255
+ add_definitions (-D_LIBCPP_DEBUG=1 )
256
+ set (SYCL_CLANG_EXTRA_FLAGS "${SYCL_CLANG_EXTRA_FLAGS} -D_LIBCPP_DEBUG=1" )
257
+ else ()
258
+ add_definitions (-D_GLIBCXX_ASSERTIONS=1 )
259
+ set (SYCL_CLANG_EXTRA_FLAGS "${SYCL_CLANG_EXTRA_FLAGS} -D_GLIBCXX_ASSERTIONS=1" )
260
+ endif ()
261
+ endif ()
262
+
251
263
set (SYCL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
252
264
253
265
# SYCL runtime library
Original file line number Diff line number Diff line change @@ -19,10 +19,18 @@ macro(add_sycl_executable ARG_TARGET_NAME)
19
19
list (APPEND LINKED_LIBS "${LIB_PREFIX}${_lib}${LIB_POSTFIX} " )
20
20
endforeach ()
21
21
22
+ if (LLVM_ENABLE_ASSERTIONS AND NOT SYCL_DISABLE_STL_ASSERTIONS )
23
+ if (SYCL_USE_LIBCXX )
24
+ set (_SYCL_EXTRA_FLAGS -D_LIBCPP_DEBUG=1 )
25
+ else ()
26
+ set (_SYCL_EXTRA_FLAGS -D_GLIBCXX_ASSERTIONS=1 )
27
+ endif ()
28
+ endif ()
29
+
22
30
add_custom_target (${ARG_TARGET_NAME} _exec ALL
23
31
COMMAND ${DEVICE_COMPILER_EXECUTABLE} -fsycl ${ARG_SOURCES}
24
32
-o ${CMAKE_CURRENT_BINARY_DIR} /${ARG_TARGET_NAME}
25
- ${LINKED_LIBS} ${ARG_OPTIONS}
33
+ ${LINKED_LIBS} ${ARG_OPTIONS} ${_SYCL_EXTRA_FLAGS}
26
34
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR} /${ARG_TARGET_NAME}
27
35
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
28
36
COMMAND_EXPAND_LISTS )
Original file line number Diff line number Diff line change 43
43
config .available_features .add ('linux' )
44
44
llvm_config .with_system_environment ('LD_LIBRARY_PATH' )
45
45
llvm_config .with_environment ('LD_LIBRARY_PATH' , config .sycl_libs_dir , append_path = True )
46
+ llvm_config .with_system_environment ('CFLAGS' )
47
+ llvm_config .with_environment ('CFLAGS' , config .sycl_clang_extra_flags )
46
48
47
49
elif platform .system () == "Windows" :
48
50
config .available_features .add ('windows' )
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ config.cuda_toolkit_include = "@CUDA_TOOLKIT_INCLUDE@"
17
17
config.sycl_tools_src_dir = "@SYCL_TOOLS_SRC_DIR@"
18
18
config.llvm_build_lib_dir = "@LLVM_BUILD_LIBRARY_DIRS@"
19
19
config.llvm_build_bin_dir = "@LLVM_BUILD_BINARY_DIRS@"
20
+ config.sycl_clang_extra_flags = "@SYCL_CLANG_EXTRA_FLAGS@"
20
21
21
22
config.llvm_enable_projects = "@LLVM_ENABLE_PROJECTS@"
22
23
You can’t perform that action at this time.
0 commit comments