From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id F09323858D20 for ; Tue, 30 Apr 2024 21:12:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F09323858D20 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 F09323858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714511553; cv=none; b=cTjmXf9rfEPs1FXZa7Z9oEg4bW7ruWVkKVhYwDQgpL0Bxuyr7tbOUaaAYse8udfphMnwwVTTlNo1NlTPNIcsiuEHjaKBnV6LeGxDsYef/hmvKdofwRkC+qoy+8U0aELbDvip6vjMTCuHxDfFz/k/Y7+cjo4eEUDiZTANOZqpPnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714511553; c=relaxed/simple; bh=NFrJu4yU4V/v0Mor9lHvLUHVvSlWZEQcPj+nLpiaDFg=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=d/lViKc5gNcHrmCZHZzZewA8siXA18Z8QJHO/1qkOtf5FB9XQXV68Mg8cCEUecT3z/NIKjXJzx52W7mZYFb9SH0dxj7aNGn1nmB+apyY70OwJvqLsdl6EK/yydZc/r3uaEFg6KOpd3rs7V/CoMnsbUAdIZVD152enolpu3mHIhw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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-out1.suse.de (Postfix) with ESMTPS id C4B413431D; Tue, 30 Apr 2024 21:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1714511550; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a+xkFNW3VnZ1Z3wCgrT7pSRheL6g/xQIWNYTSE8q0bg=; b=omwEBV/tNE7dYttZ0yQpEitfzHbttpqV4R/qpt27y1Cl0LUZoyCVHvnX1nPhwCUaQLQCKY vYv2kP/RTj+oK28ufPvZcJfHa5a8FULcJlaRVOMfe8PDlu3P9PUxIRSZImwVYqHokd/6qb SEVStbxtXIrms4+6Pl/rBMqfwBOd0n8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1714511550; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a+xkFNW3VnZ1Z3wCgrT7pSRheL6g/xQIWNYTSE8q0bg=; b=ZUXW0GfBabGFdO90xFzIzPeqXiy/kyCUIislf0Ixh1NGFft5GQd+sdCL03mivrJJoTeTAo qjzS4j2NWbS4kkDQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1714511550; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a+xkFNW3VnZ1Z3wCgrT7pSRheL6g/xQIWNYTSE8q0bg=; b=omwEBV/tNE7dYttZ0yQpEitfzHbttpqV4R/qpt27y1Cl0LUZoyCVHvnX1nPhwCUaQLQCKY vYv2kP/RTj+oK28ufPvZcJfHa5a8FULcJlaRVOMfe8PDlu3P9PUxIRSZImwVYqHokd/6qb SEVStbxtXIrms4+6Pl/rBMqfwBOd0n8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1714511550; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a+xkFNW3VnZ1Z3wCgrT7pSRheL6g/xQIWNYTSE8q0bg=; b=ZUXW0GfBabGFdO90xFzIzPeqXiy/kyCUIislf0Ixh1NGFft5GQd+sdCL03mivrJJoTeTAo qjzS4j2NWbS4kkDQ== 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 B6F32137BA; Tue, 30 Apr 2024 21:12:30 +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 EQVrLL5eMWaRPwAAD6G6ig (envelope-from ); Tue, 30 Apr 2024 21:12:30 +0000 From: Martin Jambor To: Jakub Jelinek Cc: GCC Patches , Michal Jires , Gerald Pfeifer Subject: Re: [wwwdocs] Porting-to-14: Mention new pragma GCC Target behavior In-Reply-To: References: User-Agent: Notmuch/0.38.2 (https://notmuchmail.org) Emacs/29.3 (x86_64-suse-linux-gnu) Date: Tue, 30 Apr 2024 23:12:30 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCPT_COUNT_THREE(0.00)[4] X-Spam-Score: -4.30 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 Thu, Apr 25 2024, Jakub Jelinek wrote: > On Thu, Apr 25, 2024 at 02:34:22PM +0200, Martin Jambor wrote: >> when looking at a package build issue with GCC 14, Michal Jire=C5=A1 not= ed a >> different behavior of pragma GCC Target. This snippet tries to describe >> the gist of the problem. I have left it in the C section even though it >> is not really C specific, but could not think of a good name for a new >> section for it. Ideas (and any other suggestions for improvements) >> welcome, of course. > > The change was more subtle. > We used to define/undefine the ISA macros in C in GCC 13 and older as wel= l, > but only when using integrated preprocessor during compilation, > so it didn't work that way with -save-temps or separate -E and -S/-c > steps. > While in C++ it behaved as if the define/undefines aren't done at all > (they were done, but after preprocessing/lexing everything, so didn't > affect anything). > In GCC 14, it behaves in C++ the same as in C in older versions, and > additionally they are defined/undefined also when using separate > preprocessing, in both C and C++. > I see, thanks for the correction. Would the following then perhaps describe the situation accurately? Note that I have moved the whole thing to C++ section because it seems porting issues in C because of this are quite unlikely. Michal, I assume that the file where this issue happened was written in C++, right? Martin diff --git a/htdocs/gcc-14/porting_to.html b/htdocs/gcc-14/porting_to.html index c825a68e..1e67b0b3 100644 --- a/htdocs/gcc-14/porting_to.html +++ b/htdocs/gcc-14/porting_to.html @@ -514,6 +514,51 @@ be included explicitly when compiling with GCC 14: =20 +

Pragma GCC Target now affects preprocessor sy= mbols

+ +

+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 integrated preprocessor during compilation but not when +preprocessor was invoked as a separate step or when using -save-temps. +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, +functions 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 called. */
+  #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 would be to remember +whether pop_options needs to be performed in a new +user-defined macro. + + + =20