[cfe-dev] [RFC][SPIR-V] Add linking of separate translation units using spirv-link

Anastasia Stulova via cfe-dev cfe-dev at lists.llvm.org
Tue Jan 4 03:38:31 PST 2022


Hello,

I would like to propose enabling linking functionality of SPIR-V object 
files using spirv-link from the SPIRV-Tools project (https:
//github.com/KhronosGroup/SPIRV-Tools#linker). The initial patch is available 
at https://reviews.llvm.org/D116266 and it follows the conventional approach in 
clang and therefore completes the SPIR-V Toolchain functionality.

Examples:

clang --target=spirv64 file1.cl file2.cl

clang --target=spirv64 file1.cl -o file1.o
clang --target=spirv64 file1.o file2.cl -o all.out

Note that the implementation of linking phase is completely independent from
the SPIR-V binary generation phase and it applies to either mechanism that is
used to produce the SPIR-V binary format (internal backend or llvm-spirv tool)
as long as the binary is in the correct format. Similar to the use of other optional
linkers e.g. gold, this introduces a soft dependency on spirv-link for users of
the SPIR-V feature only. This is reflected in the clang documentation of the
proposed patch.

Comments and reviews are greatly appreciated!
Kind regards,
Anastasia


More information about the cfe-dev mailing list