The perl_tsa_mutex_lock Symbol Cannot Be Found
Error Information
Can't load 'xxx.so' for module threads: xxx.so: undefined symbol: perl_tsa_mutex_lock at xxx
Problem
The /usr/lib64/perl5/CORE/perl.h file contains the following definitions:
##if ...
defined(__clang__)
...
## define PERL_TSA__(x) __attribute__((x))
## define PERL_TSA_ACTIVE
##else
## define PERL_TSA__(x) /* No TSA, make TSA attributes no-ops. */
## undef PERL_TSA_ACTIVE
##endif
##ifdef PERL_TSA_ACTIVE
EXTERN_C int perl_tsa_mutex_lock(perl_mutex* mutex)
PERL_TSA_ACQUIRE(*mutex)
PERL_TSA_NO_TSA;
EXTERN_C int perl_tsa_mutex_unlock(perl_mutex* mutex)
PERL_TSA_RELEASE(*mutex)
PERL_TSA_NO_TSA;
##endif##endif
The mutex-related symbols used by Clang are perl_tsa_* symbols with a thread safety flag. However, libperl.so does not contain the symbols. As a result, link errors occur.
Solution
- Use libperl.so that contains perl_tsa_* symbols (during compilation of libperl.so, add the USE_ITHREADS and I_PTHREAD macros).
- Delete the predefined macro __clang__ as follows:
clang -U__clang__ ...
Parent topic: Other Compatibility Problems