[clang] [clang][Driver][SPIR-V] Allow linking IR using llvm-link (PR #169572)

Nick Sarnie via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 11 09:48:00 PST 2025


sarnex wrote:

> Guessing the idea is to put in N input files and get out one merged LLVM-IR file from the clang interface? I've done this personally with -Wl,--lto-emit-llvm for the OpenMP / libc libraries. Could we just implement some similar functionality in the linker SPIR-V toolchain uses instead?

Yes exactly. With the existing cases (NVPTX,AMDGPU) LTO is actually supported and `lld` is usable, right now neither is true for SPIR-V, trying to use `lld` at all errors in the driver.

The SPIR-V linker is an out-of-tree [project](https://github.com/KhronosGroup/SPIRV-Tools) and I don't expect they would be interested in this change as all of their existing tools take in `spv` and output `spv`, none of their tools do anything with LLVM IR and LLVM isn't even a dependency of the project.

One alternative to this change is to allow using `lld` with SPIR-V just for this case, but adding support for LTO in general seems a bit out of scope for this change, so we could detect if the user passed `-Wl,--lto-emit-llvm` and in that case only call `lld`.

Let me know what you think.

https://github.com/llvm/llvm-project/pull/169572


More information about the cfe-commits mailing list