Skip to content

Commit b7ef830

Browse files
authored
[SYCL] Provide a flexible way to compile a single devicelib with specified CFLAGS (#15870)
Add an new function in libdevice CMake to provide a way to pass arbitrary compiling flags when building a device library file. This is preparatory work to add AOT device asan library targeting for different GPU/CPU platforms. Signed-off-by: jinge90 <[email protected]>
1 parent eab2dfc commit b7ef830

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

libdevice/cmake/modules/SYCLLibdevice.cmake

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,29 @@ function(compile_lib filename)
112112
"FILETYPE"
113113
"SRC;EXTRA_OPTS;DEPENDENCIES"
114114
${ARGN})
115+
set(compile_opt_list ${compile_opts}
116+
${${ARG_FILETYPE}_device_compile_opts}
117+
${ARG_EXTRA_OPTS})
118+
compile_lib_ext(${filename}
119+
FILETYPE ${ARG_FILETYPE}
120+
SRC ${ARG_SRC}
121+
DEPENDENCIES ${ARG_DEPENDENCIES}
122+
OPTS ${compile_opt_list})
123+
endfunction()
124+
125+
function(compile_lib_ext filename)
126+
cmake_parse_arguments(ARG
127+
""
128+
"FILETYPE"
129+
"SRC;OPTS;DEPENDENCIES"
130+
${ARGN})
115131

116132
set(devicelib-file
117133
${${ARG_FILETYPE}_binary_dir}/${filename}.${${ARG_FILETYPE}-suffix})
118134

119135
add_custom_command(
120136
OUTPUT ${devicelib-file}
121-
COMMAND ${clang} ${compile_opts} ${ARG_EXTRA_OPTS}
137+
COMMAND ${clang} ${ARG_OPTS}
122138
${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SRC} -o ${devicelib-file}
123139
MAIN_DEPENDENCY ${ARG_SRC}
124140
DEPENDS ${ARG_DEPENDENCIES}

0 commit comments

Comments
 (0)