Skip to content

Commit 5ea7935

Browse files
wenju-heIanWood1
authored andcommitted
[libclc] only check filename part of the source for avoiding duplication (llvm#135710)
llvm-diff shows this PR has no changes to amdgcn--amdhsa.bc. Motivation is that in our downstream the same category of target built-ins, e.g. math, are organized in several different folders. For example, in target SOURCES we have math-common/cos.cl, while in generic SOURCES it is math/cos.cl. Based on current check rule that compares both folder name and base filename, target math-common/cos.cl won't override math/cos.cl when collecting source files from SOURCES files in cmake function libclc_configure_lib_source. With this PR, we allow folder name to be different in the process. A notable change of this PR is that two entries in SOURCES with the same base filename must not implements the same built-in.
1 parent b3f2948 commit 5ea7935

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,16 +466,22 @@ function(libclc_configure_lib_source LIB_FILE_LIST)
466466
## Add the generated convert files here to prevent adding the ones listed in
467467
## SOURCES
468468
set( rel_files ${${LIB_FILE_LIST}} ) # Source directory input files, relative to the root dir
469-
set( objects ${${LIB_FILE_LIST}} ) # A "set" of already-added input files
469+
# A "set" of already-added input files
470+
set( objects )
471+
foreach( f ${${LIB_FILE_LIST}} )
472+
get_filename_component( name ${f} NAME )
473+
list( APPEND objects ${name} )
474+
endforeach()
470475

471476
foreach( l ${source_list} )
472477
file( READ ${l} file_list )
473478
string( REPLACE "\n" ";" file_list ${file_list} )
474479
get_filename_component( dir ${l} DIRECTORY )
475480
foreach( f ${file_list} )
481+
get_filename_component( name ${f} NAME )
476482
# Only add each file once, so that targets can 'specialize' builtins
477-
if( NOT ${f} IN_LIST objects )
478-
list( APPEND objects ${f} )
483+
if( NOT ${name} IN_LIST objects )
484+
list( APPEND objects ${name} )
479485
list( APPEND rel_files ${dir}/${f} )
480486
endif()
481487
endforeach()

0 commit comments

Comments
 (0)