[Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #9 from Jakub Jelinek --- (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
[Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299 --- Comment #8 from Gwenole Beauchesne --- 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.
[Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299 Sam James changed: What|Removed |Added CC||sjames at gcc dot gnu.org Target Milestone|--- |14.0 --- Comment #7 from Sam James --- (In reply to Lewis Hyatt from comment #6) > Fixed for GCC 14. (Setting milestone, thanks!)
[Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299 Lewis Hyatt changed: What|Removed |Added Resolution|--- |FIXED Status|NEW |RESOLVED --- Comment #6 from Lewis Hyatt --- Fixed for GCC 14.
[Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299 --- Comment #5 from CVS Commits --- The master branch has been updated by Lewis Hyatt : https://gcc.gnu.org/g:8697d3a1dcf32750a3b9dc007586eb5f9ba5f17a commit r14-4967-g8697d3a1dcf32750a3b9dc007586eb5f9ba5f17a Author: Lewis Hyatt 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.
[Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299 Lewis Hyatt changed: What|Removed |Added CC||lhyatt at gcc dot gnu.org --- Comment #4 from Lewis Hyatt --- Patch submitted for review: https://gcc.gnu.org/pipermail/gcc-patches/2023-August/625924.html
[Bug preprocessor/87299] #pragma GCC target behaves differently when using -save-temps
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87299 Andrew Pinski changed: What|Removed |Added Component|middle-end |preprocessor Target||x86_64 --- Comment #3 from Andrew Pinski --- 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).