https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122430
Bug ID: 122430
Summary: Call to empty interposable function is optimized away
with -flto -fPIC -fsemantic-interposition
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: xry111 at gcc dot gnu.org
Target Milestone: ---
$ cat q.c
void g() { }
int f() { g(); return 42; }
$ gcc q.c -fPIC -O2 cat-shared -flto -flto-partition=max
-fsemantic-interposition
$ objdump --disassemble=f
...
0000000000001100 <f>:
1100: b8 2a 00 00 00 mov $0x2a,%eax
1105: c3 ret
...
I don't think it's allowed with -fsemantic-interposition. This seems related
to PR95558 and PR122058 but I'm unsure if the underlying issue is the same, as
this one needs -flto.
-flto-partition=max is needed for a minimal reproducer but in practice this
breaks libXfont-1.5.4 with CFLAGS="-O2 -flto -fPIC" without any
-flto-partition.