-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Flang-new trying to access the imported module inside the .mod
file
#97398
Comments
@llvm/issue-subscribers-flang-runtime Author: Thirumalai Shaktivel (Thirumalai-Shaktivel)
Reproducible files are available here, [module-bug.tar.gz](https://github.com/user-attachments/files/16065435/module-bug.tar.gz)
MRE: program app
use circle, only : area
implicit none
real :: r
r = 2.0
write(*,*) 'radius = ', r
write(*,*) 'area = ', area(r)
end program app Flang-new $ ./build.sh
error: Semantic errors in app.f90
../libdummy/include/circle.mod:4:5: error: Cannot read module file for module 'constant_pi': Source file 'constant_pi.mod' was not found
use constant_pi,only:get_pi
^^^^^^^^^^^ GFortran $ ./build.sh
radius = 2.00000000
area = 12.5663710 |
@llvm/issue-subscribers-bug Author: Thirumalai Shaktivel (Thirumalai-Shaktivel)
Reproducible files are available here, [module-bug.tar.gz](https://github.com/user-attachments/files/16065435/module-bug.tar.gz)
MRE: program app
use circle, only : area
implicit none
real :: r
r = 2.0
write(*,*) 'radius = ', r
write(*,*) 'area = ', area(r)
end program app Flang-new $ ./build.sh
error: Semantic errors in app.f90
../libdummy/include/circle.mod:4:5: error: Cannot read module file for module 'constant_pi': Source file 'constant_pi.mod' was not found
use constant_pi,only:get_pi
^^^^^^^^^^^ GFortran $ ./build.sh
radius = 2.00000000
area = 12.5663710 |
@llvm/issue-subscribers-flang-frontend Author: Thirumalai Shaktivel (Thirumalai-Shaktivel)
Reproducible files are available here, [module-bug.tar.gz](https://github.com/user-attachments/files/16065435/module-bug.tar.gz)
MRE: program app
use circle, only : area
implicit none
real :: r
r = 2.0
write(*,*) 'radius = ', r
write(*,*) 'area = ', area(r)
end program app Flang-new $ ./build.sh
error: Semantic errors in app.f90
../libdummy/include/circle.mod:4:5: error: Cannot read module file for module 'constant_pi': Source file 'constant_pi.mod' was not found
use constant_pi,only:get_pi
^^^^^^^^^^^ GFortran $ ./build.sh
radius = 2.00000000
area = 12.5663710 |
Yes, that's how this compiler works. |
Hi @klausler, the example shared above is the simple reproducible example. But this issue is faced while building an application which has new CMake build system. The This is the same behaviour with classic Flang. But, ifort, ifx and gfortran works fine. Can you please clarify more and also any possible workarounds? |
Any further comments on this? I believe the reported problem is a valid one. |
Module files emitted by this Fortran compiler are valid Fortran source files. Symbols that are USE-associated into modules are represented in their module files with USE statements and special comments with hash codes in them to ensure that those USE statements resolve to the same modules that were used to build the module when its module file was generated. This scheme prevents unchecked module file growth in large applications by not emitting USE-associated symbols redundantly. This problem can be especially bad when derived type definitions must be repeated in the module files of their clients, and the clients of those modules, and so on. However, this scheme has the disadvantage that clients of modules must be compiled with dependent modules in the module search path. This new -fhermetic-module-files option causes module file output to be free of dependences on any non-intrinsic module files; dependent modules are instead emitted as part of the module file, rather than being USE-associated. It is intended for top level library module files that are shipped with binary libraries when it is not convenient to collect and ship their dependent module files as well. Fixes llvm#97398.
Thank you @klausler, the PR changes seem to fix the issue. @ningli-amd, can you please check with the application? |
Module files emitted by this Fortran compiler are valid Fortran source files. Symbols that are USE-associated into modules are represented in their module files with USE statements and special comments with hash codes in them to ensure that those USE statements resolve to the same modules that were used to build the module when its module file was generated. This scheme prevents unchecked module file growth in large applications by not emitting USE-associated symbols redundantly. This problem can be especially bad when derived type definitions must be repeated in the module files of their clients, and the clients of those modules, and so on. However, this scheme has the disadvantage that clients of modules must be compiled with dependent modules in the module search path. This new -fhermetic-module-files option causes module file output to be free of dependences on any non-intrinsic module files; dependent modules are instead emitted as part of the module file, rather than being USE-associated. It is intended for top level library module files that are shipped with binary libraries when it is not convenient to collect and ship their dependent module files as well. Fixes llvm#97398.
Reproducible files are available here, module-bug.tar.gz
MRE:
Flang-new
GFortran
The text was updated successfully, but these errors were encountered: