@@ -120,14 +120,15 @@ 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
+ WORKING_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR}
126
127
)
127
128
128
- add_custom_target ( ${ARG_TARGET} ALL DEPENDS ${ARG_TARGET} .bc )
129
+ add_custom_target ( ${ARG_TARGET} ALL DEPENDS ${LIBCLC_ARCH_OBJFILE_DIR} /${ ARG_TARGET}.bc )
129
130
set_target_properties ( ${ARG_TARGET} PROPERTIES
130
- TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR } /${ARG_TARGET}.bc
131
+ TARGET_FILE ${LIBCLC_ARCH_OBJFILE_DIR } /${ARG_TARGET}.bc
131
132
FOLDER "libclc/Device IR/Linking"
132
133
)
133
134
endfunction ()
@@ -360,33 +361,39 @@ function(add_libclc_builtin_set)
360
361
# llvm-spirv tool.
361
362
if ( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
362
363
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}
364
+ set ( libclc_builtins_lib ${LIBCLC_OUTPUT_LIBRARY_DIR} /${obj_suffix} )
365
+ add_custom_command ( OUTPUT ${libclc_builtins_lib}
366
+ COMMAND ${llvm-spirv_exe} ${spvflags} -o ${libclc_builtins_lib} ${builtins_link_lib}
365
367
DEPENDS ${llvm-spirv_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
368
+ WORKING_DIRECTORY ${LIBCLC_OUTPUT_LIBRARY_DIR}
366
369
)
367
370
else ()
368
371
# Non-SPIR-V targets add an extra step to optimize the bytecode
369
372
set ( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} )
370
373
371
- add_custom_command ( OUTPUT ${builtins_opt_lib_tgt} .bc
372
- COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt} .bc
374
+ add_custom_command ( OUTPUT ${LIBCLC_ARCH_OBJFILE_DIR} /${ builtins_opt_lib_tgt}.bc
375
+ COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${LIBCLC_ARCH_OBJFILE_DIR} /${ builtins_opt_lib_tgt}.bc
373
376
${builtins_link_lib}
374
377
DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
378
+ WORKING_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR}
375
379
)
376
380
add_custom_target ( ${builtins_opt_lib_tgt}
377
- ALL DEPENDS ${builtins_opt_lib_tgt} .bc
381
+ ALL DEPENDS ${LIBCLC_ARCH_OBJFILE_DIR} /${ builtins_opt_lib_tgt}.bc
378
382
)
379
383
set_target_properties ( ${builtins_opt_lib_tgt} PROPERTIES
380
- TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR } /${builtins_opt_lib_tgt}.bc
384
+ TARGET_FILE ${LIBCLC_ARCH_OBJFILE_DIR } /${builtins_opt_lib_tgt}.bc
381
385
FOLDER "libclc/Device IR/Opt"
382
386
)
383
387
384
388
set ( builtins_opt_lib $< TARGET_PROPERTY:${builtins_opt_lib_tgt} ,TARGET_FILE> )
385
389
386
390
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} )
391
+ set ( libclc_builtins_lib ${LIBCLC_OUTPUT_LIBRARY_DIR} /${obj_suffix} )
392
+ add_custom_command ( OUTPUT ${libclc_builtins_lib}
393
+ COMMAND ${prepare_builtins_exe} -o ${libclc_builtins_lib} ${builtins_opt_lib}
394
+ DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target}
395
+ WORKING_DIRECTORY ${LIBCLC_OUTPUT_LIBRARY_DIR}
396
+ )
390
397
endif ()
391
398
392
399
# Add a 'prepare' target
@@ -402,7 +409,7 @@ function(add_libclc_builtin_set)
402
409
add_dependencies ( prepare-${ARG_TRIPLE} prepare-${obj_suffix} )
403
410
404
411
install (
405
- FILES ${CMAKE_CURRENT_BINARY_DIR} /${obj_suffix }
412
+ FILES ${libclc_builtins_lib }
406
413
DESTINATION "${CMAKE_INSTALL_DATADIR} /clc"
407
414
)
408
415
@@ -418,20 +425,28 @@ function(add_libclc_builtin_set)
418
425
# * clspv targets don't include all OpenCL builtins
419
426
if ( NOT ARG_ARCH MATCHES "^(nvptx|clspv)(64)?$" )
420
427
add_test ( NAME external-calls-${obj_suffix}
421
- COMMAND ./check_external_calls.sh ${CMAKE_CURRENT_BINARY_DIR} /${obj_suffix } ${LLVM_TOOLS_BINARY_DIR}
428
+ COMMAND ./check_external_calls.sh ${libclc_builtins_lib } ${LLVM_TOOLS_BINARY_DIR}
422
429
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
423
430
endif ()
424
431
425
432
foreach ( a ${ARG_ALIASES} )
426
433
set ( alias_suffix "${a} -${ARG_TRIPLE} .bc" )
427
434
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" )
435
+ OUTPUT ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
436
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${libclc_builtins_lib} ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
437
+ DEPENDS prepare-${obj_suffix}
438
+ WORKING_DIRECTORY ${LIBCLC_OUTPUT_LIBRARY_DIR}
439
+ )
440
+ add_custom_target ( alias-${alias_suffix} ALL
441
+ DEPENDS ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
442
+ )
443
+ set_target_properties ( alias-${alias_suffix}
444
+ PROPERTIES FOLDER "libclc/Device IR/Aliases"
445
+ )
446
+ install (
447
+ FILES ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
448
+ DESTINATION "${CMAKE_INSTALL_DATADIR} /clc"
449
+ )
435
450
endforeach ( a )
436
451
endfunction (add_libclc_builtin_set )
437
452
0 commit comments