From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id F00D239730EC for ; Sun, 20 Nov 2022 15:06:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F00D239730EC 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-x535.google.com with SMTP id x2so13142578edd.2 for ; Sun, 20 Nov 2022 07:06:47 -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=lfa3t6xuN24Ks7jtEyNxPK633NtO/7WSKV3ufZcF8ZM=; b=LlFwW87QZfUxhQpQFwJZn2Ci+dy0Czzb/en4GtvYhs05ofEx8l5AHcoESy76ZwDKX4 ffArG4gF/gECqtdO9lZ6WPffXWeBULyDgM9so4jKjS09jkZ5ShSAR3Z1xF0F2Ruq5IfU tB7DdoX/gS1nhuhtspZUku0cQr0v2tY8Ulu2gjf810aBFfx3W6LBpA6wwBNeAW1pj2CC D52707+Eoety29AuTX/mlLGM5Z5m8iY9C9K94Qqj8aNRKb/3kEumiKmRj8k4nSDzVK2E 0Ye6Qk89Ee/5qrYpjyGJrkOw/IsK7vyBfdTPg32B+//6mlL6juVRo9qYbXt9Rs5fn5qM lFeA== 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=lfa3t6xuN24Ks7jtEyNxPK633NtO/7WSKV3ufZcF8ZM=; b=BOICGjIMMQuXe66lOh0vbr3QgYjTtqFg4LPDJWY0crO6AIZ1id9MahTZqwE9AJQbM6 M23TtHsNJK0fc3QsmlcULF76Rp9UnWu7slxMS8wF/ATHWLYalgxU3n0P8lywsPBgV2u8 tByEexQ1cpVT7kkSLlUnOyLPJgq+vZDDGjYtI4Q8lWH59EUKd9juj3125WtMh+5xdfCX yxfH5F4GrDwzTCzE2LPb5yNWHNz5JO5/gK66LleO0XTf7T/uHNSZuWN0+4aNCGDVCTiD nQ4RWwiocX0pxfRSgcxNrvukqq+/3YLr/xhBE6CO+94fcLgJ7c5erG6CiLo43/D+dXVr qC6g== X-Gm-Message-State: ANoB5pmiUgyhYyjcAiryBJSaLEM7BCAD04Dai9L5ZqN5eUHND3IUH+M9 ES93oP32g2LfBigAKp7cneI= X-Google-Smtp-Source: AA0mqf5p6MBGQmWi5Zc7gHAl5qtfFbbvLW6hC7+7KPTdesLsbs80PAIbMGwY6fBSm9JnA+J+8dEhUw== X-Received: by 2002:a05:6402:2b8b:b0:468:cae8:f5a6 with SMTP id fj11-20020a0564022b8b00b00468cae8f5a6mr12940723edb.263.1668956806756; Sun, 20 Nov 2022 07:06:46 -0800 (PST) Received: from pali ([2a02:2b88:6:5cc6::2f]) by smtp.gmail.com with ESMTPSA id fg7-20020a056402548700b004618a89d273sm4026383edb.36.2022.11.20.07.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 07:06:46 -0800 (PST) Date: Sun, 20 Nov 2022 16:06:45 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: LIU Hao Cc: mingw-w64-public@lists.sourceforge.net, gcc@gcc.gnu.org Subject: Re: [Mingw-w64-public] gcc parameter -mcrtdll= for choosing Windows C RunTime DLL library Message-ID: <20221120150645.lu4c6m3bhrpupwm3@pali> References: <20221120125348.a6xh7kxmvrimse72@pali> <3966ae87-8e0e-3fba-bb3e-4be572c17e04@126.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3966ae87-8e0e-3fba-bb3e-4be572c17e04@126.com> 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 21:36:19 LIU Hao wrote: > 在 2022-11-20 20:53, Pali Rohár 写道: > > 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? > > > > > > It's not enough to just link against the desired library, you will also have > to define `__MSVCRT_VERSION__` accordingly (for UCRT it should be defined as > `0xE00` i.e. 14.0). > > The current status of such mechanism is that both the macro > `__MSVCRT_VERSION__` and the library 'libmsvcrt.a' are determined when > building mingw-w64, configurable by `--with-default-msvcrt=`, so they always > match. > > > [1] https://sourceforge.net/p/mingw-w64/mailman/message/36030072/ Thank you for explaining more details. My simple patch takes this in care and defines also __MSVCRT_VERSION__ to the correct value based on -mcrtdll parameter.