https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121725
--- Comment #2 from Sam James <sjames at gcc dot gnu.org> --- Here's another testcase from elfutils. It has two files, I haven't tried to condense it into one to keep it more realistic, but I can if needed. ``` $ cat dwarf_error.i static __thread int global_error; int dwarf_errno () { return global_error; } __typeof__ (dwarf_errno) __dwarf_errno_internal __attribute__ ((alias ("dwarf_errno"))); void __libdw_seterrno () { global_error = 0; } ``` ``` $ cat dwarf_getsrc_file.i int dwarf_getsrc_file_dbg, dwarf_getsrc_file_cudie; long dwarf_getsrc_file_cuhl, dwarf_getsrc_file_noff, dwarf_getsrc_file_nlines; int *dwarf_getsrc_file_lines; char dwarf_getsrc_file_fname2; int dwarf_nextcu (int *, long, long *, long *, long, char, char); int dwarf_getsrclines (int *, int **, long *); void xbasename (char *); void __libdw_seterrno (); int __dwarf_errno_internal (); int dwarf_getsrc_file (char *fname) { bool is_basename = __builtin_strchr (fname, '/'); for (; dwarf_nextcu (&dwarf_getsrc_file_dbg, 0, &dwarf_getsrc_file_noff, &dwarf_getsrc_file_cuhl, 0, 0, 0);) { if (dwarf_getsrclines (&dwarf_getsrc_file_cudie, &dwarf_getsrc_file_lines, &dwarf_getsrc_file_nlines)) { int error = __dwarf_errno_internal (); if (error == 0) continue; __libdw_seterrno (); return 1; } if (is_basename) xbasename (&dwarf_getsrc_file_fname2); } } ``` ``` $ gcc -O3 -flto dwarf_error.i dwarf_getsrc_file.i -shared -fno-semantic-interposition -fPIC during RTL pass: x86_cse dwarf_getsrc_file.i: In function ‘dwarf_getsrc_file’: dwarf_getsrc_file.i:32:1: internal compiler error: in candidate_gnu2_tls_p, at config/i386/i386-features.cc:4300 32 | } | ^ Please submit a full bug report, with preprocessed source (by using -freport-bug). See <https://bugs.gentoo.org/> for instructions. lto-wrapper: fatal error: gcc returned 1 exit status compilation terminated. /usr/lib/gcc/x86_64-pc-linux-gnu/16/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status ```