I noticed that Flang does not set dso_local
on global variables and functions. I believe this is the reason that it does not produce direct relocations when -fno-pic
is used.
Is there a reason dso_local
is not used for Fortran variables/functions or is it just a TODO (if yes, then do we have an issue for this)?
Definition of dso_local
from LLVM LangRef:
Runtime Preemption Specifiers
Global variables, functions and aliases may have an optional runtime preemption specifier. If a preemption specifier isn’t given explicitly, then a symbol is assumed to be dso_preemptable.
dso_preemptable
Indicates that the function or variable may be replaced by a symbol from outside the linkage unit at runtime.
dso_local
The compiler may assume that a function or variable marked as dso_local will resolve to a symbol within the same linkage unit. Direct access will be generated even if the definition is not within this compilation unit.
I suppose we can use llvm-project/clang/lib/CodeGen/CodeGenModule.cpp at 7ca6490636e758ec44ed149029b91163087d798e · llvm/llvm-project · GitHub as a reference.