Skip to content

[libclc] Fix dependencies on generated convert builtins #127515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,30 +243,30 @@ add_custom_command(
OUTPUT convert.cl
COMMAND ${Python3_EXECUTABLE} ${script_loc} > convert.cl
DEPENDS ${script_loc} )
add_custom_target( "generate_convert.cl" DEPENDS convert.cl )
set_target_properties( "generate_convert.cl" PROPERTIES FOLDER "libclc/Sourcegenning" )
add_custom_target( generate-convert.cl DEPENDS convert.cl )
set_target_properties( generate-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" )

add_custom_command(
OUTPUT clc-convert.cl
COMMAND ${Python3_EXECUTABLE} ${script_loc} --clc > clc-convert.cl
DEPENDS ${script_loc} )
add_custom_target( "clc-generate_convert.cl" DEPENDS clc-convert.cl )
set_target_properties( "clc-generate_convert.cl" PROPERTIES FOLDER "libclc/Sourcegenning" )
add_custom_target( generate-clc-convert.cl DEPENDS clc-convert.cl )
set_target_properties( generate-clc-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" )

if ( clspv-- IN_LIST LIBCLC_TARGETS_TO_BUILD OR clspv64-- IN_LIST LIBCLC_TARGETS_TO_BUILD )
add_custom_command(
OUTPUT clspv-convert.cl
COMMAND ${Python3_EXECUTABLE} ${script_loc} --clspv > clspv-convert.cl
DEPENDS ${script_loc} )
add_custom_target( "clspv-generate_convert.cl" DEPENDS clspv-convert.cl )
set_target_properties( "clspv-generate_convert.cl" PROPERTIES FOLDER "libclc/Sourcegenning" )
add_custom_target( generate-clspv-convert.cl DEPENDS clspv-convert.cl )
set_target_properties( generate-clspv-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" )

add_custom_command(
OUTPUT clc-clspv-convert.cl
COMMAND ${Python3_EXECUTABLE} ${script_loc} --clc --clspv > clc-clspv-convert.cl
DEPENDS ${script_loc} )
add_custom_target( "clc-clspv-generate_convert.cl" DEPENDS clc-clspv-convert.cl )
set_target_properties( "clc-clspv-generate_convert.cl" PROPERTIES FOLDER "libclc/Sourcegenning" )
add_custom_target( generate-clc-clspv-convert.cl DEPENDS clc-clspv-convert.cl )
set_target_properties( generate-clc-clspv-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" )
endif()

enable_testing()
Expand Down Expand Up @@ -324,9 +324,11 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
if( NOT ARCH STREQUAL spirv AND NOT ARCH STREQUAL spirv64 )
if( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
list( APPEND opencl_gen_files clspv-convert.cl )
elseif ( NOT ENABLE_RUNTIME_SUBNORMAL )
else()
list( APPEND opencl_gen_files convert.cl )
list( APPEND opencl_lib_files generic/lib/subnormal_use_default.ll )
if ( NOT ENABLE_RUNTIME_SUBNORMAL )
list( APPEND opencl_lib_files generic/lib/subnormal_use_default.ll )
endif()
endif()
endif()

Expand Down
14 changes: 7 additions & 7 deletions libclc/cmake/modules/AddLibclc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,17 @@ function(add_libclc_builtin_set)
# We need to take each file and produce an absolute input file, as well
# as a unique architecture-specific output file. We deal with a mix of
# different input files, which makes this trickier.
set( input_file_dep )
if( ${file} IN_LIST ARG_GEN_FILES )
# Generated files are given just as file names, which we must make
# absolute to the binary directory.
set( input_file ${CMAKE_CURRENT_BINARY_DIR}/${file} )
set( output_file "${LIBCLC_ARCH_OBJFILE_DIR}/${file}.bc" )
# If a target exists that generates this file, add that as a dependency
# of the custom command.
if( TARGET generate-${file} )
set( input_file_dep generate-${file} )
endif()
else()
# Other files are originally relative to each SOURCE file, which are
# then make relative to the libclc root directory. We must normalize
Expand All @@ -249,19 +255,13 @@ function(add_libclc_builtin_set)

get_filename_component( file_dir ${file} DIRECTORY )

if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
set(CONVERT_DEP clspv-generate_convert.cl)
else()
set(CONVERT_DEP generate_convert.cl)
endif()

compile_to_bc(
TRIPLE ${ARG_TRIPLE}
INPUT ${input_file}
OUTPUT ${output_file}
EXTRA_OPTS -fno-builtin -nostdlib
"${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir}
DEPENDENCIES ${CONVERT_DEP}
DEPENDENCIES ${input_file_dep}
)
list( APPEND bytecode_files ${output_file} )
endforeach()
Expand Down