Skip to content

Commit

Permalink
Identify default mingw runtime (mingw builds only).
Browse files Browse the repository at this point in the history
See #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.
  • Loading branch information
sisyphus authored and khwilliamson committed Nov 22, 2023
1 parent 7bb9a11 commit f276fe5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .mailmap
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions win32/config_sh.PL
Expand Up @@ -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" }
}
}

Expand Down
15 changes: 15 additions & 0 deletions win32/configure/rt.c
@@ -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;
}

0 comments on commit f276fe5

Please sign in to comment.