Skip to content

Commit 7814dca

Browse files
mgornytru
authored andcommitted
Revert "[libclc] Make library output directories explicit (#146833)"
This reverts commit 81e6552. This change caused libclc to start installing broken symlinks that contain absolute paths to the build directory rather than relative paths within the install directory.
1 parent b475893 commit 7814dca

File tree

2 files changed

+22
-35
lines changed

2 files changed

+22
-35
lines changed

libclc/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ else()
8484
endif()
8585
endif()
8686

87-
# Setup the paths where libclc runtimes should be stored.
88-
set( LIBCLC_OUTPUT_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
89-
9087
if( EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
9188
message( WARNING "Using custom LLVM tools to build libclc: "
9289
"${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR}, "

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ function(link_bc)
120120
endif()
121121

122122
add_custom_command(
123-
OUTPUT ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.bc
124-
COMMAND ${llvm-link_exe} ${link_flags} -o ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.bc ${LINK_INPUT_ARG}
123+
OUTPUT ${ARG_TARGET}.bc
124+
COMMAND ${llvm-link_exe} ${link_flags} -o ${ARG_TARGET}.bc ${LINK_INPUT_ARG}
125125
DEPENDS ${llvm-link_target} ${ARG_DEPENDENCIES} ${ARG_INPUTS} ${RSP_FILE}
126126
)
127127

128-
add_custom_target( ${ARG_TARGET} ALL DEPENDS ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.bc )
128+
add_custom_target( ${ARG_TARGET} ALL DEPENDS ${ARG_TARGET}.bc )
129129
set_target_properties( ${ARG_TARGET} PROPERTIES
130-
TARGET_FILE ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.bc
130+
TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.bc
131131
FOLDER "libclc/Device IR/Linking"
132132
)
133133
endfunction()
@@ -360,36 +360,33 @@ function(add_libclc_builtin_set)
360360
# llvm-spirv tool.
361361
if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
362362
set( obj_suffix ${ARG_ARCH_SUFFIX}.spv )
363-
set( libclc_builtins_lib ${LIBCLC_OUTPUT_LIBRARY_DIR}/${obj_suffix} )
364-
add_custom_command( OUTPUT ${libclc_builtins_lib}
365-
COMMAND ${llvm-spirv_exe} ${spvflags} -o ${libclc_builtins_lib} ${builtins_link_lib}
363+
add_custom_command( OUTPUT ${obj_suffix}
364+
COMMAND ${llvm-spirv_exe} ${spvflags} -o ${obj_suffix} ${builtins_link_lib}
366365
DEPENDS ${llvm-spirv_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
367366
)
368367
else()
369368
# Non-SPIR-V targets add an extra step to optimize the bytecode
370369
set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} )
371370

372-
add_custom_command( OUTPUT ${LIBCLC_ARCH_OBJFILE_DIR}/${builtins_opt_lib_tgt}.bc
373-
COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${LIBCLC_ARCH_OBJFILE_DIR}/${builtins_opt_lib_tgt}.bc
371+
add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc
372+
COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc
374373
${builtins_link_lib}
375374
DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
376375
)
377376
add_custom_target( ${builtins_opt_lib_tgt}
378-
ALL DEPENDS ${LIBCLC_ARCH_OBJFILE_DIR}/${builtins_opt_lib_tgt}.bc
377+
ALL DEPENDS ${builtins_opt_lib_tgt}.bc
379378
)
380379
set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES
381-
TARGET_FILE ${LIBCLC_ARCH_OBJFILE_DIR}/${builtins_opt_lib_tgt}.bc
380+
TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc
382381
FOLDER "libclc/Device IR/Opt"
383382
)
384383

385384
set( builtins_opt_lib $<TARGET_PROPERTY:${builtins_opt_lib_tgt},TARGET_FILE> )
386385

387386
set( obj_suffix ${ARG_ARCH_SUFFIX}.bc )
388-
set( libclc_builtins_lib ${LIBCLC_OUTPUT_LIBRARY_DIR}/${obj_suffix} )
389-
add_custom_command( OUTPUT ${libclc_builtins_lib}
390-
COMMAND ${prepare_builtins_exe} -o ${libclc_builtins_lib} ${builtins_opt_lib}
391-
DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target}
392-
)
387+
add_custom_command( OUTPUT ${obj_suffix}
388+
COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_opt_lib}
389+
DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target} )
393390
endif()
394391

395392
# Add a 'prepare' target
@@ -405,7 +402,7 @@ function(add_libclc_builtin_set)
405402
add_dependencies( prepare-${ARG_TRIPLE} prepare-${obj_suffix} )
406403

407404
install(
408-
FILES ${libclc_builtins_lib}
405+
FILES ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix}
409406
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
410407
)
411408

@@ -421,27 +418,20 @@ function(add_libclc_builtin_set)
421418
# * clspv targets don't include all OpenCL builtins
422419
if( NOT ARG_ARCH MATCHES "^(nvptx|clspv)(64)?$" )
423420
add_test( NAME external-calls-${obj_suffix}
424-
COMMAND ./check_external_calls.sh ${libclc_builtins_lib} ${LLVM_TOOLS_BINARY_DIR}
421+
COMMAND ./check_external_calls.sh ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} ${LLVM_TOOLS_BINARY_DIR}
425422
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
426423
endif()
427424

428425
foreach( a ${ARG_ALIASES} )
429426
set( alias_suffix "${a}-${ARG_TRIPLE}.bc" )
430427
add_custom_command(
431-
OUTPUT ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
432-
COMMAND ${CMAKE_COMMAND} -E create_symlink ${libclc_builtins_lib} ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
433-
DEPENDS prepare-${obj_suffix}
434-
)
435-
add_custom_target( alias-${alias_suffix} ALL
436-
DEPENDS ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
437-
)
438-
set_target_properties( alias-${alias_suffix}
439-
PROPERTIES FOLDER "libclc/Device IR/Aliases"
440-
)
441-
install(
442-
FILES ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
443-
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
444-
)
428+
OUTPUT ${alias_suffix}
429+
COMMAND ${CMAKE_COMMAND} -E create_symlink ${obj_suffix} ${alias_suffix}
430+
DEPENDS prepare-${obj_suffix} )
431+
add_custom_target( alias-${alias_suffix} ALL DEPENDS ${alias_suffix} )
432+
set_target_properties( alias-${alias_suffix} PROPERTIES FOLDER "libclc/Device IR/Aliases" )
433+
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${alias_suffix}
434+
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
445435
endforeach( a )
446436
endfunction(add_libclc_builtin_set)
447437

0 commit comments

Comments
 (0)