Only define NO_THREAD_SAFE_LOCALE for MSVC plperl when required
authorAndrew Dunstan <andrew@dunslane.net>
Sat, 14 Sep 2024 12:37:08 +0000 (08:37 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Sat, 14 Sep 2024 12:50:44 +0000 (08:50 -0400)
Latest versions of Strawberry Perl define USE_THREAD_SAFE_LOCALE, and we
therefore get a handshake error when building against such instances.
The solution is to perform a test to see if USE_THREAD_SAFE_LOCALE is
defined and only define NO_THREAD_SAFE_LOCALE if it isn't.

Backpatch the meson.build fix back to release 16 and apply the same
logic to Mkvcbuild.pm in releases 12 through 16.

Original report of the issue from Muralikrishna Bandaru.

meson.build
src/tools/msvc/Mkvcbuild.pm

index 56454cc339525403d71ee1eb724ab867db57d726..54451abe1958953ac43a26091afb0338601c400a 100644 (file)
@@ -1060,7 +1060,10 @@ if not perlopt.disabled()
       if cc.get_id() == 'msvc'
         # prevent binary mismatch between MSVC built plperl and Strawberry or
         # msys ucrt perl libraries
-        perl_ccflags += ['-DNO_THREAD_SAFE_LOCALE']
+        perl_v = run_command(perl, '-V').stdout()
+        if not perl_v.contains('USE_THREAD_SAFE_LOCALE')
+          perl_ccflags += ['-DNO_THREAD_SAFE_LOCALE']
+        endif
       endif
     endif
 
index 6a79a0e037d41342a006dbdc1f187f82231edbdd..1dc336a54dae98ac51827badd3dc4515efedc1ad 100644 (file)
@@ -595,7 +595,9 @@ sub mkvcbuild
        push(@perl_embed_ccflags, 'PLPERL_HAVE_UID_GID');
        # prevent binary mismatch between MSVC built plperl and
        # Strawberry or msys ucrt perl libraries
-       push(@perl_embed_ccflags, 'NO_THREAD_SAFE_LOCALE');
+       my $perl_v = `$^X -V 2>&1`;
+       push(@perl_embed_ccflags, 'NO_THREAD_SAFE_LOCALE')
+         unless $perl_v =~ /USE_THREAD_SAFE_LOCALE/;
 
        # Windows offers several 32-bit ABIs.  Perl is sensitive to
        # sizeof(time_t), one of the ABI dimensions.  To get 32-bit time_t,