https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113996
Bug ID: 113996 Summary: ICE with LTO and full optimizations Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: jcmoyer32 at gmail dot com CC: dkm at gcc dot gnu.org Target Milestone: --- Building the following program with `gnatmake example.adb -O2 -gnatp -flto` causes an ICE: -------------------------------- with Ada.Containers.Hashed_Maps; with Ada.Strings.Hash; procedure example is subtype Node_Name is String (1 .. 4); package Node_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Node_Name, Element_Type => Integer, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); begin null; end example; -------------------------------- [x@arch ~]# gnatmake -f example.adb -O2 -gnatp -flto gcc -c -O2 -gnatp -flto example.adb gnatbind -x example.ali gnatlink example.ali -O2 -flto during IPA pass: inline In function ‘example__node_maps__find_equal_key’, inlined from ‘example__node_maps__is_equal’ at /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/adainclude/a-chtgop.adb:410:20, inlined from ‘example__node_maps__Oeq__3’ at /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/adainclude/a-cohama.adb:128:14: /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/adainclude/a-cohama.adb:500:46: internal compiler error: in initialize_inlined_parameters, at tree-inline.cc:3659 500 | R_Index : constant Hash_Type := Key_Ops.Index (R_HT, L_Node.Key); | ^ 0x1851644 internal_error(char const*, ...) ???:0 0x67856f fancy_abort(char const*, int, char const*) ???:0 0xc20fe1 optimize_inline_calls(tree_node*) ???:0 0x9629cb inline_transform(cgraph_node*) ???:0 0xaf423f execute_all_ipa_transforms(bool) ???:0 0x76c19e cgraph_node::expand() ???:0 0x6d86f3 lto_main() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://bugs.archlinux.org/> for instructions. lto-wrapper: fatal error: /usr/bin/gcc returned 1 exit status compilation terminated. /usr/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status gnatlink: error when calling /usr/bin/gcc gnatmake: *** link failed. -------------------------------- I've tested this on: - Arch Linux 6.5.9 + gcc 13.2.1: ICE - Windows 10 + gcc 13.2.0 from MSYS2-mingw64: ICE - godbolt: all versions of gnat from 9.x onwards: ICE; 8.x successfully compiles There are several workarounds I've found; each of these produces a successful compile: - Provide my own hash function - Copy the implementation of Ada.Strings.Hash to my source file and use that one - Drop the optimization level from -O2 to -O1 - Remove -gnatp - Remove -flto (replacing it with -gnatn also works)