================
@@ -1480,16 +1595,20 @@ getDeviceInput(const ArgList &Args) {
if (!Binary.getBinary())
continue;
- SmallVector<OffloadFile::TargetID> CompatibleTargets = {Binary};
+ // A generic member can still be linked into any compatible image; other
+ // members only into images with the same "code".
+ ImageID Target = GetImageID(Binary);
+ bool IsGeneric = Target.first.second == "generic";
+ SmallVector<ImageID> CompatibleTargets = {Target};
for (const auto &[ID, Input] : InputFiles)
- if (OffloadFile::TargetID(Binary) != ID &&
- object::areTargetsCompatible(Binary, ID))
+ if (Target != ID && (IsGeneric || Target.second == ID.second) &&
+ object::areTargetsCompatible(Target.first, ID.first))
----------------
srividya-sundaram wrote:
Yes, the archive member is extracted, since both GPUs map to igca_30r.
But device images are grouped by the same arch and code, and the codes differ
here, so the library's device code is linked separately from the application's:
```
clang-linker-wrapper app.o libl.a
|-- arch=igca_30r, code=xe-mtl-h,xe-mtl-u
| app.o --> clang --sycl-link --> clang-sycl-linker --> ocloc -device
xe-mtl-h,xe-mtl-u --> offload binary 1
|-- arch=igca_30r, code=xe-mtl-u
| lib.o --> clang --sycl-link --> clang-sycl-linker --> ocloc -device
xe-mtl-u --> offload binary 2
|
--> offload binary 1 + offload binary 2 merged into one offload binary -->
one wrapper object
```
https://github.com/llvm/llvm-project/pull/239010
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits