From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id D83F63852231 for ; Sun, 4 Dec 2022 12:16:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D83F63852231 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x52d.google.com with SMTP id l11so12281456edb.4 for ; Sun, 04 Dec 2022 04:16:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=fUwkXDLUaN4bpnsM7W6LL/5I6r/TPKW6dpcGHO3MW2w=; b=hrhT0C8uOehZGcUuj5s/rTvIiUYQdVU0yFVApXZ912xJ52KE5atlgyifAH2XZaFz+/ qrmC4aOmh8otRfirE/UPEWzc86qglE9tLc6S6crRijQZ8BCmOqZ+FNi9sH3rs9FyxGtK pWFIOty1o0ZTdNQUwouThwLelHzOYMN2lQgWKTpsc0/Hwse/+/WUnaWiL3QZZppWtr9a 9Njmb9KCPMb38jEkHStCsVLQrWV0lMNZFvBnuyko1lQpV5dMMAq0ctnpRzpwmOu32NDo rqH/9wHMyFz0veu2VjYytBCk19q6kvlIBLssFnE9o3CAFLVYQ69kg9sAmDnGX8dehipZ 1oCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fUwkXDLUaN4bpnsM7W6LL/5I6r/TPKW6dpcGHO3MW2w=; b=5FoCv4bE7DHrG5niMaxYjgwj9v3h6k5y2jXzugrYPpJ5Ip+mMXQP8wiw6Doyx1PjBR ENCcdqfAfwoYKpDcCNlrUpil4bAXctyy2i51YFHyjm4HO0yuRvstH0hnZ55/m2boC+3s inhbjcMOUigsyqDagRixs+eunD+rTs4cMh8dDt96gfS6+IWVu84QsuLU1XcJiu9jJoZr I/Qr6xSXr/an9uzj1BjM0wGOJeM9wdTxqyrXRPDpTbiF0GXqdbmEb+2AIRUN7A2mPpZx z/g9Bdx7JbJq2XHf+WoImMOv4wFUgnqopipltXnCtUn2g106F1aWROExUfBUqmKNqEaY esEQ== X-Gm-Message-State: ANoB5pnM5cCcruXaE+wuBxjUBjseLs4zv+aEIQbRADDsCU927UJDtmXz 39PTtw+yGaMFjqgReaeq1czbuRh+JVs= X-Google-Smtp-Source: AA0mqf6e70sp9xD1cSBV5i68rwxsZNT3fEuou7bpPgG5PuBJRttk4yqXLMeOQZ1gANQ9wEht6dREIw== X-Received: by 2002:a05:6402:1857:b0:46b:19aa:cfaa with SMTP id v23-20020a056402185700b0046b19aacfaamr29736638edy.229.1670156185437; Sun, 04 Dec 2022 04:16:25 -0800 (PST) Received: from pali ([2a02:2b88:6:5cc6::2f]) by smtp.gmail.com with ESMTPSA id p7-20020a17090653c700b007c0aa8eaf47sm4389712ejo.116.2022.12.04.04.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Dec 2022 04:16:24 -0800 (PST) Date: Sun, 4 Dec 2022 13:16:22 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: gcc@gcc.gnu.org Cc: mingw-w64-public@lists.sourceforge.net Subject: Re: gcc parameter -mcrtdll= for choosing Windows C RunTime DLL library Message-ID: <20221204121622.qsaxlp2245h6pxz2@pali> References: <20221120125348.a6xh7kxmvrimse72@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221120125348.a6xh7kxmvrimse72@pali> User-Agent: NeoMutt/20180716 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sunday 20 November 2022 13:53:48 Pali Rohár wrote: > Hello! I would like to propose a new parameter for gcc: -mcrtdll= to > allow specifying against which Windows C Runtime library should be > binary linked. On Windows there are more crt libraries and currently gcc > links to libmsvcrt.a which is in most cases symlink to libmsvcrt-os.a > (but can be changed, e.g. during mingw-w64 building). mingw-w64 project > already builds import .a library for every crt dll library (from the old > crtdll.dll up to the new ucrtbase.dll), so it is ready for usage. Simple > patch for gcc which implements -mcrtdll parameter is below. Note that on > internet are other very similar patches for -mcrtdll= parameters and > some are parts of custom mingw32 / mingw-w64 gcc builds. What do you > think? Could gcc have "official" support for -mcrtdll= parameter? Hello! I would like to ask gcc people, what do you think about such proposed -mcrtdll= parameter? There are lot of unofficial gcc patches which implement this -mcrtdll= parameter and this parameter is present in more gcc forks. So it looks like that this parameter is useful for more people. Here is list of some URLs which I found: https://sourceforge.net/p/mingw/mailman/message/5692227/ https://sourceforge.net/p/mingw-w64/mailman/message/36030107/ https://github.com/jmeubank/tdm-gcc-src/blob/tdm-patches.public/_PATCHES/mcrtdll.patch https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-gcc/0006-Windows-New-feature-to-allow-overriding.patch https://github.com/nak5124/build_env/blob/master/gcc_build/patches/gcc/0020-MinGW-w64-Define-__MSVCRT_VERSION__.patch But I have not found any discussion about it on gcc mailing list. > > --- gcc/config/i386/cygming.opt 2022-02-06 21:00:05.377656896 +0100 > +++ gcc/config/i386/cygming.opt 2022-02-06 21:04:06.690995944 +0100 > @@ -22,6 +22,10 @@ mconsole > Target RejectNegative > Create console application. > > +mcrtdll= > +Target RejectNegative Joined > +Link with specified C RunTime DLL library. > + > mdll > Target RejectNegative > Generate code for a DLL. > --- gcc/config/i386/mingw32.h 2022-01-16 17:28:31.157999097 +0100 > +++ gcc/config/i386/mingw32.h 2022-01-16 17:36:03.552856726 +0100 > @@ -95,7 +95,20 @@ along with GCC; see the file COPYING3. > #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. */ > @@ -185,11 +198,16 @@ along with GCC; see the file COPYING3. > #define REAL_LIBGCC_SPEC \ > "%{mthreads:-lmingwthrd} -lmingw32 \ > " SHARED_LIBGCC_SPEC " \ > - -lmoldname -lmingwex -lmsvcrt -lkernel32" > + -lmoldname -lmingwex %{!mcrtdll=*:-lmsvcrt} %{mcrtdll=*:-l%*} -lkernel32" > > #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; \ >