From f276fe5ce5cea2b3d1f6b72d42b95bee2bbdb3e7 Mon Sep 17 00:00:00 2001 From: sisyphus Date: Mon, 20 Nov 2023 14:49:59 +1100 Subject: [PATCH] Identify default mingw runtime (mingw builds only). See https://github.com/Perl/perl5/pull/21612 for context. Basically, by setting $Config{libc} to the default runtime (which will be either -lucrt or -lmsvcrt) we enable perl scripts to determine the identity of the default runtime. --- .mailmap | 1 + MANIFEST | 1 + win32/config_sh.PL | 3 +++ win32/configure/rt.c | 15 +++++++++++++++ 4 files changed, 20 insertions(+) create mode 100644 win32/configure/rt.c diff --git a/.mailmap b/.mailmap index 17e969aa2362..9caf76b993c9 100644 --- a/.mailmap +++ b/.mailmap @@ -790,6 +790,7 @@ Simon Schubert Simon 'corecode' Schubert Sisyphus Sisyphus Sisyphus sisyphus +Sisyphus sisyphus Sisyphus sisyphus Slaven Rezic Slaven Rezic eserte@vran.herceg.de diff --git a/MANIFEST b/MANIFEST index fbaa2aad4dd7..a35db6f11c94 100644 --- a/MANIFEST +++ b/MANIFEST @@ -6710,6 +6710,7 @@ win32/config_H.gc Win32 config header (MinGW build) win32/config_h.PL Perl code to convert Win32 config.sh to config.h win32/config_H.vc Win32 config header (Visual C++ build) win32/config_sh.PL Perl code to update Win32 config.sh from Makefile +win32/configure/rt.c identify default runtime win32/create_perllibst_h.pl creates perllibst.h file for inclusion from perllib.c win32/distclean.bat Remove _ALL_ files not listed here in MANIFEST win32/fcrypt.c crypt() implementation diff --git a/win32/config_sh.PL b/win32/config_sh.PL index ea4c302743bf..5b77c06c64bd 100644 --- a/win32/config_sh.PL +++ b/win32/config_sh.PL @@ -155,6 +155,9 @@ if (exists $opt{cc}) { } elsif ($opt{cc} =~ /\bgcc\b/) { chomp($opt{gccversion} = `$opt{cc} -dumpversion`); + chomp($opt{libc} = `$opt{cc} -o rt.exe configure/rt.c 1>nul 2>&1 && rt`); + if(-e 'rt.exe') { unlink 'rt.exe' } # rt.exe no longer needed + else { die "Failed to identify default runtime" } } } diff --git a/win32/configure/rt.c b/win32/configure/rt.c new file mode 100644 index 000000000000..7a819946fbd8 --- /dev/null +++ b/win32/configure/rt.c @@ -0,0 +1,15 @@ +/* + Print the default runtime. $Config{libc} + will be set to this specified value. +*/ +#include +#include + +int main(void) { +#if defined(_UCRT) + printf("-lucrt\n"); +#else + printf("-lmsvcrt\n"); +#endif + return 0; +}