From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 19D75385E836 for ; Thu, 2 May 2024 21:39:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19D75385E836 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 19D75385E836 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714685964; cv=none; b=gldA63ZEY4p8h18/whbD8rWvOEE7GdWPO+5BPBa/Cz8QMLbUrQX345GlttUaZmYNPCfaHM3GM41wA5B9Egicqqa3k0iGo8UBVBaXnsIE+gZZnyDZ3/CaIMd7yCG58Cuvw1jBIIMvSPS1yYyQihaUOI8vCZbmUg6BjxFqhRc9Z2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714685964; c=relaxed/simple; bh=YDDBjYKc5mZNCieueLpTixcMBXUsJB1JwpQIcW5dots=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=DiP80brvSEILyQtkZJOoYW+5PRePyfCdrKhR0WxLKzTcB5LOqs+bHTXZFB5keI6zEDh0wekldkMdvND5+iDgqgmdAr2F93NFPW4RmuTEH6ufucsDSwuKARdFGpVi194tMT9o0om/Qk7KGLUmah0NVZLGpld3LLWVFy954kcsteg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 824E41FB7B; Thu, 2 May 2024 21:39:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1714685960; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lFzGIwy1hjLTKC3pmo1tEi+MejWIYy1WSiciIvvA1Ms=; b=0piv4i69ZnsdodiZMMQTuIX3jFJmNcyrs5JQs7BH4F6/Ftx0djhGlicVFgJsec+xNw8ih3 eB/6GE53GkhQflVsHbHV3jB0BED8zU1+A2r64oZVDdupnfXla3d/FzMjHH7qKScj5vQKah RCCAmUeJRT9rNL1MSf0J8dsO03wXLG8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1714685960; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lFzGIwy1hjLTKC3pmo1tEi+MejWIYy1WSiciIvvA1Ms=; b=lDdzHIF28ffkQerpWZKUFWCXEOXUGTTnuqbCEFhj+eh8NWtdXiPaUOx9IYu23srwdUmVnN LRs8Dkb1OKaSj7DQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=0piv4i69; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=lDdzHIF2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1714685960; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lFzGIwy1hjLTKC3pmo1tEi+MejWIYy1WSiciIvvA1Ms=; b=0piv4i69ZnsdodiZMMQTuIX3jFJmNcyrs5JQs7BH4F6/Ftx0djhGlicVFgJsec+xNw8ih3 eB/6GE53GkhQflVsHbHV3jB0BED8zU1+A2r64oZVDdupnfXla3d/FzMjHH7qKScj5vQKah RCCAmUeJRT9rNL1MSf0J8dsO03wXLG8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1714685960; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lFzGIwy1hjLTKC3pmo1tEi+MejWIYy1WSiciIvvA1Ms=; b=lDdzHIF28ffkQerpWZKUFWCXEOXUGTTnuqbCEFhj+eh8NWtdXiPaUOx9IYu23srwdUmVnN LRs8Dkb1OKaSj7DQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6F5AB1386E; Thu, 2 May 2024 21:39:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id dxEMGggINGYnZgAAD6G6ig (envelope-from ); Thu, 02 May 2024 21:39:20 +0000 From: Martin Jambor To: Gerald Pfeifer Cc: Jakub Jelinek , GCC Patches , Michal Jires Subject: Re: [wwwdocs] Porting-to-14: Mention new pragma GCC Target behavior In-Reply-To: <1d9a90f2-399d-ddbb-8e76-09382eaae264@pfeifer.com> References: <1d9a90f2-399d-ddbb-8e76-09382eaae264@pfeifer.com> User-Agent: Notmuch/0.38.2 (https://notmuchmail.org) Emacs/29.3 (x86_64-suse-linux-gnu) Date: Thu, 02 May 2024 23:39:14 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.21 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 824E41FB7B X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.21 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MIME_HTML_ONLY(1.20)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MX_GOOD(-0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[suse.cz:+]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:~] X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: Hi, On Wed, May 01 2024, Gerald Pfeifer wrote: > On Tue, 30 Apr 2024, Martin Jambor wrote: >> +

Pragma GCC Target now affects preprocessor symbols

> > Note the id: should be "gcc-target-pragma", though I even suggest to > simplify and say "target-pragma". > >> +The behavior of pragma GCC Target and specifically how it affects ISA > > Seconding Jakub's > > "And here as well, perhaps even #pragma GCC target." > >> +macros has changed in GCC 14. In GCC 13 and older, the GCC >> +target pragma defined and undefined corresponding ISA macros in >> +C when using integrated preprocessor during compilation but not when > > "...the integrated preprocessor..." > >> +preprocessor was invoked as a separate step or when using -save-temps. > > "...the preprocessor..." > > and -save-temps, or better "the -save-temps > option". > >> +This can lead to different behavior, especially in C++. For example, >> +functions the C++ snippet below will be (silently) compiled for an >> +incorrect instruction set by GCC 14. > > "functions" above looks like it's extraneous and should be skipped? > >> + /* With GCC 14, __AVX2__ here will always be defined and pop_options >> + never called. */ >> + #if ! __AVX2__ >> + #pragma GCC pop_options >> + #endif > > Maybe a bit subtle, I would not say a #pragma is called; how about invoked > or activated? > >> +

>> +The fix in this case would be to remember >> +whether pop_options needs to be performed in a new >> +user-defined macro. > > "The fix in this case is to remember" (or "...remembering...") > Thanks for your suggestions, this is what I am going to commit in a moment. Martin diff --git a/htdocs/gcc-14/porting_to.html b/htdocs/gcc-14/porting_to.html index c825a68e..a20d82c2 100644 --- a/htdocs/gcc-14/porting_to.html +++ b/htdocs/gcc-14/porting_to.html @@ -514,6 +514,48 @@ be included explicitly when compiling with GCC 14: +

Pragma GCC target now affects preprocessor symbols

+ +

+The behavior of pragma GCC target and specifically how it affects ISA +macros has changed in GCC 14. In GCC 13 and older, the GCC +target pragma defined and undefined corresponding ISA macros in +C when using the integrated preprocessor during compilation but not +when the preprocessor was invoked as a separate step or when using +the -save-temps option. In C++ the ISA macro definitions +were performed in a way which did not have any actual effect. + +In GCC 14 C++ behaves like C with integrated preprocessing in earlier +versions. Moreover, in both languages ISA macros are defined and +undefined as expected when preprocessing separately from compilation. + +

+This can lead to different behavior, especially in C++. For example, +a part of the C++ snippet below will be (silently) compiled for an +incorrect instruction set by GCC 14. + +

+  #if ! __AVX2__
+  #pragma GCC push_options
+  #pragma GCC target("avx2")
+  #endif
+
+  /* Code to be compiled for AVX2. */
+
+  /* With GCC 14, __AVX2__ here will always be defined and pop_options
+  never invoked. */
+  #if ! __AVX2__
+  #pragma GCC pop_options
+  #endif
+
+  /* With GCC 14, all following functions will be compiled for AVX2
+  which was not intended. */
+
+ +

+The fix in this case is to remember whether pop_options +needs to be performed in a new user-defined macro. +