From d8cd8d0211dcd606a3753a6b3c36c19a7b1672dc Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Wed, 5 Aug 2015 23:36:13 +0100
Subject: [PATCH 05/19] master Windows: New feature to allow overriding
 -lmsvcrt

Added in support of the MinGW-w64 WIP feature "agile mscvrt dll" where
a process' loaded msvc runtime is used by a newly loaded DLL rather than
always using msvcrt.dll
---
 gcc/config/i386/cygming.opt | 3 +++
 gcc/config/i386/mingw32.h   | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/cygming.opt b/gcc/config/i386/cygming.opt
index a9074bf..e1d89e2 100644
--- a/gcc/config/i386/cygming.opt
+++ b/gcc/config/i386/cygming.opt
@@ -22,6 +22,9 @@ mconsole
 Target RejectNegative
 Create console application.
 
+mcrtdll=
+Target RejectNegative Joined
+
 mdll
 Target RejectNegative
 Generate code for a DLL.
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
index 4ac5f68..f875e7b 100644
--- a/gcc/config/i386/mingw32.h
+++ b/gcc/config/i386/mingw32.h
@@ -165,7 +165,7 @@ along with GCC; see the file COPYING3.  If not see
 #define REAL_LIBGCC_SPEC \
   "%{mthreads:-lmingwthrd} -lmingw32 \
    " SHARED_LIBGCC_SPEC " \
-   -lmoldname -lmingwex -lmsvcrt"
+   -lmoldname -lmingwex %{!mcrtdll=*:-lmsvcrt} %{mcrtdll=*:-l%*}"
 
 #undef STARTFILE_SPEC
 #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
-- 
2.7.1

