Skip to content

Commit 2869ca7

Browse files
authored
[LIBCLC] Improve CMake dependency tracking (#5019)
This is (hopefully) resolving an issue where after changing the implementation of some built-ins in libclc the changes wouldn't get picked up correctly by CMake and the old implementation would still be used and a clean build would be required. As far as I can tell what was happening is that CMake would properly rebuild up until the `opt` stage but wouldn't do the `prepare_builtins` or `remangle` stages, leaving the old bitcode for these, and that is the libraries that are used by clang. The problem seems to be with how the dependencies are specified between these two, dependencies between custom commands and custom targets are really tricky with CMake and it seems like the way it was setup didn't work. The most reliable way of connecting multiple custom commands, especially in the same file like here, is to just use the `OUTPUT` argument of the previous custom command as a `DEPENDS` in the next one. So I've updated these two stages to work like that, and now as far as I can tell the dependencies are picked up properly.
1 parent a9068d9 commit 2869ca7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ macro(add_libclc_builtin_set arch_suffix)
9191
COMMAND prepare_builtins -o
9292
"${builtins_obj_path}"
9393
"$<TARGET_PROPERTY:opt.${obj_suffix},TARGET_FILE>"
94-
DEPENDS "opt.${obj_suffix}"
94+
DEPENDS "${builtins_opt_path}"
9595
prepare_builtins )
9696
add_custom_target( "prepare-${obj_suffix}" ALL
9797
DEPENDS "${builtins_obj_path}" )
@@ -122,7 +122,7 @@ macro(add_libclc_builtin_set arch_suffix)
122122
--long-width=${long_width}
123123
--char-signedness=${signedness}
124124
"$<TARGET_PROPERTY:prepare-${obj_suffix},TARGET_FILE>"
125-
DEPENDS "prepare-${obj_suffix}" libclc-remangler )
125+
DEPENDS "${builtins_obj_path}" libclc-remangler )
126126
add_custom_target( "remangled-${long_width}-${signedness}_char.${obj_suffix}" ALL
127127
DEPENDS "${builtins_remangle_path}" )
128128
set_target_properties("remangled-${long_width}-${signedness}_char.${obj_suffix}"

0 commit comments

Comments
 (0)