[llvm] Put large common blocks into .lbss for the medium and large code models (PR #161483)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 4 21:56:30 PDT 2025
MaskRay wrote:
I have some concerns about adding large COMMON support for the obsoleted Fortran feature (and removed from Fortran 2018):
Architecture-specific limitation: This feature is x86-64 specific, which introduces architectural divergence for what is essentially a legacy feature.
SHN_X86_64_LCOMMON isn't even defined in glibc's elf.h.
While the processor-specific section index range SHN_LOPROC~SHN_HIPROC is present, it's really unused in all linkers and binary utilities on Linux.
Adding support just for SHN_X86_64_LCOMMON would be annoying and introduce overhead in a hot patch in linkers.
Is this solving a real problem? Could you clarify whether #149222 represents an actual real-world use case?
If the goal is to eliminate COMMON blocks entirely, the modern solution is to use modules: define the variable in a module in a single source file and compile it once. This is the recommended practice in modern Fortran.
If you specifically need the linker behavior where duplicate symbols don't cause errors, and want these symbols in a .lbss section, consider changing flang to lower to COMDAT section groups instead:
```
.section .lbss.foo,"awG",%nobits,foo,comdat
.globl foo
.space 8
.size foo, 8
```
This approach achieves the same result while working across all architectures, not just x86-64.
https://github.com/llvm/llvm-project/pull/161483
More information about the llvm-commits
mailing list