[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 11:53:06 PST 2025
================
@@ -4562,7 +4565,15 @@ void Driver::BuildDefaultActions(Compilation &C, DerivedArgList &Args,
LA->propagateHostOffloadInfo(C.getActiveOffloadKinds(),
/*BoundArch=*/nullptr);
} else {
- LA = C.MakeAction<LinkJobAction>(LinkerInputs, types::TY_Image);
+ // If we are linking but were passed -emit-llvm, we will be calling
+ // llvm-link, so set the output type accordingly. This is only allowed in
+ // rare cases, so make sure we aren't going to error about it.
+ bool LinkingIR = Args.hasArg(options::OPT_emit_llvm) &&
----------------
sarnex wrote:
That's correct, this change is only intended to make functional changes for `SPIR-V`. However, there is an existing option `-hip-link` that also uses `llvm-link` (see [here](https://github.com/sarnex/llvm-project/blob/4cffff5b05823d4530fd0716d10e25b29f6a6cf3/clang/lib/Driver/Driver.cpp#L4237C45-L4238C45)) for the AMDGPU toolchain, so I included that because it's another known case where we're linking IR.
https://github.com/llvm/llvm-project/pull/169572
More information about the cfe-commits
mailing list