[Bug target/124740] New: x86 (32bit) could handle musttail with -fPIC
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Mar 31 21:14:16 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124740
Bug ID: 124740
Summary: x86 (32bit) could handle musttail with -fPIC
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: rejects-valid, tail-call
Severity: enhancement
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: i?86-*-* x86_64-*-*
Created attachment 64111
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64111&action=edit
testcase
With this testcase at -O2 -fPIC -m32; GCC rejects the attached because of:
```
/* If we are generating position-independent code, we cannot sibcall
optimize direct calls to global functions, as the PLT requires
%ebx be live. (Darwin does not have a PLT.) */
if (!TARGET_MACHO
&& !TARGET_64BIT
&& flag_pic
&& flag_plt
&& bind_global)
return false;
```
But with must-tail you could do an indirect tail call instead. For must-tail it
is better to do an indirect tail call than rejecting it.
This was noticed while adding musttail to clang:
https://github.com/llvm/llvm-project/pull/188419#issuecomment-4148497506
More information about the Gcc-bugs
mailing list