From: Martin Jambor <mjambor@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Michal Jires <mjires@suse.cz>, Gerald Pfeifer <gerald@pfeifer.com>
Subject: [wwwdocs] Porting-to-14: Mention new pragma GCC Target behavior
Date: Thu, 25 Apr 2024 14:34:22 +0200 [thread overview]
Message-ID: <ri68r11zkmp.fsf@virgil.suse.cz> (raw)
Hello,
when looking at a package build issue with GCC 14, Michal Jireš noted 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.
Otherwise, would this be good to go to the wwwdocs?
Thanks,
Martin
diff --git a/htdocs/gcc-14/porting_to.html b/htdocs/gcc-14/porting_to.html
index c825a68e..ae9a3cde 100644
--- a/htdocs/gcc-14/porting_to.html
+++ b/htdocs/gcc-14/porting_to.html
@@ -490,6 +490,43 @@ in C23.
GCC will probably continue to support old-style function definitions
even once C23 is used as the default language dialect.
+<h4 id="gcc-targte-pragma">Pragma GCC Target now affects preprocessor symbols</h4>
+
+<p>
+The behavior of pragma GCC Target has changed in GCC 14. For example,
+GCC 13 and below defines <code>__AVX2__</code> only when the target
+is specified on the command line. This has been considered <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299">a
+bug</a> and since it was fixed in GCC 14, <code>__AVX2__</code> is now also
+defined with <code>#pragma GCC target("avx2")</code>.
+
+<p>
+Therefore, if macros expand to something like the snippet below,
+functions will be (silently) compiled for an incorrect instruction
+set.
+
+<pre>
+ #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. */
+</pre>
+
+<p>
+The fix in this case would be to remember
+whether <code>pop_options</code> needs to be performed in a new
+user-defined macro.
+
<h2 id="cxx">C++ language issues</h2>
<h3 id="header-dep-changes">Header dependency changes</h3>
next reply other threads:[~2024-04-25 12:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-25 12:34 Martin Jambor [this message]
2024-04-25 12:41 ` Jakub Jelinek
2024-04-30 21:12 ` Martin Jambor
2024-04-30 21:30 ` Jakub Jelinek
2024-05-01 14:05 ` Gerald Pfeifer
2024-05-02 21:39 ` Martin Jambor
2024-05-03 23:37 ` Gerald Pfeifer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ri68r11zkmp.fsf@virgil.suse.cz \
--to=mjambor@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=gerald@pfeifer.com \
--cc=mjires@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).