You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clang Version: Clang 19 dev (e.g., clang version 19.0.0git)
GCC Version: (e.g., gcc version 10.3)
Compiler Flags: -fno-plt
Description:
I encountered an issue with the -fno-plt option in Clang 19 dev (development version) on aarch64. When compiling code with -fno-plt, Clang still generates PLT (Procedure Linkage Table) entries for function calls, whereas GCC behaves correctly and does not generate PLT entries.
This issue affects scenarios where direct GOT-based access is expected, and the presence of PLT entries may lead to unnecessary indirection and performance overhead.
Compile the following code with Clang 19 dev and -fno-plt
// gcc 1.c -shared -fno-plt -O0 -o libnoplt-clang.so -fPIC
// clang 1.c -shared -fno-plt -O0 -o libnoplt-gcc.so -fPIC
int bar(int a) {
return 10;
}
int foo(int a) {
return bar(a);
}
The Clang-compiled version generates PLT functions, while the GCC version does not.
While the default visibility bar is preemptible if you link it with -shared in the default case, it is non-preemptible if you link it with -no-pie or -pie. (https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic) The compiler doesn't have sufficient information. A GOT-generating code sequence is costly on probably all RISC architectures.
I think Clang's behavior is ideal and don't think we should match GCC.
Environment
Description:
I encountered an issue with the -fno-plt option in Clang 19 dev (development version) on aarch64. When compiling code with -fno-plt, Clang still generates PLT (Procedure Linkage Table) entries for function calls, whereas GCC behaves correctly and does not generate PLT entries.
This issue affects scenarios where direct GOT-based access is expected, and the presence of PLT entries may lead to unnecessary indirection and performance overhead.
Compile the following code with Clang 19 dev and -fno-plt
The Clang-compiled version generates PLT functions, while the GCC version does not.
Currently, LLVM has only been processed for the x86 and ARM + Mach-O architecture, but there are still problems with the aarch64 architecture.
relevant issue: Support fno-plt like gcc
relevant pr: Implement -fno-plt for SelectionDAG/GlobalISel
The text was updated successfully, but these errors were encountered: