public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Yong <jyong@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1882] Add MinGW option -mcrtdll= for choosing C RunTime DLL library Date: Fri, 16 Jun 2023 10:16:20 +0000 (GMT) [thread overview] Message-ID: <20230616101620.8A60E385C6D5@sourceware.org> (raw) https://gcc.gnu.org/g:453cb585f0f8673a5d69d1b420ffd4b3f53aca00 commit r14-1882-g453cb585f0f8673a5d69d1b420ffd4b3f53aca00 Author: Pali Rohár <pali@kernel.org> Date: Wed Jun 14 18:09:17 2023 +0200 Add MinGW option -mcrtdll= for choosing C RunTime DLL library It adjust preprocess, compile and link flags, which allows to change default -lmsvcrt library by another provided by MinGW runtime. gcc/ChangeLog: * config/i386/mingw-w64.h (CPP_SPEC): Adjust for -mcrtdll=. (REAL_LIBGCC_SPEC): New define. * config/i386/mingw.opt: Add mcrtdll= * config/i386/mingw32.h (CPP_SPEC): Adjust for -mcrtdll=. (REAL_LIBGCC_SPEC): Adjust for -mcrtdll=. (STARTFILE_SPEC): Adjust for -mcrtdll=. * doc/invoke.texi: Add mcrtdll= documentation. Signed-off-by: Jonathan Yong <10walls@gmail.com> Diff: --- gcc/config/i386/mingw-w64.h | 22 +++++++++++++++++++++- gcc/config/i386/mingw.opt | 4 ++++ gcc/config/i386/mingw32.h | 28 ++++++++++++++++++++++++---- gcc/doc/invoke.texi | 24 +++++++++++++++++++++++- 4 files changed, 72 insertions(+), 6 deletions(-) diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h index 3a21cec3f8c..0146ed4f793 100644 --- a/gcc/config/i386/mingw-w64.h +++ b/gcc/config/i386/mingw-w64.h @@ -25,7 +25,27 @@ along with GCC; see the file COPYING3. If not see #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \ "%{municode:-DUNICODE} " \ "%{" SPEC_PTHREAD1 ":-D_REENTRANT} " \ - "%{" SPEC_PTHREAD2 ":-U_REENTRANT} " + "%{" SPEC_PTHREAD2 ":-U_REENTRANT} " \ + "%{mcrtdll=crtdll*:-U__MSVCRT__ -D__CRTDLL__} " \ + "%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \ + "%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \ + "%{mcrtdll=msvcrt40*:-D__MSVCRT_VERSION__=0x400} " \ + "%{mcrtdll=msvcrt-os*:-D__MSVCRT_VERSION__=0x700} " \ + "%{mcrtdll=msvcr70*:-D__MSVCRT_VERSION__=0x700} " \ + "%{mcrtdll=msvcr71*:-D__MSVCRT_VERSION__=0x701} " \ + "%{mcrtdll=msvcr80*:-D__MSVCRT_VERSION__=0x800} " \ + "%{mcrtdll=msvcr90*:-D__MSVCRT_VERSION__=0x900} " \ + "%{mcrtdll=msvcr100*:-D__MSVCRT_VERSION__=0xA00} " \ + "%{mcrtdll=msvcr110*:-D__MSVCRT_VERSION__=0xB00} " \ + "%{mcrtdll=msvcr120*:-D__MSVCRT_VERSION__=0xC00} " \ + "%{mcrtdll=ucrt*:-D_UCRT} " + +#undef REAL_LIBGCC_SPEC +#define REAL_LIBGCC_SPEC \ + "%{mthreads:-lmingwthrd} -lmingw32 \ + " SHARED_LIBGCC_SPEC " \ + -lmingwex %{!mcrtdll=*:-lmsvcrt} %{mcrtdll=*:-l%*} \ + -lkernel32 " MCFGTHREAD_SPEC #undef STARTFILE_SPEC #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \ diff --git a/gcc/config/i386/mingw.opt b/gcc/config/i386/mingw.opt index 0ae026a66bd..dd66a50aec0 100644 --- a/gcc/config/i386/mingw.opt +++ b/gcc/config/i386/mingw.opt @@ -18,6 +18,10 @@ ; along with GCC; see the file COPYING3. If not see ; <http://www.gnu.org/licenses/>. +mcrtdll= +Target RejectNegative Joined +Preprocess, compile or link with specified C RunTime DLL library. + pthread Driver diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h index 6a55baaa458..a1ee001983a 100644 --- a/gcc/config/i386/mingw32.h +++ b/gcc/config/i386/mingw32.h @@ -89,7 +89,20 @@ along with GCC; see the file COPYING3. If not see #undef CPP_SPEC #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \ "%{" SPEC_PTHREAD1 ":-D_REENTRANT} " \ - "%{" SPEC_PTHREAD2 ": } " + "%{" SPEC_PTHREAD2 ": } " \ + "%{mcrtdll=crtdll*:-U__MSVCRT__ -D__CRTDLL__} " \ + "%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \ + "%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \ + "%{mcrtdll=msvcrt40*:-D__MSVCRT_VERSION__=0x400} " \ + "%{mcrtdll=msvcrt-os*:-D__MSVCRT_VERSION__=0x700} " \ + "%{mcrtdll=msvcr70*:-D__MSVCRT_VERSION__=0x700} " \ + "%{mcrtdll=msvcr71*:-D__MSVCRT_VERSION__=0x701} " \ + "%{mcrtdll=msvcr80*:-D__MSVCRT_VERSION__=0x800} " \ + "%{mcrtdll=msvcr90*:-D__MSVCRT_VERSION__=0x900} " \ + "%{mcrtdll=msvcr100*:-D__MSVCRT_VERSION__=0xA00} " \ + "%{mcrtdll=msvcr110*:-D__MSVCRT_VERSION__=0xB00} " \ + "%{mcrtdll=msvcr120*:-D__MSVCRT_VERSION__=0xC00} " \ + "%{mcrtdll=ucrt*:-D_UCRT} " /* For Windows applications, include more libraries, but always include kernel32. */ @@ -184,11 +197,18 @@ along with GCC; see the file COPYING3. If not see #define REAL_LIBGCC_SPEC \ "%{mthreads:-lmingwthrd} -lmingw32 \ " SHARED_LIBGCC_SPEC " \ - -lmoldname -lmingwex -lmsvcrt -lkernel32 " MCFGTHREAD_SPEC + %{mcrtdll=crtdll*:-lcoldname} %{!mcrtdll=crtdll*:-lmoldname} \ + -lmingwex %{!mcrtdll=*:-lmsvcrt} %{mcrtdll=*:-l%*} \ + -lkernel32 " MCFGTHREAD_SPEC #undef STARTFILE_SPEC -#define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \ - %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \ +#define STARTFILE_SPEC " \ + %{shared|mdll:%{mcrtdll=crtdll*:dllcrt1%O%s}} \ + %{shared|mdll:%{!mcrtdll=crtdll*:dllcrt2%O%s}} \ + %{!shared:%{!mdll:%{mcrtdll=crtdll*:crt1%O%s}}} \ + %{!shared:%{!mdll:%{!mcrtdll=crtdll*:crt2%O%s}}} \ + %{pg:%{mcrtdll=crtdll*:gcrt1%O%s}} \ + %{pg:%{!mcrtdll=crtdll*:gcrt2%O%s}} \ crtbegin.o%s \ %{fvtable-verify=none:%s; \ fvtable-verify=preinit:vtv_start.o%s; \ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 9ecbd32a228..19d8c1c9aa5 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1458,7 +1458,7 @@ See RS/6000 and PowerPC Options. -munroll-only-small-loops -mlam=@var{choice}} @emph{x86 Windows Options} -@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll +@gccoptlist{-mconsole -mcrtdll=@var{library} -mcygwin -mno-cygwin -mdll -mnop-fun-dllimport -mthread -municode -mwin32 -mwindows -fno-set-stack-executable} @@ -34292,6 +34292,28 @@ required for console applications. This option is available for Cygwin and MinGW targets and is enabled by default on those targets. +@opindex mcrtdll +@item -mcrtdll=@var{library} +Preprocess, compile or link with specified C RunTime DLL @var{library}. +This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__} +and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose +start file for CRT @var{library} and link with CRT @var{library}. +Recognized CRT library names for proprocessor are: +@code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40}, +@code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90}, +@code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}. +If this options is not specified then the default MinGW import library +@code{msvcrt} is used for linking and no other adjustment for +preprocessor is done. MinGW import library @code{msvcrt} is just a +symlink to (or a copy of) another MinGW CRT import library +chosen during MinGW compilation. MinGW import library @code{msvcrt-os} +is for Windows system CRT DLL library @code{msvcrt.dll} and +in most cases is the default MinGW import library. +Generally speaking, changing the CRT DLL requires recompiling +the entire MinGW CRT. This option is for experimental and testing +purposes only. +This option is available for MinGW targets. + @opindex mdll @item -mdll This option is available for Cygwin and MinGW targets. It
reply other threads:[~2023-06-16 10:16 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230616101620.8A60E385C6D5@sourceware.org \ --to=jyong@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).