From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from m15-112.126.com (m15-112.126.com [220.181.15.112]) by sourceware.org (Postfix) with ESMTPS id 92F1C383F85E for ; Wed, 6 May 2020 12:45:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 92F1C383F85E Received: from [192.168.1.2] (unknown [101.86.244.84]) by smtp2 (Coremail) with SMTP id DMmowADn6_djsbJehg6sCg--.40900S2; Wed, 06 May 2020 20:45:25 +0800 (CST) Subject: Re: [Mingw-w64-public] mingw-w64 and __attribute__((format(printf))) issue To: =?UTF-8?Q?Martin_Storsj=c3=b6?= , "mingw-w64-public@lists.sourceforge.net" Cc: "gcc-help@gcc.gnu.org" References: <84f2a94f-0d73-fe05-78c6-bd64c1f8ee76@126.com> From: Liu Hao Openpgp: preference=signencrypt Autocrypt: addr=lh_mouse@126.com; keydata= mQINBFvNzjsBEADgRSHQwFcRdrKpmUxYOyjJKduTZgGP90O0ZrSUzqjuM5x/0NpjgV3PRk7S OWMJAQ3u66jyG/iZnMzpIca+gdObCtaqHPG5NyOwlUjlQcRI7tTaJWGjwVTco2np6z1msAkE L4dRCwVaud5U8LoukcQcuBiCrsdx2Sp9QUR33lUEfQajks0HKFvHHqdooHiflEY89lLpcM18 r+VMXviPrBPBoYesvYWSWLEDKnAkxl+y2KjPFnCUYFh4eHlh2GndUGPZMCYqu8t8EJcfl/Zp nRkHjRDhqwNHHj2JCTO2U12H25G0C2pvlbeZNTDnTp7m0YGsnp6RO4sFYxQE0f4rxqA1K7BP gBdlqdOJO/CasCMNeGqjP1lcSIJ38/EBLR/GyM7yNwT9P1oowy3KE+w0NlSrWxLU4zs873Ev SKx33xcmyVkZyZjMWA+OFt4LM57fK/CwJc3C0yFYJsutpP0espCr2IJLGEcP/srL71SRFZ9I nZBnV3uyWPxWDvjB0tDLmXCi1I7Uprz607yCjxEiHlclk1KSrRizRL/XJNbz3TxqbiwRjp6+ u2OJZv1j8XGb6XCWdEEyQYS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9LbYc9OZhjfNTJ0q5K00JvqOHPLYertlF3uscbA+KKhvtZ3x8w o2xAthMRzUGlYy+lHGJ8zUE7PKkeD2rBYfMs7mId7EQ8UNc6ZwvmL0WtZhTiXpmJNAtWBWeG D7zfJr1Z5i/s7tOMyAi6e8J9l5pt6IPa//uByXAGcdOzPADdAxlBLPkJStS/m2RFfDTbdWiZ Flo+wGMdJXNbeLQ4ykdbLbkeTBCH9TSQVmH34GlTT/O6N8xQJF7PSp+Sn0w= Message-ID: <11517505-9ad5-14b4-9101-6011a557f52d@126.com> Date: Wed, 6 May 2020 20:45:20 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5SmrrsY8HtqHlSxZCpdAtK4UX9dTMhs20" X-CM-TRANSID: DMmowADn6_djsbJehg6sCg--.40900S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCr1UZry5AFWUZw15Kr4Uurg_yoW5XF1xpF y3K3Wqkr4kGFWIyrnxJF4Y9F1fJFs5tFWUWF1kJ3yIya98ua4IyrsFkF4Yvr9xCr4Skw4Y qr4Utr18WFn0vFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jT_M3UUUUU= X-Originating-IP: [101.86.244.84] X-CM-SenderInfo: 5okbz0xxvhqiyswou0bp/1tbi2QUcRlpD-OVRJQAAsy X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 May 2020 12:45:35 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --5SmrrsY8HtqHlSxZCpdAtK4UX9dTMhs20 Content-Type: multipart/mixed; boundary="Gpp7BR1U5oqB0l23JR0BUBR8VSVFYlbpE"; protected-headers="v1" From: Liu Hao To: =?UTF-8?Q?Martin_Storsj=c3=b6?= , "mingw-w64-public@lists.sourceforge.net" Cc: "gcc-help@gcc.gnu.org" Message-ID: <11517505-9ad5-14b4-9101-6011a557f52d@126.com> Subject: Re: [Mingw-w64-public] mingw-w64 and __attribute__((format(printf))) issue References: <84f2a94f-0d73-fe05-78c6-bd64c1f8ee76@126.com> In-Reply-To: --Gpp7BR1U5oqB0l23JR0BUBR8VSVFYlbpE Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable =E5=9C=A8 2020/5/6 18:48, Martin Storsj=C3=B6 =E5=86=99=E9=81=93: >=20 > This is generally the risk of this kind of commit - regardless of how > right/wrong the status quo is, there's _a lot_ of code that relies on i= t > behaving in a specific way, and changing that will certainly run into > minor issues in a lot of places. >=20 As it was I that committed the patch - I thought it should be safe, because 0) G++ has been hardcoding `__USE_MINGW_ANSI_STDIO` for years (see 'bits/os_defines.h'), and 1) MSYS2 has it too (see 'makepkg_mingw64.conf' which affects all packages in C or C++). It was however an oversight that during bootstrapping GCC doesn't use the CPPFLAGS from the build environment, which I think is unusual, as all MSYS2 packages have `__USE_MINGW_ANSI_STDIO`. The hard-coded (?) `printf` attribute expects the MS behavior, which shouldn't be the case, if we were building something that calls functions from libgomp.h directly, despite the fact that it isn't a public header. >> 2. Make GCC treat `format(printf)` as `format(gnu_printf)` if C11 or >> =C2=A0 C++11 is selected, or >=20 > I'm not very keen on that. The compiler should ideally not assume to > much about what the platform headers do in detail, because it limits > what we can change. (If we'd make that change in the compiler, and then= > for another reason end up reverting the commit, we'd have the same issu= e > in reverse.) >=20 Yes I agree. It's pretty bad that the C (but not C++) standard allows users to declare standard functions without including appropriate headers. If someone declare `printf` themselves then they will end up in calling it from MSVCRT, even in C11 mode. >> 3. Replace `format(printf)` with `format(gnu_printf)` in libgomp sourc= e. >=20 > This also kind of hardcodes too much; libgomp in general can't and > shouldn't assume too much about which format kind it uses, unless > libgomp itself hardcodes __USE_MINGW_ANSI_STDIO. Also, the whole > gnu_printf format is something that only GCC supports, not Clang, but I= > guess libgomp is rather GCC specific anyway. >=20 As long as 'libgomp.h' is a private header, it might be fine to change or remove this attribute. > However we do have a define that should expand to the right thing - jus= t > like inttypes.h PRIu64 follows __USE_MINGW_ANSI_STDIO - we have > __MINGW_PRINTF_FORMAT. >=20 > So something like this should work: >=20 > #ifdef __MINGW32__ > #define PRINTF_FORMAT __MINGW_PRINTF_FORMAT > #else > #define PRINTF_FORMAT printf > #endif >=20 > __attribute__((format(PRINTF_FORMAT))) >=20 > Not very pretty, but should work without hardcoding any assumptions > about which format actually is used. >=20 So we end up in patching libgomp source anyway. I will try this tomorrow.= --=20 Best regards, LH_Mouse --Gpp7BR1U5oqB0l23JR0BUBR8VSVFYlbpE-- --5SmrrsY8HtqHlSxZCpdAtK4UX9dTMhs20 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEn9eDGptREvfrWRePQbMyeCIxW8QFAl6ysWAACgkQQbMyeCIx W8R6eQ/+Ppes4e9zrp9H1rRvZuLF4ammEK5p8tdqXFK+I2sX7ynqudjAEYlJ7Aao NsAKRAsI4fe512C9+5A5fyQBilLXgvldmgvv5wqnr8d3hccjJZUzV9zjttZWKwOn pdEZxjiTLUDWIKacheg06tUukZAZZyoGYKIWJd0dWqzalpfyOnj+qQkO6TRRYJgQ U8I8S1ttRjK0sHqNVmEJl4dO6Htx1gukT4V0uGP3tbI/RGEURZwlBxtfqxFvdA+T 4CRFW/1VqdPAN4yttn9nGwV9xuGhCuUa8xbcPDBcRAXt+1mB6HoF7/uLDMy8Lxaf oL9T6B1N8wNvWrAGrn1gHlVefq3JEd0G0dR4x+L16S+0j6kZ2+TBZPTtFNlrSzrI 3tK4TaxpRcTvWLU+l422WwnVgm2qF6KdbX/R0qZrWVXcsJvXULFICIoKqyAl7BFf BWmLyp8xYS9QgOd7IAq2r4LfMavbJhli6Cw3sPbcOWzdj4US1/TXFZlfaZ7FNSk+ CSjOIlkMBj7hvu+0LTuacLmZPS96EmxLlv/LGUhYyn1x4a6+s1ig7uMz5kbT1yvw 27m/0zWC74JZ4TqfurzYpKL0FY2DFmwssWr+PYT9qV/C4i0ciy3NPxvgXV5IdxBY 1ju28KwhOJCyyRF0VHF+WujBRzgYkolM/BJVmZWJeUORuN3iNZE= =wOcP -----END PGP SIGNATURE----- --5SmrrsY8HtqHlSxZCpdAtK4UX9dTMhs20--