@@ -120,14 +120,14 @@ function(link_bc)
120
120
endif ()
121
121
122
122
add_custom_command (
123
- OUTPUT ${ARG_TARGET} .bc
124
- COMMAND ${llvm-link_exe} ${link_flags} -o ${ARG_TARGET} .bc ${LINK_INPUT_ARG}
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}
125
125
DEPENDS ${llvm-link_target} ${ARG_DEPENDENCIES} ${ARG_INPUTS} ${RSP_FILE}
126
126
)
127
127
128
- add_custom_target ( ${ARG_TARGET} ALL DEPENDS ${ARG_TARGET} .bc )
128
+ add_custom_target ( ${ARG_TARGET} ALL DEPENDS ${LIBCLC_ARCH_OBJFILE_DIR} /${ ARG_TARGET}.bc )
129
129
set_target_properties ( ${ARG_TARGET} PROPERTIES
130
- TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR } /${ARG_TARGET}.bc
130
+ TARGET_FILE ${LIBCLC_ARCH_OBJFILE_DIR } /${ARG_TARGET}.bc
131
131
FOLDER "libclc/Device IR/Linking"
132
132
)
133
133
endfunction ()
@@ -360,33 +360,36 @@ function(add_libclc_builtin_set)
360
360
# llvm-spirv tool.
361
361
if ( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
362
362
set ( obj_suffix ${ARG_ARCH_SUFFIX} .spv )
363
- add_custom_command ( OUTPUT ${obj_suffix}
364
- COMMAND ${llvm-spirv_exe} ${spvflags} -o ${obj_suffix} ${builtins_link_lib}
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}
365
366
DEPENDS ${llvm-spirv_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
366
367
)
367
368
else ()
368
369
# Non-SPIR-V targets add an extra step to optimize the bytecode
369
370
set ( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} )
370
371
371
- add_custom_command ( OUTPUT ${builtins_opt_lib_tgt} .bc
372
- COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt} .bc
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
373
374
${builtins_link_lib}
374
375
DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
375
376
)
376
377
add_custom_target ( ${builtins_opt_lib_tgt}
377
- ALL DEPENDS ${builtins_opt_lib_tgt} .bc
378
+ ALL DEPENDS ${LIBCLC_ARCH_OBJFILE_DIR} /${ builtins_opt_lib_tgt}.bc
378
379
)
379
380
set_target_properties ( ${builtins_opt_lib_tgt} PROPERTIES
380
- TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR } /${builtins_opt_lib_tgt}.bc
381
+ TARGET_FILE ${LIBCLC_ARCH_OBJFILE_DIR } /${builtins_opt_lib_tgt}.bc
381
382
FOLDER "libclc/Device IR/Opt"
382
383
)
383
384
384
385
set ( builtins_opt_lib $< TARGET_PROPERTY:${builtins_opt_lib_tgt} ,TARGET_FILE> )
385
386
386
387
set ( obj_suffix ${ARG_ARCH_SUFFIX} .bc )
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} )
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
+ )
390
393
endif ()
391
394
392
395
# Add a 'prepare' target
@@ -402,7 +405,7 @@ function(add_libclc_builtin_set)
402
405
add_dependencies ( prepare-${ARG_TRIPLE} prepare-${obj_suffix} )
403
406
404
407
install (
405
- FILES ${CMAKE_CURRENT_BINARY_DIR} /${obj_suffix }
408
+ FILES ${libclc_builtins_lib }
406
409
DESTINATION "${CMAKE_INSTALL_DATADIR} /clc"
407
410
)
408
411
@@ -418,20 +421,27 @@ function(add_libclc_builtin_set)
418
421
# * clspv targets don't include all OpenCL builtins
419
422
if ( NOT ARG_ARCH MATCHES "^(nvptx|clspv)(64)?$" )
420
423
add_test ( NAME external-calls-${obj_suffix}
421
- COMMAND ./check_external_calls.sh ${CMAKE_CURRENT_BINARY_DIR} /${obj_suffix } ${LLVM_TOOLS_BINARY_DIR}
424
+ COMMAND ./check_external_calls.sh ${libclc_builtins_lib } ${LLVM_TOOLS_BINARY_DIR}
422
425
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
423
426
endif ()
424
427
425
428
foreach ( a ${ARG_ALIASES} )
426
429
set ( alias_suffix "${a} -${ARG_TRIPLE} .bc" )
427
430
add_custom_command (
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" )
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
+ )
435
445
endforeach ( a )
436
446
endfunction (add_libclc_builtin_set )
437
447
0 commit comments