https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125430
Bug ID: 125430
Summary: Module-contained PRIVATE procedures must have global
ELF linkage
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jvdelisle at gcc dot gnu.org
Target Milestone: ---
This problem reduced from the Formal package.
(https://github.com/rouson/formal)
When attempting to compile these, one gets a linker error.
Three separate files containing the following:
parent_m.f90:
module parent_m
implicit none
private
public :: use_b
interface
module subroutine use_b(n, y)
integer, intent(in) :: n
double precision, allocatable, intent(out) :: y(:)
end subroutine
end interface
contains
pure function b(n) result(x)
integer, intent(in) :: n
double precision, allocatable :: x(:)
integer :: i
associate(dx => 1.0d0/n)
x = [(i*dx, i = 1, n)]
end associate
end function
pure function a(n) result(x)
integer, intent(in) :: n
double precision, allocatable :: x(:)
x = [0.0d0, b(n), 1.0d0]
end function
end module
-----
child_s.f90:
submodule(parent_m) child_s
implicit none
contains
module procedure use_b
y = b(n)
end procedure
end submodule
-----
child_main.f90
program child_main
use parent_m, only : use_b
implicit none
double precision, allocatable :: y(:)
call use_b(4, y)
print *, y
end program
To reproduce do this:
$ gfc -c parent_m.f90
$ gfc -c child_s.f90
$ gfc child_main.f90 *.o
/usr/bin/ld: child_s.o: in function `__parent_m_MOD_use_b':
child_s.f90:(.text+0x9c): undefined reference to `__parent_m_MOD_b'
collect2: error: ld returned 1 exit status
I have a proposed patch for comment.