From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Emacs build fails [MSYS2/MINGW64] Date: Mon, 29 Apr 2019 12:38:02 -0700 Organization: UCLA Computer Science Department Message-ID: <60bbd1ea-e7dc-c056-5298-7d7ee95e0031@cs.ucla.edu> References: <1443630449.1251981.1556465864402@mail.libero.it> <6790fa0c-6544-df50-b4f1-a77ca0daea1f@cs.ucla.edu> <1118604098.1569315.1556538785729@mail.libero.it> <83imuwual4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------B476CA2E1789EFEAF49DAF5B" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="258632"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 Cc: angelo.g0@libero.it, emacs-devel@gnu.org To: Eli Zaretskii , martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 29 21:38:55 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hLC74-00156i-GI for ged-emacs-devel@m.gmane.org; Mon, 29 Apr 2019 21:38:54 +0200 Original-Received: from localhost ([127.0.0.1]:34287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLC73-0004w8-Dc for ged-emacs-devel@m.gmane.org; Mon, 29 Apr 2019 15:38:53 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLC6M-0004vo-0U for emacs-devel@gnu.org; Mon, 29 Apr 2019 15:38:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLC6K-0002R3-Oc for emacs-devel@gnu.org; Mon, 29 Apr 2019 15:38:09 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:38256) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hLC6I-0002Og-MU; Mon, 29 Apr 2019 15:38:06 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9FAC81618B5; Mon, 29 Apr 2019 12:38:04 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id DYTHrhEOV17I; Mon, 29 Apr 2019 12:38:03 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 435CE1618C0; Mon, 29 Apr 2019 12:38:03 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fvCQwL2XwfGz; Mon, 29 Apr 2019 12:38:03 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 206EC1618BA; Mon, 29 Apr 2019 12:38:03 -0700 (PDT) Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl KAl8KYDZzbDNCQGEbpY3efZIvPdeI+FWQN4W+kghy+P6au6PrIIhYraeua7XDdb2LS1en3Ss mE3QjqfRqI/A2ue8JMwsvXe/WK38Ezs6x74iTaqI3AFH6ilAhDqpMnd/msSESNFt76DiO1ZK QMr9amVPknjfPmJISqdhgB1DlEdw34sROf6V8mZw0xfqT6PKE46LcFefzs0kbg4GORf8vjG2 Sf1tk5eU8MBiyN/bZ03bKNjNYMpODDQQwuP84kYLkX2wBxxMAhBxwbDVZudzxDZJ1C2VXujC OJVxq2kljBM9ETYuUGqd75AW2LXrLw6+MuIsHFAYAgRr7+KcwDgBAfwhPBYX34nSSiHlmLC+ KaHLeCLF5ZI2vKm3HEeCTtlOg7xZEONgwzL+fdKo+D6SoC8RRxJKs8a3sVfI4t6CnrQzvJbB n6gxdgCu5i29J1QCYrCYvql2UyFPAK+do99/1jOXT4m2836j1wARAQABzSBQYXVsIEVnZ2Vy dCA8ZWdnZXJ0QGNzLnVjbGEuZWR1PsLBfgQTAQIAKAUCTIByZAIbAwUJEswDAAYLCQgHAwIG FQgCCQoLBBYCAwECH In-Reply-To: <83imuwual4.fsf@gnu.org> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:236032 Archived-At: This is a multi-part message in MIME format. --------------B476CA2E1789EFEAF49DAF5B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 4/29/19 7:53 AM, Eli Zaretskii wrote: > see, for example, the comments by Florian > Weimer in this GCC bug report: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88793 Those comments don't invalidate all uses of __attribute__ ((cold)) in Emacs. Florian says that in cold functions on some platforms, strlen on large (5000-byte) strings can be as much as 60 times slower due to questionable optimizations in GCC that are currently being rethought . However, if the functions currently marked 'cold' in Emacs are called so rarely (at least on such large strings) that the performance cost (factor of 60 for rarely-used code) is outweighed by the performance benefit (small factor of improvement in commonly-used code), then from a performance viewpoint it's still preferable to mark these functions 'cold'. > the GCC manual indicates that marking a function as 'cold' > causes that function to be optimized for size, and we already know > that GCC 8.x has at least one bug with -Os used together with -O2, The GCC bug report says that the bug can also occur with -O2, and can occur without __attribute__ ((cold)). So it's not as simple as saying "__attribute__ ((cold)) is buggy". > I think we have way too many functions marked with this > attribute. Functions like wrong_type_argument or Fthrow or > Fabort_recursive_edit or Fsignal or error or Ftop_level -- do they > really fit the below description? It should be purely a performance issue. For example, on my platform (x86-64, GCC 8.3.1, -O2, Fedora 29) after inlining, Emacs has 1066 static calls to wrong_type_argument, and with __attribute__ ((cold)) all these calling sites can be optimized. In bytecode.c this causes GCC to move wrong_type_argument calls to a cold section of the text, which means the bytecode interpreter should run faster for all the usual branch-prediction and icache reasons. I measured the effect of __attribute__ ((cold)) (including both costs and benefits) as improving overall performance of a big benchmark ('make compile-always') by 1.3% on my platform. This test included all the roughly 50 functions currently marked as cold in Emacs. Although I can imagine that removing __attribute__ ((cold)) from some of these functions would not hurt overall performance significantly, I didn't think it worth the time to investigate which ones. That is, I didn't investigate marking a smaller set of functions. If someone wants to do that work then I expect that we should be able to remove markings from some of these functions without affecting performance significantly. > if we leave it in the > sources, we should disable it for MinGW, it seems. Yes, that sounds like a good idea. I installed the attached patch. It would be good to know what the actual bug is (it's possible that it's not a compiler bug at all, but is a portability bug in Emacs), but that's less urgent. --------------B476CA2E1789EFEAF49DAF5B Content-Type: text/x-patch; name="0001-Disable-__attribute__-cold-on-MinGW.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Disable-__attribute__-cold-on-MinGW.patch" >From aaf33358e79e0210f2e8dab17fd8a33ac97383b9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 29 Apr 2019 12:27:04 -0700 Subject: [PATCH] Disable __attribute__ ((cold)) on MinGW * src/conf_post.h (ATTRIBUTE_COLD) [__MINGW32__]: Define to empty on this platform. --- src/conf_post.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/conf_post.h b/src/conf_post.h index 7699d2c95b..4af1ba9331 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -59,7 +59,7 @@ along with GNU Emacs. If not, see . */ into the same 1-, 2-, or 4-byte allocation unit in the MinGW builds. It was also needed to port to pre-C99 compilers, although we don't care about that any more. */ -#if NS_IMPL_GNUSTEP || defined(__MINGW32__) +#if NS_IMPL_GNUSTEP || defined __MINGW32__ typedef unsigned int bool_bf; #else typedef bool bool_bf; @@ -225,7 +225,9 @@ extern void _DebPrint (const char *fmt, ...); extern char *emacs_getenv_TZ (void); extern int emacs_setenv_TZ (char const *); -#if __has_attribute (cold) +/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at + . */ +#if __has_attribute (cold) && !defined __MINGW32__ # define ATTRIBUTE_COLD __attribute__ ((cold)) #else # define ATTRIBUTE_COLD -- 2.20.1 --------------B476CA2E1789EFEAF49DAF5B--