-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Allow overriding USE_COMPILER_TLS (formerly HAS_COMPILER_TLS). #1726
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
Conversation
This is useful, for example, for targets where glibc has deadlock issues with its built-in TLS implementation.
Travis failures seem to get apt-get install issues...? |
Travis has been a bit unstable lately, restarting the failed jobs usually works. |
Not sure if that define gets passed through the Makefiles automatically, and perhaps USE_COMPILER_TLS should default to 0 on glibc systems ? (Is there any major advantage in using compiler vs pthreads tls where both are available ? I think so far we simply do not know if the lockups are limited to glibc, or if musl etc are similarly affected) |
Actually, this whole thing is a bit fishy, I'm going to respond on the other thread. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added 2 comments about possible redefinition of USE_COMPILER_TLS in case of android and macos targets.
@@ -501,17 +502,18 @@ static const int allocation_block_size = BUFFER_SIZE + sizeof(struct alloc_t); | |||
#if defined(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \ | |||
defined(__NDK_MINOR__) && \ | |||
((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1))) | |||
#undef HAS_COMPILER_TLS | |||
#define USE_COMPILER_TLS 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: possible redefinition of USE_COMPILER_TLS
as __clang__
is checked and will cause that define to be set to 1 at line 478.
#endif | ||
|
||
/* Versions of XCode before 8 did not properly support TLS */ | ||
#if defined(__apple_build_version__) && __apple_build_version__ < 8000042 | ||
#undef HAS_COMPILER_TLS | ||
#define USE_COMPILER_TLS 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to have this condition match while also have a previous one match ?
This would mean a previous line (like 478) does #define USE_COMPILER_TLS 1
and then this one redefine it to 0 causing a compiler warning or error.
Maybe just add a #undef USE_COMPILER_TLS
before this line.
I've compiled this patch and indeed, the build system need a modification to pass around --- a/Makefile.system
+++ b/Makefile.system
@@ -1016,6 +1016,10 @@ ifdef USE_SIMPLE_THREADED_LEVEL3
CCOMMON_OPT += -DUSE_SIMPLE_THREADED_LEVEL3
endif
+ifdef USE_COMPILER_TLS
+CCOMMON_OPT += -DUSE_COMPILER_TLS=$(USE_COMPILER_TLS)
+endif
+
ifndef SYMBOLPREFIX
SYMBOLPREFIX =
endif
Also, to try harder if the deadlock might occurs or not, I've made a small C test program that does a bunch of dlopen and dlclose and check in gdb if it runs or not (easy to see as gdb will show whenever a thread is created): #include <dlfcn.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
while(1) {
void* handle = dlopen(argv[1], RTLD_NOW);
if(handle == 0) {
printf("Can't open openblas: %s\n", dlerror());
return 1;
}
dlclose(handle);
}
return 0;
} And this patch + the additional change on the build system to support USE_COMPILER_TLS fix the deadlock. The full patch is here: https://salsa.debian.org/science-team/openblas/blob/e51b3b26641901a5a93247ef9bb9dbdddc82cfae/debian/patches/0008-Allow-overriding-USE_COMPILER_TLS-formerly-HAS_COMPI.patch
|
We should probably pass this over in favor if #1739. |
That, and the issue referenced in the PR description was closed 6 years ago. I'm not even sure that a build config option to change TLS handling is desirable - it's one more variation to test, and it's better to properly fix TLS issues if there are any left in 2024 (many projects use thread-local storage, and it's a hard necessity usually - just turning it off isn't really an option). Probably best to close this PR? |
Both these PRs have been cherry-picked for improvements ages ago, I had only kept them open for reference. If you think they should be closed to make the PR list look nicer, this can be done. |
Ah if they're merged, I would indeed close them. |
This is useful, for example, for targets where glibc has deadlock issues with its built-in TLS implementation, as described in #1720.