GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran

fortran: Module-contained PRIVATE procedures must have global ELF linkage

Fortran's PRIVATE module procedures now have global ELF linkage, allowing submodules to access them via host association.

Fortran module-contained PRIVATE procedures are now marked with global ELF linkage and hidden visibility. This change allows submodules compiled as separate translation units to reach these procedures through host association. This aligns the treatment of PRIVATE procedures with the existing treatment of module variables.

In Details

In trans-decl.cc, build_function_decl now sets TREE_PUBLIC for all module-contained procedures. DECL_VISIBILITY is set to VISIBILITY_HIDDEN for PRIVATE procedures to match existing variable treatment. This resolves PR125430, enabling submodules compiled separately to access private module procedures via host association.

For Context

Fortran modules provide a way to organize code into reusable units. A module can contain procedures (subroutines and functions) and variables. PRIVATE entities within a module are intended to be accessible only within that module. This commit modifies the linking behavior of PRIVATE procedures to allow access from submodules, which are essentially child modules that inherit properties from their parent modules. ELF linkage controls how compiled code is linked together to form an executable.

Filed Under: fortranmodulesELFlinkingvisibility