Issue 243304
Summary [Clang][SYCL] Report unresolved symbols in a SYCL device link
Labels SYCL
Assignees
Reporter srividya-sundaram
    For SYCL, clang-linker-wrapper runs one **device link** per group of device images with the same `arch` and `code`: clang-sycl-linker links the group's device code and compiles it with ocloc. After that, the **final host link** links the host code into the executable.

When device code for the same IGCA target is compiled for different Intel GPUs, it ends up in separate device links, as in https://github.com/llvm/llvm-project/pull/239010. A `SYCL_EXTERNAL` function defined in one device link is then not available to the other, but nothing reports it:

```
clang++ -fsycl --offload-arch=xe-mtl-u -c lib.cpp -o lib.o && llvm-ar rcs libl.a lib.o
clang++ -fsycl --offload-arch=xe-mtl-u,xe-mtl-h -c app.cpp -o app.o
clang++ -fsycl --offload-arch=xe-mtl-u,xe-mtl-h app.o libl.a -o app
```

- `lib.o` has `igca_30r` with `code=xe-mtl-u`, and `app.o` has `igca_30r` with `code=xe-mtl-h,xe-mtl-u`, so they get two separate device links:
  - device link `igca_30r`, `code=xe-mtl-h,xe-mtl-u`: `app.o` only
 - device link `igca_30r`, `code=xe-mtl-u`: `lib.o` only
- If `app.o`'s device code calls a `SYCL_EXTERNAL` function defined in `lib.o`, the call is not resolved in `app.o`'s device link.
- clang-sycl-linker finishes that device link without an error.
- The final host link also succeeds, since the host part of the function is in `lib.o`.

clang-sycl-linker should report an error when a device link calls a function that none of its inputs define, naming the function and the device link, e.g. `libf` in the device link for `igca_30r`, `code=xe-mtl-h,xe-mtl-u`. It should not fail device links that are complete on their own, e.g. when `app.o` doesn't call into `lib.o`.

Discussed in https://github.com/llvm/llvm-project/pull/239010#discussion_r4556954075.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to