Bug 97284 - internal compiler error: 'global_options' are modified in local context
Summary: internal compiler error: 'global_options' are modified in local context
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Martin Liška
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-04 11:27 UTC by fdlbxtqi
Modified: 2021-01-12 13:05 UTC (History)
4 users (show)

See Also:
Host: Ubuntu-20.04 lts. Linux GCC11
Target: Ubuntu-20.04 lts. Linux GCC11
Build: GCC11
Known to work:
Known to fail:
Last reconfirmed: 2020-10-05 00:00:00


Attachments
Output of gcc -E (438.83 KB, application/gzip)
2021-01-12 08:29 UTC, Ville Voutilainen
Details
Output of --verbose (2.25 KB, application/gzip)
2021-01-12 09:20 UTC, Ville Voutilainen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description fdlbxtqi 2020-10-04 11:27:53 UTC
This happens when I build qtbase.

/usr/local/lib/gcc/x86_64-pc-linux-gnu/11.0.0/include/pmmintrin.h:129:9: internal compiler error: 'global_options' are modified in local context
  129 | #pragma GCC pop_options
      |         ^~~
g++ -c -include .pch/Qt5Core -pipe -O3 -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -Wno-format-overflow -D_REENTRANT -fPIC -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_USING_NAMESPACE -DQT_NO_FOREACH -DQFLOAT16_INCLUDE_FAST -DELF_INTERPRETER=\"/lib64/ld-linux-x86-64.so.2\" -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/corelib -I. -Iglobal -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/3rdparty/md5 -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/3rdparty/md4 -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/3rdparty/sha3 -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/3rdparty -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/3rdparty/double-conversion/include -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/3rdparty/harfbuzz/src -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/3rdparty/forkfd -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/3rdparty/tinycbor/src -I.rcc -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/include -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/include/QtCore -I../../include -I../../include/QtCore -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/include/QtCore/5.15.1 -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/include/QtCore/5.15.1/QtCore -I../../include/QtCore/5.15.1 -I../../include/QtCore/5.15.1/QtCore -I.moc -I.tracegen -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/mkspecs/linux-g++ -o .obj/qrunnable.o /home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/corelib/thread/qrunnable.cpp
0xa28421 cp_parser_pragma
        ../../gcc/gcc/cp/parser.c:44093
0xa28421 cp_parser_pragma
        ../../gcc/gcc/cp/parser.c:44093
0xa5957b cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4793
0xa5957b cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4793
0xa5957b c_parse_file()
        ../../gcc/gcc/cp/parser.c:44152
0xa5957b c_parse_file()
        ../../gcc/gcc/cp/parser.c:44152
0xb76cdd c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1188
0xb76cdd c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1188
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
make[2]: *** [Makefile:22373: .obj/qendian.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:22979: .obj/qfloat16.o] Error 1
0xf75bdb cl_optimization_compare(gcc_options*, gcc_options*)
        /home/cqwrteur/myhome/gcc_build/gcc/options-save.c:11304
0xb790dd handle_pragma_pop_options
        ../../gcc/gcc/c-family/c-pragma.c:1093
0xa28421 cp_parser_pragma
        ../../gcc/gcc/cp/parser.c:44093
0xa5957b cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4793
0xa5957b c_parse_file()
        ../../gcc/gcc/cp/parser.c:44152
0xb76cdd c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1188
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
make[2]: *** [Makefile:23464: .obj/qrandom.o] Error 1
In file included from /usr/local/lib/gcc/x86_64-pc-linux-gnu/11.0.0/include/immintrin.h:33,
                 from /home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/include/QtCore/5.15.1/QtCore/private/../../../../../src/corelib/tools/qsimd_p.h:191,
                 from /home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/include/QtCore/5.15.1/QtCore/private/qsimd_p.h:1,
                 from /home/cqwrteur/qt/qtbase-everywhere-src-5.15.1/src/corelib/global/qlogging.cpp:61:
/usr/local/lib/gcc/x86_64-pc-linux-gnu/11.0.0/include/pmmintrin.h:129:9: internal compiler error: 'global_options' are modified in local context
  129 | #pragma GCC pop_options
      |         ^~~
0xf75bdb cl_optimization_compare(gcc_options*, gcc_options*)
        /home/cqwrteur/myhome/gcc_build/gcc/options-save.c:11304
0xb790dd handle_pragma_pop_options
        ../../gcc/gcc/c-family/c-pragma.c:1093
0xa28421 cp_parser_pragma
        ../../gcc/gcc/cp/parser.c:44093
0xa5957b cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4793
0xa5957b c_parse_file()
        ../../gcc/gcc/cp/parser.c:44152
0xb76cdd c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1188
Please submit a full bug report,
Comment 1 Martin Liška 2020-10-05 06:23:29 UTC
Please provide a pre-processed soure file (-E option).
Comment 2 Ville Voutilainen 2021-01-12 07:51:05 UTC
(In reply to Martin Liška from comment #1)
> Please provide a pre-processed soure file (-E option).

The output of gcc -E for this build is empty, so sure looks like the crash
is in the preprocessor.
Comment 3 Ville Voutilainen 2021-01-12 08:11:00 UTC
..or maybe I'm just too dumb to invoke g++ -E properly, and the rest of the options confuse the compiler.
Comment 4 Ville Voutilainen 2021-01-12 08:29:16 UTC
Created attachment 49943 [details]
Output of gcc -E
Comment 5 Martin Liška 2021-01-12 09:13:20 UTC
Still can't reproduce it.
Please send me also output of --verbose.
Comment 6 Ville Voutilainen 2021-01-12 09:20:05 UTC
Created attachment 49946 [details]
Output of --verbose
Comment 7 Ville Voutilainen 2021-01-12 09:21:50 UTC
(In reply to Martin Liška from comment #5)
> Still can't reproduce it.
> Please send me also output of --verbose.

Yeah, I fed that output to g++, and then it compiles just fine. But when it's in the actual build with all the -MD -MT -MF flags, it doesn't. Those are, btw, in case it's of any help,
-MD -MT qtbase/qmake/CMakeFiles/qmake.dir/__/src/corelib/global/qendian.cpp.o -MF qtbase/qmake/CMakeFiles/qmake.dir/__/src/corelib/global/qendian.cpp.o.d -o qtbase/qmake/CMakeFiles/qmake.dir/__/src/corelib/global/qendian.cpp.o
Comment 8 Ville Voutilainen 2021-01-12 09:28:13 UTC
Also, you can just try the actual build, if you follow
https://wiki.qt.io/Building_Qt_6_from_Git
Comment 9 Martin Liška 2021-01-12 09:38:10 UTC
(In reply to Ville Voutilainen from comment #8)
> Also, you can just try the actual build, if you follow
> https://wiki.qt.io/Building_Qt_6_from_Git

I tried, but it fails quite fast with:

/home/marxin/bin/gcc/bin/c++ -DHAVE_CONFIG_H -DPCRE2_CODE_UNIT_WIDTH=16 -DPCRE2_DISABLE_JIT -DQT_BOOTSTRAPPED -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_FOREACH -DQT_USE_QSTRINGBUILDER -DQT_VERSION_MAJOR=6 -DQT_VERSION_MINOR=0 -DQT_VERSION_PATCH=1 -DQT_VERSION_STR=\"6.0.1\" -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../qtbase/src/tools/bootstrap/../../3rdparty/pcre2/src -Iqtbase/src/corelib/Core_autogen/include -Iqtbase/include -Iqtbase/include/QtCore -I../qtbase/src/corelib -Iqtbase/src/corelib -Iqtbase/src/corelib/global -I../qtbase/src/corelib/../3rdparty/tinycbor/src -Iqtbase/include/QtCore/6.0.1 -Iqtbase/include/QtCore/6.0.1/QtCore -I../qtbase/src/corelib/../3rdparty/forkfd -Iqtbase/src/corelib/.rcc -I../qtbase/mkspecs/linux-g++ -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -Iqtbase/src/xml/Xml_autogen/include -Iqtbase/include/QtXml -I../qtbase/src/xml -Iqtbase/src/xml -Iqtbase/include/QtXml/6.0.1 -Iqtbase/include/QtXml/6.0.1/QtXml -I../qtbase/src/tools/bootstrap/.. -I../qtbase/src/tools/bootstrap/../../3rdparty/tinycbor/src -DNDEBUG -O2 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -ffunction-sections -fdata-sections -Wsuggest-override -std=gnu++17 -MD -MT qtbase/src/tools/bootstrap/CMakeFiles/Bootstrap.dir/__/__/corelib/global/qfloat16.cpp.o -MF qtbase/src/tools/bootstrap/CMakeFiles/Bootstrap.dir/__/__/corelib/global/qfloat16.cpp.o.d -o qtbase/src/tools/bootstrap/CMakeFiles/Bootstrap.dir/__/__/corelib/global/qfloat16.cpp.o -c ../qtbase/src/corelib/global/qfloat16.cpp
In file included from qtbase/include/QtCore/qanystringview.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qstring.h:56,
                 from qtbase/include/QtCore/qstring.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/tools/qhashfunctions.h:44,
                 from qtbase/include/QtCore/qhashfunctions.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/tools/qvarlengtharray.h:47,
                 from qtbase/include/QtCore/qvarlengtharray.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/kernel/qmetatype.h:49,
                 from qtbase/include/QtCore/qmetatype.h:1,
                 from ../qtbase/src/corelib/global/qfloat16.h:45,
                 from ../qtbase/src/corelib/global/qfloat16.cpp:41:
qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qanystringview.h:250:46: error: ‘numeric_limits’ is not a member of ‘std’
  250 |     static constexpr size_t SizeMask = (std::numeric_limits<size_t>::max)() / 4;
      |                                              ^~~~~~~~~~~~~~
qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qanystringview.h:250:67: error: expected primary-expression before ‘>’ token
  250 |     static constexpr size_t SizeMask = (std::numeric_limits<size_t>::max)() / 4;
      |                                                                   ^
qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qanystringview.h:250:70: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  250 |     static constexpr size_t SizeMask = (std::numeric_limits<size_t>::max)() / 4;
      |                                                                      ^~~
      |                                                                      std::max
In file included from /home/marxin/bin/gcc/include/c++/11.0.0/algorithm:62,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/global/qglobal.h:126,
                 from qtbase/include/QtCore/qglobal.h:1,
                 from ../qtbase/src/corelib/global/qfloat16.h:44,
                 from ../qtbase/src/corelib/global/qfloat16.cpp:41:
/home/marxin/bin/gcc/include/c++/11.0.0/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from qtbase/include/QtCore/qanystringview.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qstring.h:56,
                 from qtbase/include/QtCore/qstring.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/tools/qhashfunctions.h:44,
                 from qtbase/include/QtCore/qhashfunctions.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/tools/qvarlengtharray.h:47,
                 from qtbase/include/QtCore/qvarlengtharray.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/kernel/qmetatype.h:49,
                 from qtbase/include/QtCore/qmetatype.h:1,
                 from ../qtbase/src/corelib/global/qfloat16.h:45,
                 from ../qtbase/src/corelib/global/qfloat16.cpp:41:
qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qanystringview.h:253:46: error: ‘numeric_limits’ is not a member of ‘std’
  253 |     static constexpr size_t TypeMask = (std::numeric_limits<size_t>::max)() & ~SizeMask;
      |                                              ^~~~~~~~~~~~~~
qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qanystringview.h:253:67: error: expected primary-expression before ‘>’ token
  253 |     static constexpr size_t TypeMask = (std::numeric_limits<size_t>::max)() & ~SizeMask;
      |                                                                   ^
qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qanystringview.h:253:70: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  253 |     static constexpr size_t TypeMask = (std::numeric_limits<size_t>::max)() & ~SizeMask;
      |                                                                      ^~~
      |                                                                      std::max
In file included from /home/marxin/bin/gcc/include/c++/11.0.0/algorithm:62,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/global/qglobal.h:126,
                 from qtbase/include/QtCore/qglobal.h:1,
                 from ../qtbase/src/corelib/global/qfloat16.h:44,
                 from ../qtbase/src/corelib/global/qfloat16.cpp:41:
/home/marxin/bin/gcc/include/c++/11.0.0/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from qtbase/include/QtCore/qanystringview.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qstring.h:56,
                 from qtbase/include/QtCore/qstring.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/tools/qhashfunctions.h:44,
                 from qtbase/include/QtCore/qhashfunctions.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/tools/qvarlengtharray.h:47,
                 from qtbase/include/QtCore/qvarlengtharray.h:1,
                 from qtbase/include/QtCore/../../../../qtbase/src/corelib/kernel/qmetatype.h:49,
                 from qtbase/include/QtCore/qmetatype.h:1,
                 from ../qtbase/src/corelib/global/qfloat16.h:45,
                 from ../qtbase/src/corelib/global/qfloat16.cpp:41:
qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qanystringview.h:254:28: error: non-constant condition for static assertion
  254 |     static_assert(TypeMask == (Latin1Flag|TwoByteCodePointFlag));
      |                   ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qanystringview.h:264:20: error: enumerator value for ‘Latin1’ is not an integer constant
  264 |         Latin1   = Latin1Flag,
      |                    ^~~~~~~~~~
qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qanystringview.h:265:20: error: enumerator value for ‘Utf16’ is not an integer constant
  265 |         Utf16    = TwoByteCodePointFlag,
      |                    ^~~~~~~~~~~~~~~~~~~~
qtbase/include/QtCore/../../../../qtbase/src/corelib/text/qanystringview.h:266:20: error: enumerator value for ‘Unused’ is not an integer constant
  266 |         Unused   = TypeMask,
      |                    ^~~~~~~~
Comment 10 Ville Voutilainen 2021-01-12 11:12:58 UTC
Right - that's the Qt bug I'm hoping to fix, but I don't get far because of the ICE. :) The libstdc++ headers have been reorganized, so Qt's expectations that numeric_limits is available without including <limits> are no longer valid with GCC 11.
Comment 11 Martin Liška 2021-01-12 11:37:41 UTC
Good, I placed a couple of '#include <limits>' and I can reproduce it now.
Thanks for the report.
Comment 12 Martin Liška 2021-01-12 11:58:24 UTC
So it's caused by PCH:

$ cat qt.ii
[empty]

$ cat q.ii
#pragma GCC pch_preprocess "cmake_pch.hxx.gch"
#pragma GCC push_options
#pragma GCC target ""
#pragma GCC pop_options

$ g++ -x c++-header qt.ii -o cmake_pch.hxx.gch && g++ q.ii -c
q.ii:4:9: internal compiler error: ‘global_options’ are modified in local context
    4 | #pragma GCC pop_options
      |         ^~~
0x115df28 cl_optimization_compare(gcc_options*, gcc_options*)
	/dev/shm/objdir/gcc/options-save.c:15271
0xcbc30e handle_pragma_pop_options
	/home/marxin/Programming/gcc/gcc/c-family/c-pragma.c:1092
0xcbcdb7 c_invoke_pragma_handler(unsigned int)
	/home/marxin/Programming/gcc/gcc/c-family/c-pragma.c:1515
0xb346ad cp_parser_pragma
	/home/marxin/Programming/gcc/gcc/cp/parser.c:45062
0xb693ab cp_parser_toplevel_declaration
	/home/marxin/Programming/gcc/gcc/cp/parser.c:14096
0xb693ab cp_parser_translation_unit
	/home/marxin/Programming/gcc/gcc/cp/parser.c:4936
0xb693ab c_parse_file()
	/home/marxin/Programming/gcc/gcc/cp/parser.c:45121
0xcb4669 c_common_parse_file()
	/home/marxin/Programming/gcc/gcc/c-family/c-opts.c:1211
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 13 Martin Liška 2021-01-12 12:22:07 UTC
I've got a patch candidate, testing right now.
Comment 14 GCC Commits 2021-01-12 13:04:45 UTC
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:e91910d3576eeac714c93ec25ea3b15012007903

commit r11-6612-ge91910d3576eeac714c93ec25ea3b15012007903
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Jan 12 13:20:18 2021 +0100

    options: properly compare string arguments
    
    Similarly to 7f967bd2a7ba156ede3fbb147e66dea5fb7137a6, we need to
    compare string with strcmp.
    
    gcc/ChangeLog:
    
            PR c++/97284
            * optc-save-gen.awk: Compare also n_target_save vars with
            strcmp.
Comment 15 Martin Liška 2021-01-12 13:05:29 UTC
Fixed.