fpm
fpm copied to clipboard
Detect submodule dependencies
If a procedure inside an example/ subdirectory has an interface in a module and the corresponding procedure definition in a submodule (which was largely the intent when submodule became a language feature in Fortran 2008), then a linking error results. It appears that fpm is only seeing the module dependency information captured in use statements but not in submodule statements.
To Do:
- [ ] post a reproducer later.
Thanks, can reproduce this error using the files below:
! example/main.f90
program a
use m
call p
end program
! example/mod.f90
module m
interface
module subroutine p
end subroutine
end interface
end module
! example/sub.f90
submodule(m) s
contains
module procedure p
end procedure
end submodule
Output (built inside fpm tree):
+ mkdir -p build/gfortran_2A42023B310FA28D/example/
+ gfortran -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g -fcheck=bounds -fcheck=array-temps -fbacktrace -fcoarray=single -J build/gfortran_2A42023B310FA28D/fpm -I build/gfortran_2A42023B310FA28D/fpm build/gfortran_2A42023B310FA28D/fpm/example_main.f90.o build/gfortran_2A42023B310FA28D/fpm/example_mod.f90.o build/gfortran_2A42023B310FA28D/fpm/libfpm.a -o build/gfortran_2A42023B310FA28D/example/fpm-demo
/usr/bin/ld: build/gfortran_2A42023B310FA28D/fpm/example_main.f90.o: in function `MAIN__':
/home/awvwgk/projects/src/git/fortran-package-manager/example/main.f90:3: undefined reference to `__m_MOD_p'
collect2: error: ld returned 1 exit status
<ERROR> Compilation failed for object " fpm-demo "
<ERROR>stopping due to failed compilation
The link line must contain build/gfortran_2A42023B310FA28D/fpm/example_sub.f90.o otherwise this will always fail.