Skip to content

Commit 0a5e3d4

Browse files
mgornymahesh-attarde
authored andcommitted
[libclc] Fix installed symlinks to be relative again (llvm#149728)
Fix the symlink creation logic to use relative paths instead of absolute, in order to ensure that the installed symlinks actually refer to the installed .bc files rather than the ones from the build directory. This was broken in llvm#146833. The change is a bit roundabout but it attempts to preserve the spirit of llvm#146833, that is the ability to use multiple output directories (provided they all resides in `${LIBCLC_OUTPUT_LIBRARY_DIR}` and preserve the same structure in the installed tree). Signed-off-by: Michał Górny <[email protected]>
1 parent 9e610fd commit 0a5e3d4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,17 +425,21 @@ function(add_libclc_builtin_set)
425425
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
426426
endif()
427427

428-
if(CMAKE_HOST_UNIX OR LLVM_USE_SYMLINKS)
429-
set(LIBCLC_LINK_OR_COPY create_symlink)
430-
else()
431-
set(LIBCLC_LINK_OR_COPY copy)
432-
endif()
433-
434428
foreach( a IN LISTS ARG_ALIASES )
429+
if(CMAKE_HOST_UNIX OR LLVM_USE_SYMLINKS)
430+
cmake_path(RELATIVE_PATH libclc_builtins_lib
431+
BASE_DIRECTORY ${LIBCLC_OUTPUT_LIBRARY_DIR}
432+
OUTPUT_VARIABLE LIBCLC_LINK_OR_COPY_SOURCE)
433+
set(LIBCLC_LINK_OR_COPY create_symlink)
434+
else()
435+
set(LIBCLC_LINK_OR_COPY_SOURCE ${libclc_builtins_lib})
436+
set(LIBCLC_LINK_OR_COPY copy)
437+
endif()
438+
435439
set( alias_suffix "${a}-${ARG_TRIPLE}.bc" )
436440
add_custom_command(
437441
OUTPUT ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
438-
COMMAND ${CMAKE_COMMAND} -E ${LIBCLC_LINK_OR_COPY} ${libclc_builtins_lib} ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
442+
COMMAND ${CMAKE_COMMAND} -E ${LIBCLC_LINK_OR_COPY} ${LIBCLC_LINK_OR_COPY_SOURCE} ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
439443
DEPENDS prepare-${obj_suffix}
440444
)
441445
add_custom_target( alias-${alias_suffix} ALL

0 commit comments

Comments
 (0)