Skip to content

Detect submodule dependencies #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
rouson opened this issue Sep 3, 2021 · 1 comment · Fixed by #743
Closed
1 task

Detect submodule dependencies #556

rouson opened this issue Sep 3, 2021 · 1 comment · Fixed by #743
Labels
bug Something isn't working

Comments

@rouson
Copy link
Contributor

rouson commented Sep 3, 2021

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.
@awvwgk awvwgk added the bug Something isn't working label Sep 4, 2021
@awvwgk
Copy link
Member

awvwgk commented Sep 4, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants