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.
This commit is contained in:
sisyphus 2023-11-20 14:49:59 +11:00 committed by Karl Williamson
parent 7bb9a11330
commit f276fe5ce5
4 changed files with 20 additions and 0 deletions

View File

@ -790,6 +790,7 @@ Simon Schubert <corecode@fs.ei.tum.de> Simon 'corecode' Schubert <corecode@fs.ei
Sisyphus <sisyphus@cpan.org> <sisyphus359@gmail.com>
Sisyphus <sisyphus@cpan.org> Sisyphus <sisyphus1@optusnet.com.au>
Sisyphus <sisyphus@cpan.org> sisyphus <sisyphus1@optusnet.com.au>
Sisyphus <sisyphus@cpan.org> sisyphus <sisyphus359@gmail.com>
Sisyphus <sisyphus@cpan.org> sisyphus <sisyphus@cpan.org>
Slaven Rezic <slaven@rezic.de> <slaven.rezic@berlin.de>
Slaven Rezic <slaven@rezic.de> eserte@vran.herceg.de <eserte@vran.herceg.de>

View File

@ -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

View File

@ -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" }
}
}

15
win32/configure/rt.c Normal file
View File

@ -0,0 +1,15 @@
/*
Print the default runtime. $Config{libc}
will be set to this specified value.
*/
#include <stdio.h>
#include <stddef.h>
int main(void) {
#if defined(_UCRT)
printf("-lucrt\n");
#else
printf("-lmsvcrt\n");
#endif
return 0;
}