Bug 2043517 - ICE when compiling codeblocks plugin
Summary: ICE when compiling codeblocks plugin
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 36
Hardware: ppc64le
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
Depends On: 2047389
Blocks: PPCTracker
TreeView+ depends on / blocked
Reported: 2022-01-21 12:46 UTC by Dan Horák
Modified: 2022-05-01 05:18 UTC (History)
14 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed:
Type: Bug

Attachments (Terms of Use)
preprocessed source (172.62 KB, application/gzip)
2022-01-21 12:46 UTC, Dan Horák
no flags Details
preprocessed source 2 (415.30 KB, application/gzip)
2022-01-21 16:42 UTC, Dan Horák
no flags Details

System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 104172 0 P2 UNCONFIRMED [9/10/11/12 Regression] ppc64le mangling ICE with -flto -ffat-lto-objects 2022-01-21 21:30:26 UTC

Description Dan Horák 2022-01-21 12:46:30 UTC
Created attachment 1852495 [details]
preprocessed source

Description of problem:
ICE occurs when compiling the HexEditor plugin for Code::Blocks IDE

<mock-chroot> sh-5.1# g++ -DHAVE_CONFIG_H -I. -I../../../../src/include -I/usr/lib64/wx/include/gtk3-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -I../../../../src/include -I../../../../src/sdk/wxscintilla/include -DCB_AUTOCONF -DCB_PRECOMP -DPIC -DTIXML_USE_STL=YES -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -Winvalid-pch -fPIC -fexceptions -c ExpressionPreprocessed.cpp  -fPIC -DPIC -o .libs/ExpressionPreprocessed.o
during RTL pass: final
ExpressionPreprocessed.cpp: In member function ‘Expression::Preprocessed::Preprocessed()’:
ExpressionPreprocessed.cpp:61:5: internal compiler error: Segmentation fault
   61 |     Preprocessed::Preprocessed()
      |     ^~~~~~~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.

Version-Release number of selected component (if applicable):

How reproducible:
100% on ppc64le, haven't checked other arches yet

Comment 1 Dan Horák 2022-01-21 13:59:25 UTC
- x86_64 looks OK
- seems LTO related, removing the LTO flags makes it compile

Comment 2 Dan Horák 2022-01-21 14:01:34 UTC
reproduced with
/usr/libexec/gcc/ppc64le-redhat-linux/12/cc1plus -O2 -fexceptions -g -grecord-gcc-switches -Wall -Werror=format-security -fstack-protector-strong -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -Winvalid-pch -fexceptions -fPIC -flto=auto -ffat-lto-objects < ExpressionPreprocessed.ii

Comment 3 Dan Horák 2022-01-21 14:07:12 UTC
and minimal reproducer is
/usr/libexec/gcc/ppc64le-redhat-linux/12/cc1plus -flto=auto -ffat-lto-objects < ExpressionPreprocessed.ii

Comment 4 Dan Horák 2022-01-21 16:42:42 UTC
Created attachment 1852575 [details]
preprocessed source 2

probably same issue in another project

reproduced by
/usr/libexec/gcc/ppc64le-redhat-linux/12/cc1plus -O2 -flto=auto -ffat-lto-objects < PagePrinter.ii

here either removing -O2 or the LTO options make it pass

the complete error message
<mock-chroot> sh-5.1# g++ -c -pedantic -Wno-long-long -std=c++11 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -IHercStudio -IHercConfiguration -IHercUtilities -IHercPrinter -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtNetwork -I/usr/include/qt5/QtCore -Imoc -Iui -I/usr/lib64/qt5/mkspecs/linux-g++ -o obj/PagePrinter.o HercPrinter/PagePrinter.cpp
HercPrinter/PagePrinter.cpp: In member function ‘virtual void PdfPrinter::setValues(bool)’:
HercPrinter/PagePrinter.cpp:85:24: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
   85 |     mPdf->setPageSizeMM(QSize(mPaperWidth*25.4L, mPaperHeight*25.4L));
      |     ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/qt5/QtGui/QPdfWriter:1,
                 from HercPrinter/PagePrinter.h:33,
                 from HercPrinter/PagePrinter.cpp:1:
/usr/include/qt5/QtGui/qpdfwriter.h:98:10: note: declared here
   98 |     void setPageSizeMM(const QSizeF &size) override;
      |          ^~~~~~~~~~~~~
during RTL pass: final
HercPrinter/PagePrinter.cpp: In member function ‘PagePrinter::PagePrinter(QSharedPointer<Stationery>&, QPainter&)’:
HercPrinter/PagePrinter.cpp:15:1: internal compiler error: Segmentation fault
   15 | PagePrinter::PagePrinter(StationeryPtr &stationery, QPainter &painter) :
      | ^~~~~~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.

Comment 5 Marek Polacek 2022-01-21 17:57:20 UTC
Reproduced, same backtrace as in bug 2043357:

during RTL pass: final
HercPrinter/PagePrinter.cpp: In member function ‘PagePrinter::PagePrinter(QSharedPointer<Stationery>&, QPainter&)’:
HercPrinter/PagePrinter.cpp:15:1: internal compiler error: tree check: expected class ‘type’, have ‘declaration’ (translation_unit_decl) in base_ctor_omit_inherited_parms, at cp/method.cc:568
0x1024ace3 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*)
0x10484f03 tree_class_check
0x10484f03 base_ctor_omit_inherited_parms(tree_node*)
0x1046f7b3 write_method_parms
0x1046fbf3 write_bare_function_type
0x1046fd1b write_encoding
0x104722f3 mangle_decl_string
0x1047251f get_mangled_id
0x104728ff mangle_decl(tree_node*)
0x113f92f3 rs6000_globalize_decl_name
0x113b7c93 globalize_decl
0x113befff assemble_start_function(tree_node*, char const*)
0x10a0670f rest_of_handle_final
0x10a0670f execute

Comment 6 Jakub Jelinek 2022-01-21 21:23:20 UTC
Reduced testcase:
// { dg-do compile { target { powerpc*-*-* && lp64 && le } } }
// { dg-options "-O2 -flto=auto -ffat-lto-objects -mabi=ieeelongdouble" }

struct A { A(int); };
struct B { float b; };
struct C : B { C(); };
C::C() { A(b * 25.4L); }

The bug is in:
/* Create an alias for a mangled name where we have changed the mangling (in
   GCC 8.1, we used U10__float128, and now we use u9__ieee128).  This is called
   via the target hook TARGET_ASM_GLOBALIZE_DECL_NAME.  */

static void
rs6000_globalize_decl_name (FILE * stream, tree decl)
  const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);

  targetm.asm_out.globalize_label (stream, name);
  if (rs6000_passes_ieee128 && name[0] == '_' && name[1] == 'Z')
      tree save_asm_name = DECL_ASSEMBLER_NAME (decl);
      const char *old_name;

      ieee128_mangling_gcc_8_1 = true;
      lang_hooks.set_decl_assembler_name (decl);
      SET_DECL_ASSEMBLER_NAME (decl, save_asm_name);
      ieee128_mangling_gcc_8_1 = false;

      if (strcmp (name, old_name) != 0)
          fprintf (stream, "\t.weak %s\n", old_name);
          fprintf (stream, "\t.set %s,%s\n", old_name, name);

This is just wrong, mangling is only possible before free_lang_data, not after that, everything should be mangled by then.
So, IMHO the backend should note that during mangling that it emitted some u9__ieee128 (when rs6000_mangle_type returns it)
and through some hook should cooperate with the C++ FE to create a mangling alias like the FE creates mangling aliases for -fabi-version*.

Comment 7 Jakub Jelinek 2022-01-25 09:28:30 UTC
https://koji.fedoraproject.org/scratch/jakub/task_81787698/ is a scratch build of gcc that could fix this.

Comment 8 Dan Horák 2022-01-25 12:22:58 UTC
tested with hercstudio (the 2nd case here) and it builds OK, no segfaults

Comment 9 Jakub Jelinek 2022-01-27 10:34:09 UTC
Please retry against gcc-12.0.1-0.3.fc36 and annobin-10.51-2.fc36 now in rawhide.

Comment 10 Dan Horák 2022-01-27 12:28:16 UTC
the original issue went away, but there is a new one

libtool: link: g++  -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/ppc64le-redhat-linux/12/../../../../lib64/crti.o /usr/lib/gcc/ppc64le-redhat-linux/12/crtbeginS.o  .libs/CharacterView.o .libs/DigitView.o .libs/ExpressionExecutor.o .libs/ExpressionParser.o .libs/ExpressionPreprocessed.o .libs/ExpressionTestCases.o .libs/ExpressionTester.o .libs/FileContentBase.o .libs/FileContentBuffered.o .libs/FileContentDisk.o .libs/HexEditLineBuffer.o .libs/HexEditor.o .libs/HexEditPanel.o .libs/HexEditViewBase.o .libs/SearchDialog.o .libs/SelectStoredExpressionDlg.o .libs/TestCasesDlg.o   ../../../sdk/.libs/libcodeblocks.so -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgobject-2.0 -lglib-2.0 -ltinyxml -lsquirrel -lsqstdlib -lwx_gtk3u_aui-3.0 -lwx_gtk3u_propgrid-3.0 -lwx_gtk3u_richtext-3.0 -lwx_gtk3u_xrc-3.0 -lwx_gtk3u_webview-3.0 -lwx_gtk3u_html-3.0 -lwx_gtk3u_qa-3.0 -lwx_gtk3u_adv-3.0 -lwx_gtk3u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -lpthread -ldl -L/usr/lib/gcc/ppc64le-redhat-linux/12 -L/usr/lib/gcc/ppc64le-redhat-linux/12/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64le-redhat-linux/12/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/ppc64le-redhat-linux/12/crtendS.o /usr/lib/gcc/ppc64le-redhat-linux/12/../../../../lib64/crtn.o -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -O2 -flto=auto -g -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -Wl,--no-undefined -Wl,-z -Wl,relro -Wl,--as-needed -Wl,-z -Wl,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT -Wl,/builddir/build/BUILD/codeblocks-20.03/.package_note-codeblocks-20.03-11.fc36.ppc64le.ld -pthread   -pthread -Wl,-soname -Wl,libHexEditor.so -o .libs/libHexEditor.so
/usr/bin/ld: /usr/lib/gcc/ppc64le-redhat-linux/12/libgcc.a(float128-ifunc.o):(.data+0x0): undefined reference to `__parse_hwcap_and_convert_at_platform'
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:617: libHexEditor.la] Error 1
make[4]: Leaving directory '/builddir/build/BUILD/codeblocks-20.03/src/plugins/contrib/HexEditor'

This is from a fresh build - https://koji.fedoraproject.org/koji/taskinfo?taskID=82004527

Comment 11 Florian Weimer 2022-01-27 12:41:44 UTC
You shouldn't use -nostdlib. If you do that, you are on your own. The issue here is -l flag (-lgcc_s after -lc) ordering and -Wl,--as-needed.

Comment 12 Dan Horák 2022-01-27 12:49:02 UTC
I think it's libtool in "module" mode ...

/bin/sh ../../../../libtool  --tag=CXX   --mode=link g++  -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -Winvalid-pch -fPIC -fexceptions -module -shared -version-info 0:1:0 -no-undefined -avoid-version -Wl,--no-undefined -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/codeblocks-20.03/.package_note-codeblocks-20.03-11.fc36.ppc64le.ld -o libHexEditor.la -rpath /usr/lib64/codeblocks/plugins CharacterView.lo DigitView.lo ExpressionExecutor.lo ExpressionParser.lo ExpressionPreprocessed.lo ExpressionTestCases.lo ExpressionTester.lo FileContentBase.lo FileContentBuffered.lo FileContentDisk.lo HexEditLineBuffer.lo HexEditor.lo HexEditPanel.lo HexEditViewBase.lo SearchDialog.lo SelectStoredExpressionDlg.lo TestCasesDlg.lo ../../../sdk/libcodeblocks.la -pthread   -lwx_gtk3u_aui-3.0 -lwx_gtk3u_propgrid-3.0 -lwx_gtk3u_richtext-3.0 -lwx_gtk3u_xrc-3.0 -lwx_gtk3u_webview-3.0 -lwx_gtk3u_html-3.0 -lwx_gtk3u_qa-3.0 -lwx_gtk3u_adv-3.0 -lwx_gtk3u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0  -lpthread -ldl

Comment 13 Dan Horák 2022-01-27 14:32:34 UTC
hmm, libtool itself contains
postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s"

which should be the right set, but somehow the build lacks the first -lgcc_s ...

Comment 14 Dan Horák 2022-01-27 16:54:17 UTC
IMO this is a libtool bug, it shouldn't be de-duplicating the libs in $postdeps. When I pass --preserve-dup-deps the linker command contains the right sequence of -lgcc_s and -lc

Comment 15 Dan Horák 2022-01-27 18:08:46 UTC
or this change in libtool

--- libtool.orig	2022-01-27 18:02:50.421704711 +0000
+++ libtool	2022-01-27 18:02:56.221776202 +0000
@@ -2930,7 +2930,7 @@
     case $host in
       # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
       # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
-      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2* | *linux*)
+      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
         # don't eliminate duplications in $postdeps and $predeps

Comment 16 Ben Cotton 2022-02-08 20:27:59 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 36 development cycle.
Changing version to 36.

Comment 17 Pavel Raiskup 2022-05-01 05:18:31 UTC
> -      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2* | *linux*)
> +      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)

I don't have time for full review of this (I've just quickly seen the
downstream commit 2103f3557ecaa87d60ddb9c8d2f490c8ead9f3a0).  I just have a
warning that his might be tricky.

Any such downstream change in Libtool needs to be done very carefully
because patching ltmain.in in Rawhide not only affects the Rawhide builds —
it will also affect the variety of upstream `make dist` release tarballs.
Therefore, while the patch might work on Fedora 37+, it may get distributed
to the world and fail the build on other distributions (no big immediate risk,
but long term upstream maintainers might prefer doing the development on other
distros, just to assure they provide clean `make dist` tarballs).

Note You need to log in before you can comment on or make changes to this bug.