New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libarcher does not work in the libomp-10-dev package #45290
Comments
I looked into the options used for building the library in the debian build. This is a default linker flag according to: dpkg-buildflags --get LDFLAGS The following removes the flag from the LDFLAGS I cannot find any mentioning of this flag in the llvm-build directory, so cmake is not aware of this flag. Therefore, I think we cannot remove the flag just for libarcher.so using cmake magic. |
Due to this flag, Archer uses the weak implementation of the functions rather than calling the implementation of the function available in the application, when the statically linked TSan runtime library is present in the application.
|
Sorry, I only see this bug.
$ clang-14 -fopenmp -fsanitize=thread red-norace.c -g
|
I just installed the llvm-12 packages from the repository. For my tests, I set LD_LIBARARY_PATH to include the directory with libarcher.so. According to $ clang-12 -fopenmp -fsanitize=thread red-norace.c libarcher is loaded, but the call to RunningOnValgrind ends up in the weak implementation in libarcher instead of using the function in a.out. For comparison, I have the clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz release build from github unpacked. Using the OMP_TOOL_LIBRARIES env, I can explicitly select to use libarcher from the release tarball: I did not rebuild the application and still use libomp from the debian package. |
mentioned in issue llvm/llvm-bugzilla-archive#51117 |
If somebody interested: I don't know full consequences of that though - may be this solution has some drawbacks. |
FWIW the related bug reports for Ubuntu are https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1899199 and https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1964487 |
This patch fix issues reported for Ubuntu and possibly other platforms: #45290 The latest comment on this issue points out that using dlsym rather than the weak symbol approach to call TSan annotation functions fixes the issue for Ubuntu. Differential Revision: https://reviews.llvm.org/D142378
@llvm/issue-subscribers-openmp |
After 7fbf122 all tests pass, when setting |
This patch fix issues reported for Ubuntu and possibly other platforms: llvm/llvm-project#45290 The latest comment on this issue points out that using dlsym rather than the weak symbol approach to call TSan annotation functions fixes the issue for Ubuntu. Differential Revision: https://reviews.llvm.org/D142378
Extended Description
The idea of Archer is to complement ThreadSanitizer and provide the synchronization semantics for OpenMP. In a vanilla build of LLVM with openmp, libarcher is loaded by the OpenMP runtime (libomp.so) automatically and checks whether the TSan library is present in the execution:
$ export ARCHER_OPTIONS=verbose=1
$ clang -fopenmp -fsanitize=thread red-norace.c -g
$ OMP_NUM_THREADS=2 ./a.out
Archer detected OpenMP application with TSan, supplying OpenMP synchronization semantics
Sum: 4999950000
Using clang-10 from the package, there are several issues. First, the archer library is not found as the library is not in the dl search path (as also mentioned in bug 45909)
$ clang-10 -fopenmp -fsanitize=thread red-norace.c -g
$ OMP_NUM_THREADS=2 ./a.out
... WARNING: ThreadSanitizer: data race ...
Creating a link in /lib/x86_64-linux-gnu should help for this.
The next issue (after I added the link):
$ OMP_NUM_THREADS=2 ./a.out
Archer detected OpenMP application without TSan stopping operation
... WARNING: ThreadSanitizer: data race ...
I could not figure out, why the archer library does not use the exported dynamic symbols from the tsan runtime, which is statically linked into the application:
$ readelf --dyn-syms a.out | grep RunningOnValgrind
529: 000000000048f6f0 18 FUNC GLOBAL DEFAULT 13 RunningOnValgrind
$ readelf --dyn-syms /usr/lib/llvm-10/lib/libarcher.so | grep RunningOnValgrind
61: 0000000000002770 10 FUNC WEAK DEFAULT 12 RunningOnValgrind
$ readelf --dyn-syms /home/.../clang/10.0/lib/libarcher.so | grep RunningOnValgrind
64: 0000000000002590 10 FUNC WEAK DEFAULT 12 RunningOnValgrind
I can successfully use clang-10 with my vanilla build of libarcher. So, it seems like there is something funny going on with libarcher from the deb package.
Finally, I'm not sure why the library should not be installed if compiler and OpenMP runtime are installed. I can understand that developers packages are not installed by default, but a compiler is typically installed by developers?
The text was updated successfully, but these errors were encountered: