public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
       [not found] <bug-87299-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-11 19:41 ` pinskia at gcc dot gnu.org
  2023-08-01  2:26 ` lhyatt at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-11 19:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |preprocessor
             Target|                            |x86_64

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The problem here is while "#pragma GCC target("avx512f")" is processed during C
front-end and communicates back to the preprocessor but while doing -save-temps
(-E), the processing is not done so tokenizing happens without the processing
of the pragma.  The same issue happens with the C++ front-end where the
tokenizer happens before the processing of the #pragma even (there is a bug
about that too).

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
       [not found] <bug-87299-4@http.gcc.gnu.org/bugzilla/>
  2021-12-11 19:41 ` [Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps pinskia at gcc dot gnu.org
@ 2023-08-01  2:26 ` lhyatt at gcc dot gnu.org
  2023-10-27  8:39 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2023-08-01  2:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299

Lewis Hyatt <lhyatt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lhyatt at gcc dot gnu.org

--- Comment #4 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
Patch submitted for review:
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/625924.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
       [not found] <bug-87299-4@http.gcc.gnu.org/bugzilla/>
  2021-12-11 19:41 ` [Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps pinskia at gcc dot gnu.org
  2023-08-01  2:26 ` lhyatt at gcc dot gnu.org
@ 2023-10-27  8:39 ` cvs-commit at gcc dot gnu.org
  2023-10-27  8:40 ` lhyatt at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-27  8:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Lewis Hyatt <lhyatt@gcc.gnu.org>:

https://gcc.gnu.org/g:8697d3a1dcf32750a3b9dc007586eb5f9ba5f17a

commit r14-4967-g8697d3a1dcf32750a3b9dc007586eb5f9ba5f17a
Author: Lewis Hyatt <lhyatt@gmail.com>
Date:   Fri Oct 27 04:32:50 2023 -0400

    preprocessor: c++: Support `#pragma GCC target' macros [PR87299]

    `#pragma GCC target' is not currently handled in preprocess-only mode
(e.g.,
    when running gcc -E or gcc -save-temps). As noted in the PR, this means
that
    if the target pragma defines any macros, those macros are not effective in
    preprocess-only mode. Similarly, such macros are not effective when
    compiling with C++ (even when compiling without -save-temps), because C++
    does not process the pragma until after all tokens have been obtained from
    libcpp, at which point it is too late for macro expansion to take place.

    Since r13-1544 and r14-2893, there is a general mechanism to handle pragmas
    under these conditions as well, so resolve the PR by using the new "early
    pragma" support.

    toplev.cc required some changes because the target-specific handlers for
    `#pragma GCC target' may call target_reinit(), and toplev.cc was not
expecting
    that function to be called in preprocess-only mode.

    I added some additional testcases from the PR for x86. The other targets
    that support `#pragma GCC target' (aarch64, arm, nios2, powerpc, s390)
    already had tests verifying that the pragma sets macros as expected; here I
    have added -save-temps versions of some of them, to test that they now work
    in preprocess-only mode as well.

    gcc/c-family/ChangeLog:

            PR preprocessor/87299
            * c-pragma.cc (init_pragma): Register `#pragma GCC target' and
            related pragmas in preprocess-only mode, and enable early handling.
            (c_reset_target_pragmas): New function refactoring code from...
            (handle_pragma_reset_options): ...here.
            * c-pragma.h (c_reset_target_pragmas): Declare.

    gcc/cp/ChangeLog:

            PR preprocessor/87299
            * parser.cc (cp_lexer_new_main): Call c_reset_target_pragmas ()
            after preprocessing is complete, before starting compilation.

    gcc/ChangeLog:

            PR preprocessor/87299
            * toplev.cc (no_backend): New static global.
            (finalize): Remove argument no_backend, which is now a
            static global.
            (process_options): Likewise.
            (do_compile): Likewise.
            (target_reinit): Don't do anything in preprocess-only mode.
            (toplev::main): Adapt to no_backend change.
            (toplev::finalize): Likewise.

    gcc/testsuite/ChangeLog:

            PR preprocessor/87299
            * c-c++-common/pragma-target-1.c: New test.
            * c-c++-common/pragma-target-2.c: New test.
            * g++.target/i386/pr87299-1.C: New test.
            * g++.target/i386/pr87299-2.C: New test.
            * gcc.target/i386/pr87299-1.c: New test.
            * gcc.target/i386/pr87299-2.c: New test.
            * gcc.target/s390/target-attribute/tattr-2b.c: New test.
            * gcc.target/aarch64/pragma_cpp_predefs_1b.c: New test.
            * gcc.target/arm/pragma_arch_attribute_1b.c: New test.
            * gcc.target/nios2/custom-fp-2b.c: New test.
            * gcc.target/powerpc/float128-3b.c: New test.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
       [not found] <bug-87299-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2023-10-27  8:39 ` cvs-commit at gcc dot gnu.org
@ 2023-10-27  8:40 ` lhyatt at gcc dot gnu.org
  2023-12-06  8:35 ` sjames at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2023-10-27  8:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299

Lewis Hyatt <lhyatt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #6 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
Fixed for GCC 14.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
       [not found] <bug-87299-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2023-10-27  8:40 ` lhyatt at gcc dot gnu.org
@ 2023-12-06  8:35 ` sjames at gcc dot gnu.org
  2023-12-06  8:40 ` gb.devel at gmail dot com
  2024-04-05 18:16 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-12-06  8:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sjames at gcc dot gnu.org
   Target Milestone|---                         |14.0

--- Comment #7 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Lewis Hyatt from comment #6)
> Fixed for GCC 14.

(Setting milestone, thanks!)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
       [not found] <bug-87299-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2023-12-06  8:35 ` sjames at gcc dot gnu.org
@ 2023-12-06  8:40 ` gb.devel at gmail dot com
  2024-04-05 18:16 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: gb.devel at gmail dot com @ 2023-12-06  8:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299

--- Comment #8 from Gwenole Beauchesne <gb.devel at gmail dot com> ---
Hi, can you please consider a backport to GCC 13 branch? The patch applies
cleanly as is, but causes regressions that are further fixed with e45c564e (for
PR pch/112319).

GCC 13 is the first and most complete compiler for modern C++ (>= C++20)
support and readily available, or soon available, as the system compiler for
major distributions. This is useful to C++ projects that (debately) use
multiple wrappers for SIMD support (xsimd, simde, mipp, etc.), but without
correct support for runtime dispatching. So, using #pragma GCC target is a
handy solution for that.

Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
       [not found] <bug-87299-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2023-12-06  8:40 ` gb.devel at gmail dot com
@ 2024-04-05 18:16 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-05 18:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Gwenole Beauchesne from comment #8)
> Hi, can you please consider a backport to GCC 13 branch? The patch applies
> cleanly as is, but causes regressions that are further fixed with e45c564e
> (for PR pch/112319).
> 
> GCC 13 is the first and most complete compiler for modern C++ (>= C++20)
> support and readily available, or soon available, as the system compiler for
> major distributions. This is useful to C++ projects that (debately) use
> multiple wrappers for SIMD support (xsimd, simde, mipp, etc.), but without
> correct support for runtime dispatching. So, using #pragma GCC target is a
> handy solution for that.

No, this certainly shouldn't be backported, it is a significant behavior change
which is something that shouldn't be done on release branches.
E.g. it breaks simdutf, see https://github.com/simdutf/simdutf/issues/391

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-05 18:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-87299-4@http.gcc.gnu.org/bugzilla/>
2021-12-11 19:41 ` [Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps pinskia at gcc dot gnu.org
2023-08-01  2:26 ` lhyatt at gcc dot gnu.org
2023-10-27  8:39 ` cvs-commit at gcc dot gnu.org
2023-10-27  8:40 ` lhyatt at gcc dot gnu.org
2023-12-06  8:35 ` sjames at gcc dot gnu.org
2023-12-06  8:40 ` gb.devel at gmail dot com
2024-04-05 18:16 ` jakub at gcc dot gnu.org

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).