Skip to content
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

Clang's thread sanitizer (part of libcompiler-rt) does not seem to work #5853

Closed
Grimler91 opened this issue Sep 26, 2020 · 7 comments
Closed
Labels
bug report Something is not working properly

Comments

@Grimler91
Copy link
Member

Problem description

Compiling a minimal c file on aarch64 or x86_64 with -fsanitize=thread does not work (arm and i686 do not support -fsanitize=thread).

Steps to reproduce

test.c:

int main()
{
  return 0;
}

Compile with clang -fsanitize=thread test.c -o test $PREFIX/lib/clang/10.0.1/lib/android/libclang_rt.tsan-aarch64-android.a gives

/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/lib/clang/10.0.1/lib/android/libclang_rt.tsan-aarch64-android.a(tsan_interceptors_posix.cpp.o): in function `__interceptor_lgamma':
/home/builder/.termux-build/libllvm/src/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:4969: undefined reference to `signgam'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /home/builder/.termux-build/libllvm/src/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:4969: undefined reference to `signgam'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/lib/clang/10.0.1/lib/android/libclang_rt.tsan-aarch64-android.a(tsan_interceptors_posix.cpp.o): in function `__interceptor_lgammaf':
/home/builder/.termux-build/libllvm/src/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:4976: undefined reference to `signgam'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /home/builder/.termux-build/libllvm/src/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:4976: undefined reference to `signgam'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/lib/clang/10.0.1/lib/android/libclang_rt.tsan-aarch64-android.a(tsan_interceptors_posix.cpp.o): in function `__interceptor_lgammal':
/home/builder/.termux-build/libllvm/src/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:4991: undefined reference to `signgam'
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: /data/data/com.termux/files/usr/lib/clang/10.0.1/lib/android/libclang_rt.tsan-aarch64-android.a(tsan_interceptors_posix.cpp.o):/home/builder/.termux-build/libllvm/src/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:4991: more undefined references to `signgam' follow
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

Expected behavior

It should compile without errors about missing symbols.

Additional information

Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://grimler.se/termux-packages-24 stable main
# root-repo (sources.list.d/root.list)
deb https://grimler.se/termux-root-packages-24 root stable
# sources.list.d/science.list.dpkg-dist
deb https://dl.bintray.com/grimler/science-packages-24 science stable
# sources.list.d/game.list.dpkg-dist
deb https://dl.bintray.com/grimler/game-packages-24 games stable
# science-repo (sources.list.d/science.list)
deb https://grimler.se/science-packages-24 science stable
# game-repo (sources.list.d/game.list)
deb https://grimler.se/game-packages-24 games stable
# unstable-repo (sources.list.d/unstable.list)
deb https://grimler.se/unstable-packages unstable main
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/24 termux extras
# sources.list.d/x11.list
deb https://grimler.se/x11-packages x11 main
Updatable packages:
apache2/stable 2.4.46-4 aarch64 [upgradable from: 2.4.46-3]
texlive-bin/stable 20200406-6 aarch64 [upgradable from: 20200406-6]
Android version:
10
Kernel build information:
Linux localhost 4.4.111-ga215b80be236 #3 SMP PREEMPT Fri Sep 4 09:51:01 CEST 2020 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-G955F
@nikey02
Copy link

nikey02 commented Oct 21, 2020

I don't know solution and know one has answered so may time to upgrade clang-11 is released.

@its-pointless
Copy link
Contributor

try linking against libm so
clang -fsanitize=thread test.c -o test $PREFIX/lib/clang/10.0.1/lib/android/libclang_rt.tsan-aarch64-android.a -lm

@stale

This comment has been minimized.

@stale stale bot added the wontfix Issue won't be fixed label Nov 18, 2021
@thunder-coding thunder-coding added bug report Something is not working properly not stale and removed wontfix Issue won't be fixed labels Nov 19, 2021
@thunder-coding
Copy link
Member

clang seems to now incorrectly try linking to shared library

$ clang x.c -fsanitize=thread $PREFIX/lib/clang/13.0.0/lib/android/libclang_rt.tsan-aarch64-android.a
ld.lld: error: cannot open /data/data/com.termux/files/usr/lib/clang/13.0.0/lib/android/libclang_rt.tsan-aarch64-android.so: No such file or directory
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

Probably some problem due to we just changed the default linker to ld.lld ?

@Grimler91
Copy link
Member Author

@buttaface do you have any guess why it looks for libclang_rt.tsan-aarch64-android.so as in above comment?

@finagolfin
Copy link
Member

It's probably required to actually use the thread sanitizer, which is not implemented for Android yet, android/ndk#1041. This has nothing to do with lld, as clang chooses the libraries to link against.

I guess this never worked before, but might once they finish that work upstream.

@Grimler91
Copy link
Member Author

Aha, closing this then since it is not really a bug with our clang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something is not working properly
Projects
None yet
Development

No branches or pull requests

5 participants