This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
avoid mis-mangled name references on threaded C++ builds
authorTony Cook <tony@develop-help.com>
Mon, 4 Apr 2016 02:03:58 +0000 (12:03 +1000)
committerTony Cook <tony@develop-help.com>
Mon, 4 Apr 2016 02:03:58 +0000 (12:03 +1000)
g++ on recent darwin appears to be clang++ in disguise, and so
supports the TSA decorations, but the wrappers we define don't have
explicit extern "C" linkage (which perlapi.h does have).

Under C++ Time::HiRes wraps its includes in extern "C" { }, and
so references unmangled names for the perl_tsa_mutex_*() wrappers,
but since util.c never sees an extern "C" for those functions it
produces mangled names, causing undefined references in Time::HiRes.

Detected by a smoke run againt a smoke-me branch:

http://www.nntp.perl.org/group/perl.daily-build.reports/2016/03/msg190183.html

Longer term the TSA decorations should probably be probed for in Configure
and the wrapper declarations moved to embed.fnc

perl.h

diff --git a/perl.h b/perl.h
index 0468a1c..fd716c3 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -3192,10 +3192,10 @@ typedef pthread_key_t   perl_key;
  * TODO: however, some platforms are starting to get these clang
  * thread safety annotations for pthreads, for example FreeBSD.
  * Do we need a way to a bypass these wrappers? */
-int perl_tsa_mutex_lock(perl_mutex* mutex)
+EXTERN_C int perl_tsa_mutex_lock(perl_mutex* mutex)
   PERL_TSA_ACQUIRE(*mutex)
   PERL_TSA_NO_TSA;
-int perl_tsa_mutex_unlock(perl_mutex* mutex)
+EXTERN_C int perl_tsa_mutex_unlock(perl_mutex* mutex)
   PERL_TSA_RELEASE(*mutex)
   PERL_TSA_NO_TSA;
 #endif