llvm / llvm/llvm-project

[Offload] Tests implicitly require `LLVMgold` and fail without it

Open
#159,297 0 comments 0 reactions 0 assignees View on GitHub
openmp:libomptarget test-suite
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I've been trying to make some contributions into `offload` sub-project and tried running `check-offload` to verify my changes, but a lot of tests failed:

```
Failed Tests (145):
libomptarget :: x86_64-unknown-linux-gnu :: offloading/bug51781.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: api/assert.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: api/omp_device_alloc.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: api/omp_device_managed_memory.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: api/omp_device_managed_memory_alloc.c
...
... many more
...
libomptarget :: x86_64-unknown-linux-gnu-LTO :: ompt/veccopy_wrong_return.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: unified_shared_memory/api.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: unified_shared_memory/associate_ptr.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: unified_shared_memory/close_enter_exit.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: unified_shared_memory/close_manual.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: unified_shared_memory/close_member.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: unified_shared_memory/close_modifier.c
libomptarget :: x86_64-unknown-linux-gnu-LTO :: unified_shared_memory/shared_update.c
```

They all fail with the same error:

```
# .---command stderr------------
# | /usr/bin/ld: llvm/llvm-project/build/bin/../lib/LLVMgold.so: error loading plugin: llvm/llvm-project/build/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory
# | clang: error: linker command failed with exit code 1 (use -v to see invocation)
# | llvm/llvm-project/build/bin/clang-linker-wrapper: error: 'clang' failed
# | clang++: error: linker command failed with exit code 1 (use -v to see invocation)
# `-----------------------------
# error: command failed with exit status: 1
```

From what I understand, tests which involve LTO (that includes `bug51781.c`) need `LLVMgold.so`, but don't actually check if it is built.

`llvm/` subproject testing adds `LLVMgold` as a dependency for test targets if `LLVMgold` target is registered (so that `check-offload` works in a clean build).

https://github.com/llvm/llvm-project/blob/b29c7ded31d81ca47aed0157c543c8b6a0f5866c/llvm/test/CMakeLists.txt#L170-L173

And it has a logic of detecting the plugin presence at runtime to register a LIT feature:

https://github.com/llvm/llvm-project/blob/b29c7ded31d81ca47aed0157c543c8b6a0f5866c/llvm/test/lit.cfg.py#L615-L619

https://github.com/llvm/llvm-project/blob/b29c7ded31d81ca47aed0157c543c8b6a0f5866c/llvm/test/lit.cfg.py#L654-L655

With respect to `offload`, the proposed fix is:
- register `ld_plugin` feature if `LLVMgold` is detected - to address tests like `bug51781.c`
- entirely skip registering (i.e. setting value to `LIBOMPTARGET_SYSTEM_TARGETS` CMake variable) `-LTO` targets if `LLVMgold` target isn't registered

Does it sound like a right approach?

Contributor guide

Open the contributing guide

Research direction

Start with llvm/test/CMakeLists.txt and llvm/test/lit.cfg.py, then trace how offload registers its system targets and LTO tests. Compare the existing LLVMgold dependency and runtime feature checks with the failing check-offload configurations; done means configurations requiring an unavailable LLVMgold plugin no longer fail during test discovery or execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cmake
Domain
build-system, compilers, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.