On Wed, 18 Jan 2023, Andreas Schwab via Gcc-patches wrote: > No unwind tables are generated, as if -funwind-tables is ignored. If > LTO is disabled, everything works as expected.
On Risc-V btw. (which, unlike i386,aarch64,s390,rs6000 does not effectively enable funwind-tables always via either backend or common/config/$arch/ code, which is the reason why the problem can't be seen there). It's an interaction with -g : The problem (with cross compiler here, but shouldn't matter): % riscv64-gcc -g -flto -funwind-tables -fPIC -c hello.c % riscv64-gcc -shared hello.o % readelf -wF a.out ... empty .eh_frame ... Contents of the .debug_frame section: ... content ... Using a compiler for any of the above archs makes this work (working means that the unwind info is placed into .eh_frame, _not_ into .debug_frame). Not using -g makes it work. Adding -funwind-tables to the link command makes it work. Adding -fexceptions to the compile command makes it work. Not using LTO makes it work. So, it's quite clear that the option merging algorithm related to all this is somewhat broken, the global (or per function, or whatever) -funwind-tables option from hello.o doesn't make it correctly into the output (when -g is there). Adding -fexception makes it work because then the functions will have personalities and on LTO-read-in _that_ will implicitely enable funwind-tables again (which should have been enabled already by the option-read-in). As written initially the other archs are working because they all have various ways of essentially setting flag_unwind_tables always: i386 via common/config/i386/i386-common.cc opts->x_flag_asynchronous_unwind_tables = 2; config/i386/i386-options.cc if (opts->x_flag_asynchronous_unwind_tables == 2) opts->x_flag_unwind_tables = opts->x_flag_asynchronous_unwind_tables = 1; rs6000 via common/config/rs6000/rs6000-common.cc #ifdef OBJECT_FORMAT_ELF opts->x_flag_asynchronous_unwind_tables = 1; #endif (which ultimately also enabled flag_unwind_tables) s390 via common/config/s390/s390-common.cc opts->x_flag_asynchronous_unwind_tables = 1; aarch64 via common/config/aarch64/aarch64-common.cc #if (TARGET_DEFAULT_ASYNC_UNWIND_TABLES == 1) { OPT_LEVELS_ALL, OPT_fasynchronous_unwind_tables, NULL, 1 }, { OPT_LEVELS_ALL, OPT_funwind_tables, NULL, 1}, #endif (the #define here is set for aarch64*-*-linux* ) So the problem cannot be readily demonstrated on these architectures. risc-v has no such code (and doesn't need to). Ciao, Michael.