Skip to content

Commit 3668c0a

Browse files
author
Martin Wehking
committed
Create one bitcode library for NVPTX
Create one single bitcode library for NVPTX by compiling each libdev file into bitcode first, linking these together and running opt on them. Strip away metadata by reusing prepare_builtins from libclc. Remove NVPTX bundles from the libdev object files and remove any unbundling action spawned by the Clang driver for the SYCL toolchain when compiling for the NVPTX backend. Make the driver link against the single bitcode libraries for NVPTX for the SYCL toolchain when device library linkage is not excluded. Ensure that the clang tests check for the correctness of the new clang driver actions and check if the driver still links the device code against the itt device libraries when device library linkage has been excluded. Refactor SYCLLibdevice.cmake by creating functions and grouping e.g. the same compilation flags for a filetype together in one variable. Reuse these variables and call functions to remove redundancies.
1 parent de0260f commit 3668c0a

File tree

8 files changed

+538
-536
lines changed

8 files changed

+538
-536
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5848,10 +5848,9 @@ class OffloadingActionBuilder final {
58485848
++NumOfDeviceLibLinked;
58495849
Arg *InputArg = MakeInputArg(Args, C.getDriver().getOpts(),
58505850
Args.MakeArgString(LibName));
5851-
if (TC->getTriple().isNVPTX() ||
5852-
(TC->getTriple().isSPIR() &&
5853-
TC->getTriple().getSubArch() ==
5854-
llvm::Triple::SPIRSubArch_fpga)) {
5851+
if (TC->getTriple().isSPIR() &&
5852+
TC->getTriple().getSubArch() ==
5853+
llvm::Triple::SPIRSubArch_fpga) {
58555854
auto *SYCLDeviceLibsInputAction =
58565855
C.MakeAction<InputAction>(*InputArg, types::TY_Object);
58575856
auto *SYCLDeviceLibsUnbundleAction =

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
212212
SmallVector<std::string, 8> LibraryList;
213213
const llvm::opt::ArgList &Args = C.getArgs();
214214

215+
// For NVPTX we only use one single bitcode library and ignore
216+
// manually specified SYCL device libraries.
217+
bool IgnoreSingleLibs = TargetTriple.isNVPTX();
218+
215219
struct DeviceLibOptInfo {
216220
StringRef DeviceLibName;
217221
StringRef DeviceLibOption;
@@ -233,10 +237,13 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
233237
if (A->getOption().matches(options::OPT_fno_sycl_device_lib_EQ))
234238
NoDeviceLibs = true;
235239

240+
bool PrintUnusedLibWarning = false;
236241
for (StringRef Val : A->getValues()) {
237242
if (Val == "all") {
238243
for (const auto &K : DeviceLibLinkInfo.keys())
239-
DeviceLibLinkInfo[K] = true && (!NoDeviceLibs || K == "internal");
244+
DeviceLibLinkInfo[K] = (!IgnoreSingleLibs && !NoDeviceLibs) ||
245+
(K == "internal" && NoDeviceLibs);
246+
PrintUnusedLibWarning = false;
240247
break;
241248
}
242249
auto LinkInfoIter = DeviceLibLinkInfo.find(Val);
@@ -247,10 +254,21 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
247254
C.getDriver().Diag(diag::err_drv_unsupported_option_argument)
248255
<< A->getSpelling() << Val;
249256
}
250-
DeviceLibLinkInfo[Val] = true && !NoDeviceLibs;
257+
DeviceLibLinkInfo[Val] = !NoDeviceLibs && !IgnoreSingleLibs;
258+
PrintUnusedLibWarning = IgnoreSingleLibs && !NoDeviceLibs;
251259
}
260+
if (PrintUnusedLibWarning)
261+
C.getDriver().Diag(diag::warn_ignored_clang_option)
262+
<< A->getSpelling() << A->getAsString(Args);
252263
}
253264
}
265+
266+
if (TargetTriple.isNVPTX() && !NoDeviceLibs)
267+
LibraryList.push_back(Args.MakeArgString("devicelib--cuda.bc"));
268+
269+
if (IgnoreSingleLibs && !NoDeviceLibs)
270+
return LibraryList;
271+
254272
using SYCLDeviceLibsList = SmallVector<DeviceLibOptInfo, 5>;
255273

256274
const SYCLDeviceLibsList SYCLDeviceWrapperLibs = {
@@ -304,10 +322,9 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
304322
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
305323
bool IsNewOffload = C.getDriver().getUseNewOffloadingDriver();
306324
StringRef LibSuffix = ".bc";
307-
if (TargetTriple.isNVPTX() ||
308-
(TargetTriple.isSPIR() &&
309-
TargetTriple.getSubArch() == llvm::Triple::SPIRSubArch_fpga))
310-
// For NVidia or FPGA, we are unbundling objects.
325+
if (TargetTriple.isSPIR() &&
326+
TargetTriple.getSubArch() == llvm::Triple::SPIRSubArch_fpga)
327+
// For FPGA, we are unbundling objects.
311328
LibSuffix = IsWindowsMSVCEnv ? ".obj" : ".o";
312329
if (IsNewOffload)
313330
// For new offload model, we use packaged .bc files.
@@ -323,7 +340,7 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
323340
};
324341

325342
addLibraries(SYCLDeviceWrapperLibs);
326-
if (IsSpirvAOT || TargetTriple.isNVPTX())
343+
if (IsSpirvAOT)
327344
addLibraries(SYCLDeviceFallbackLibs);
328345

329346
bool NativeBfloatLibs;
@@ -551,7 +568,7 @@ const char *SYCL::Linker::constructLLVMLinkCommand(
551568
this->getToolChain().getTriple().getSubArch() ==
552569
llvm::Triple::SPIRSubArch_fpga;
553570
StringRef LibPostfix = ".bc";
554-
if (IsNVPTX || IsFPGA) {
571+
if (IsFPGA) {
555572
LibPostfix = ".o";
556573
if (HostTC->getTriple().isWindowsMSVCEnvironment() &&
557574
C.getDriver().IsCLMode())

clang/test/CodeGenSYCL/sycl-libdevice-cmath.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// intrinsics. This allows the driver to link in the libdevice definitions for
66
// cosf etc. later in the driver flow.
77

8-
// RUN: %clang_cc1 %s -fsycl-is-device -triple nvptx64-nvidia-cuda -emit-llvm -o - | FileCheck %s
8+
// RUN: %clang_cc1 %s -fsycl-is-device -triple nvptx64-nvidia-cuda -emit-llvm -o - | FileCheck %s
99
// RUN: %clang_cc1 %s -fsycl-is-device -triple nvptx64-nvidia-cuda -ffast-math -emit-llvm -o - | FileCheck %s
1010

1111
#include "Inputs/sycl.hpp"

clang/test/Driver/sycl-offload-nvptx.cpp

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,22 @@
5353
// CHK-PHASES-NO-CC: 7: backend, {6}, assembler, (host-sycl)
5454
// CHK-PHASES-NO-CC: 8: assembler, {7}, object, (host-sycl)
5555
// CHK-PHASES-NO-CC: 9: linker, {4}, ir, (device-sycl, sm_50)
56-
// CHK-PHASES-NO-CC: 10: input, "{{.*}}libsycl-itt-user-wrappers.o{{.*}}", object
57-
// CHK-PHASES-NO-CC: 11: clang-offload-unbundler, {10}, object
58-
// CHK-PHASES-NO-CC: 12: offload, " (nvptx64-nvidia-cuda)" {11}, object
59-
// CHK-PHASES-NO-CC: 13: input, "{{.*}}libsycl-itt-compiler-wrappers.o{{.*}}", object
60-
// CHK-PHASES-NO-CC: 14: clang-offload-unbundler, {13}, object
61-
// CHK-PHASES-NO-CC: 15: offload, " (nvptx64-nvidia-cuda)" {14}, object
62-
// CHK-PHASES-NO-CC: 16: input, "{{.*}}libsycl-itt-stubs.o{{.*}}", object
63-
// CHK-PHASES-NO-CC: 17: clang-offload-unbundler, {16}, object
64-
// CHK-PHASES-NO-CC: 18: offload, " (nvptx64-nvidia-cuda)" {17}, object
65-
// CHK-PHASES-NO-CC: 19: input, "{{.*}}nvidiacl{{.*}}", ir, (device-sycl, sm_50)
66-
// CHK-PHASES-NO-CC: 20: input, "{{.*}}libdevice{{.*}}", ir, (device-sycl, sm_50)
67-
// CHK-PHASES-NO-CC: 21: linker, {9, 12, 15, 18, 19, 20}, ir, (device-sycl, sm_50)
68-
// CHK-PHASES-NO-CC: 22: sycl-post-link, {21}, ir, (device-sycl, sm_50)
69-
// CHK-PHASES-NO-CC: 23: file-table-tform, {22}, ir, (device-sycl, sm_50)
70-
// CHK-PHASES-NO-CC: 24: backend, {23}, assembler, (device-sycl, sm_50)
71-
// CHK-PHASES-NO-CC: 25: assembler, {24}, object, (device-sycl, sm_50)
72-
// CHK-PHASES-NO-CC: 26: linker, {24, 25}, cuda-fatbin, (device-sycl, sm_50)
73-
// CHK-PHASES-NO-CC: 27: foreach, {23, 26}, cuda-fatbin, (device-sycl, sm_50)
74-
// CHK-PHASES-NO-CC: 28: file-table-tform, {22, 27}, tempfiletable, (device-sycl, sm_50)
75-
// CHK-PHASES-NO-CC: 29: clang-offload-wrapper, {28}, object, (device-sycl, sm_50)
76-
// CHK-PHASES-NO-CC: 30: offload, "device-sycl (nvptx64-nvidia-cuda:sm_50)" {29}, object
77-
// CHK-PHASES-NO-CC: 31: linker, {8, 30}, image, (host-sycl)
56+
// CHK-PHASES-NO-CC: 10: input, "{{.*}}libsycl-itt-user-wrappers.bc", ir, (device-sycl, sm_50)
57+
// CHK-PHASES-NO-CC: 11: input, "{{.*}}libsycl-itt-compiler-wrappers.bc", ir, (device-sycl, sm_50)
58+
// CHK-PHASES-NO-CC: 12: input, "{{.*}}libsycl-itt-stubs.bc", ir, (device-sycl, sm_50)
59+
// CHK-PHASES-NO-CC: 13: input, "{{.*}}nvidiacl{{.*}}", ir, (device-sycl, sm_50)
60+
// CHK-PHASES-NO-CC: 14: input, "{{.*}}libdevice{{.*}}", ir, (device-sycl, sm_50)
61+
// CHK-PHASES-NO-CC: 15: linker, {9, 10, 11, 12, 13, 14}, ir, (device-sycl, sm_50)
62+
// CHK-PHASES-NO-CC: 16: sycl-post-link, {15}, ir, (device-sycl, sm_50)
63+
// CHK-PHASES-NO-CC: 17: file-table-tform, {16}, ir, (device-sycl, sm_50)
64+
// CHK-PHASES-NO-CC: 18: backend, {17}, assembler, (device-sycl, sm_50)
65+
// CHK-PHASES-NO-CC: 19: assembler, {18}, object, (device-sycl, sm_50)
66+
// CHK-PHASES-NO-CC: 20: linker, {18, 19}, cuda-fatbin, (device-sycl, sm_50)
67+
// CHK-PHASES-NO-CC: 21: foreach, {17, 20}, cuda-fatbin, (device-sycl, sm_50)
68+
// CHK-PHASES-NO-CC: 22: file-table-tform, {16, 21}, tempfiletable, (device-sycl, sm_50)
69+
// CHK-PHASES-NO-CC: 23: clang-offload-wrapper, {22}, object, (device-sycl, sm_50)
70+
// CHK-PHASES-NO-CC: 24: offload, "device-sycl (nvptx64-nvidia-cuda:sm_50)" {23}, object
71+
// CHK-PHASES-NO-CC: 25: linker, {8, 24}, image, (host-sycl)
7872
//
7973
/// Check phases specifying a compute capability.
8074
// RUN: %clangxx -ccc-print-phases --sysroot=%S/Inputs/SYCL -std=c++11 \
@@ -97,28 +91,22 @@
9791
// CHK-PHASES: 7: backend, {6}, assembler, (host-sycl)
9892
// CHK-PHASES: 8: assembler, {7}, object, (host-sycl)
9993
// CHK-PHASES: 9: linker, {4}, ir, (device-sycl, sm_35)
100-
// CHK-PHASES: 10: input, "{{.*}}libsycl-itt-user-wrappers.o", object
101-
// CHK-PHASES: 11: clang-offload-unbundler, {10}, object
102-
// CHK-PHASES: 12: offload, " (nvptx64-nvidia-cuda)" {11}, object
103-
// CHK-PHASES: 13: input, "{{.*}}libsycl-itt-compiler-wrappers.o", object
104-
// CHK-PHASES: 14: clang-offload-unbundler, {13}, object
105-
// CHK-PHASES: 15: offload, " (nvptx64-nvidia-cuda)" {14}, object
106-
// CHK-PHASES: 16: input, "{{.*}}libsycl-itt-stubs.o", object
107-
// CHK-PHASES: 17: clang-offload-unbundler, {16}, object
108-
// CHK-PHASES: 18: offload, " (nvptx64-nvidia-cuda)" {17}, object
109-
// CHK-PHASES: 19: input, "{{.*}}nvidiacl{{.*}}", ir, (device-sycl, sm_35)
110-
// CHK-PHASES: 20: input, "{{.*}}libdevice{{.*}}", ir, (device-sycl, sm_35)
111-
// CHK-PHASES: 21: linker, {9, 12, 15, 18, 19, 20}, ir, (device-sycl, sm_35)
112-
// CHK-PHASES: 22: sycl-post-link, {21}, ir, (device-sycl, sm_35)
113-
// CHK-PHASES: 23: file-table-tform, {22}, ir, (device-sycl, sm_35)
114-
// CHK-PHASES: 24: backend, {23}, assembler, (device-sycl, sm_35)
115-
// CHK-PHASES: 25: assembler, {24}, object, (device-sycl, sm_35)
116-
// CHK-PHASES: 26: linker, {24, 25}, cuda-fatbin, (device-sycl, sm_35)
117-
// CHK-PHASES: 27: foreach, {23, 26}, cuda-fatbin, (device-sycl, sm_35)
118-
// CHK-PHASES: 28: file-table-tform, {22, 27}, tempfiletable, (device-sycl, sm_35)
119-
// CHK-PHASES: 29: clang-offload-wrapper, {28}, object, (device-sycl, sm_35)
120-
// CHK-PHASES: 30: offload, "device-sycl (nvptx64-nvidia-cuda:sm_35)" {29}, object
121-
// CHK-PHASES: 31: linker, {8, 30}, image, (host-sycl)
94+
// CHK-PHASES: 10: input, "{{.*}}libsycl-itt-user-wrappers.bc", ir, (device-sycl, sm_35)
95+
// CHK-PHASES: 11: input, "{{.*}}libsycl-itt-compiler-wrappers.bc", ir, (device-sycl, sm_35)
96+
// CHK-PHASES: 12: input, "{{.*}}libsycl-itt-stubs.bc", ir, (device-sycl, sm_35)
97+
// CHK-PHASES: 13: input, "{{.*}}nvidiacl{{.*}}", ir, (device-sycl, sm_35)
98+
// CHK-PHASES: 14: input, "{{.*}}libdevice{{.*}}", ir, (device-sycl, sm_35)
99+
// CHK-PHASES: 15: linker, {9, 10, 11, 12, 13, 14}, ir, (device-sycl, sm_35)
100+
// CHK-PHASES: 16: sycl-post-link, {15}, ir, (device-sycl, sm_35)
101+
// CHK-PHASES: 17: file-table-tform, {16}, ir, (device-sycl, sm_35)
102+
// CHK-PHASES: 18: backend, {17}, assembler, (device-sycl, sm_35)
103+
// CHK-PHASES: 19: assembler, {18}, object, (device-sycl, sm_35)
104+
// CHK-PHASES: 20: linker, {18, 19}, cuda-fatbin, (device-sycl, sm_35)
105+
// CHK-PHASES: 21: foreach, {17, 20}, cuda-fatbin, (device-sycl, sm_35)
106+
// CHK-PHASES: 22: file-table-tform, {16, 21}, tempfiletable, (device-sycl, sm_35)
107+
// CHK-PHASES: 23: clang-offload-wrapper, {22}, object, (device-sycl, sm_35)
108+
// CHK-PHASES: 24: offload, "device-sycl (nvptx64-nvidia-cuda:sm_35)" {23}, object
109+
// CHK-PHASES: 25: linker, {8, 24}, image, (host-sycl)
122110

123111
/// Check calling preprocessor only
124112
// RUN: %clangxx -E -fsycl -fsycl-targets=nvptx64-nvidia-cuda -ccc-print-phases %s 2>&1 \

libclc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ if( ENABLE_RUNTIME_SUBNORMAL )
233233
foreach( file subnormal_use_default subnormal_disable )
234234
link_bc(
235235
TARGET ${file}
236+
RSP_DIR ${LIBCLC_ARCH_OBJFILE_DIR}
236237
INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/${file}.ll
237238
)
238239
install( FILES $<TARGET_PROPERTY:${file},TARGET_FILE> ARCHIVE
@@ -405,7 +406,6 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
405406
# Enable SPIR-V builtin function declarations, so they don't
406407
# have to be explicity declared in the soruce.
407408
list( APPEND flags -Xclang -fdeclare-spirv-builtins)
408-
409409
set( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR}/${arch_suffix}" )
410410
file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
411411

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,15 @@ endfunction()
8686
# Custom target to create
8787
# * INPUT <string> ...
8888
# List of bytecode files to link together
89+
# * RSP_DIR <string>
90+
# Directory where a response file should be placed
91+
# (Only needed for WIN32 or CYGWIN)
8992
# * DEPENDENCIES <string> ...
9093
# List of extra dependencies to inject
9194
function(link_bc)
9295
cmake_parse_arguments(ARG
9396
""
94-
"TARGET"
97+
"TARGET;RSP_DIR"
9598
"INPUTS;DEPENDENCIES"
9699
${ARGN}
97100
)
@@ -100,7 +103,7 @@ function(link_bc)
100103
if( WIN32 OR CYGWIN )
101104
# Create a response file in case the number of inputs exceeds command-line
102105
# character limits on certain platforms.
103-
file( TO_CMAKE_PATH ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.rsp RSP_FILE )
106+
file( TO_CMAKE_PATH ${ARG_RSP_DIR}/${ARG_TARGET}.rsp RSP_FILE )
104107
# Turn it into a space-separate list of input files
105108
list( JOIN ARG_INPUTS " " RSP_INPUT )
106109
file( WRITE ${RSP_FILE} ${RSP_INPUT} )
@@ -216,6 +219,50 @@ function(add_libclc_alias alias target)
216219

217220
endfunction(add_libclc_alias alias target)
218221

222+
# Runs opt and prepare-builtins on a bitcode file specified by lib_tgt
223+
#
224+
# ARGUMENTS:
225+
# * LIB_TGT string
226+
# Target name that becomes dependent on the out file named LIB_TGT.bc
227+
# * IN_FILE string
228+
# Target name of the input bytecode file
229+
# * OUT_DIR string
230+
# Name of the directory where the output should be placed
231+
# * DEPENDENCIES <string> ...
232+
# List of extra dependencies to inject
233+
function(process_bc out_file)
234+
cmake_parse_arguments(ARG
235+
""
236+
"LIB_TGT;IN_FILE;OUT_DIR"
237+
"OPT_FLAGS;DEPENDENCIES"
238+
${ARGN})
239+
add_custom_command( OUTPUT ${ARG_LIB_TGT}.bc
240+
COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${ARG_LIB_TGT}.bc
241+
${ARG_IN_FILE}
242+
DEPENDS ${opt_target} ${ARG_IN_FILE} ${ARG_DEPENDENCIES}
243+
)
244+
add_custom_target( ${ARG_LIB_TGT}
245+
ALL DEPENDS ${ARG_LIB_TGT}.bc
246+
)
247+
set_target_properties( ${ARG_LIB_TGT}
248+
PROPERTIES TARGET_FILE ${ARG_LIB_TGT}.bc
249+
)
250+
251+
set( builtins_opt_lib $<TARGET_PROPERTY:${ARG_LIB_TGT},TARGET_FILE> )
252+
253+
# Add prepare target
254+
add_custom_command( OUTPUT ${ARG_OUT_DIR}/${out_file}
255+
COMMAND ${prepare_builtins_exe} -o ${ARG_OUT_DIR}/${out_file}
256+
${builtins_opt_lib}
257+
DEPENDS ${builtins_opt_lib} ${ARG_LIB_TGT} ${prepare_builtins_target} )
258+
add_custom_target( prepare-${out_file} ALL
259+
DEPENDS ${ARG_OUT_DIR}/${out_file}
260+
)
261+
set_target_properties( prepare-${out_file}
262+
PROPERTIES TARGET_FILE ${ARG_OUT_DIR}/${out_file}
263+
)
264+
endfunction()
265+
219266
# add_libclc_builtin_set(arch_suffix
220267
# TRIPLE string
221268
# Triple used to compile
@@ -291,44 +338,28 @@ macro(add_libclc_builtin_set arch_suffix)
291338
link_bc(
292339
TARGET ${builtins_link_lib_tgt}
293340
INPUTS ${bytecode_files}
341+
RSP_DIR ${LIBCLC_ARCH_OBJFILE_DIR}
294342
DEPENDENCIES ${builtins_comp_lib_tgt}
295343
)
296344

297345
set( builtins_link_lib $<TARGET_PROPERTY:${builtins_link_lib_tgt},TARGET_FILE> )
298346

299-
set( builtins_opt_lib_tgt builtins.opt.${arch_suffix} )
347+
add_custom_command( OUTPUT ${LIBCLC_LIBRARY_OUTPUT_INTDIR}
348+
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_LIBRARY_OUTPUT_INTDIR}
349+
DEPENDS ${builtins_link_lib} prepare_builtins )
300350

301-
# Add opt target
302-
add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc
303-
COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc
304-
${builtins_link_lib}
305-
DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
306-
)
307-
add_custom_target( ${builtins_opt_lib_tgt}
308-
ALL DEPENDS ${builtins_opt_lib_tgt}.bc
309-
)
310-
set_target_properties( ${builtins_opt_lib_tgt}
311-
PROPERTIES TARGET_FILE ${builtins_opt_lib_tgt}.bc
312-
)
351+
set( builtins_opt_lib_tgt builtins.opt.${arch_suffix} )
313352

314-
set( builtins_opt_lib $<TARGET_PROPERTY:${builtins_opt_lib_tgt},TARGET_FILE> )
315-
316-
# Add prepare target
317-
set( obj_suffix ${arch_suffix}.bc )
318-
add_custom_command( OUTPUT ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/${obj_suffix}
319-
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_LIBRARY_OUTPUT_INTDIR}
320-
COMMAND ${prepare_builtins_exe} -o ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/${obj_suffix}
321-
${builtins_opt_lib}
322-
DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target} )
323-
add_custom_target( prepare-${obj_suffix} ALL
324-
DEPENDS ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/${obj_suffix}
325-
)
326-
set_target_properties( prepare-${obj_suffix}
327-
PROPERTIES TARGET_FILE ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/${obj_suffix}
328-
)
353+
process_bc(${arch_suffix}.bc
354+
LIB_TGT ${builtins_opt_lib_tgt}
355+
IN_FILE ${builtins_link_lib}
356+
OUT_DIR ${LIBCLC_LIBRARY_OUTPUT_INTDIR}
357+
OPT_FLAGS ${ARG_OPT_FLAGS}
358+
DEPENDENCIES ${builtins_link_lib_tgt})
329359

330360
# Add dependency to top-level pseudo target to ease making other
331361
# targets dependent on libclc.
362+
set( obj_suffix ${arch_suffix}.bc )
332363
add_dependencies(${ARG_PARENT_TARGET} prepare-${obj_suffix})
333364
set( builtins_lib $<TARGET_PROPERTY:prepare-${obj_suffix},TARGET_FILE> )
334365

libdevice/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Utility project providing various functionalities for SPIR-V devices
22
# without native support of these functionalities.
33

4+
include(${CMAKE_CURRENT_SOURCE_DIR}/../libclc/cmake/modules/AddLibclc.cmake)
5+
46
set(CMAKE_MODULE_PATH
57
${CMAKE_MODULE_PATH}
68
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"

0 commit comments

Comments
 (0)