Description
Describe the bug
scons does not appear to be correctly find dependencies on *.mod files in Fortran files.
My project includes a Fortran library that includes a number of source files and a module including some shared variables. When compiling on windows with ifort, I get the following error when doing a clean build:
error #7002: Error in opening the compiled module file. Check INCLUDE paths.
Subsequent builds complete successfully.
Investigation shows that the above compiler error is seen because the *.mod file required by the source files is not built before the source file compilation. Reordering the list of source files improves the situation, but it still fails periodically when building in parallel. Subsequent attempts to compile work as the *.mod file is created during the first scons attempt and are thus already available.
Per suggestion from discord, I ran scons with --tree=prune
to check if the consumers of the module correctly listed the *.mod file as a build dependency. The output below (anonymized) shows the output for one of the source files:
| +-<path>\<objName>.staticrt.obj
| | +-<relativePath>\<srcFile>.f
| | +-C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.5.281\windows\bin\intel64\ifort.EXE
Note that the source file does not list the *.mod file as a dependency.
The project is cross-platform so I also checked the result of --tree=prune
on linux (compiled with gfortran). Scons also did not recognize the dependency on the mod file (output was the same as above with the exception of the compiler path). However, the code compiles without issue on linux.
Since the above shows that the source files are not identifying the *.mod file as a build dependency, my assumption is that there is some issue in the way that scons is determining dependencies for Fortran files. I'm not sure why there's not an issue with gfortran on linux.
Required information
- Link to SCons Users thread discussing your issue.
discussed on the scons discord (fortran-support channel) - Version of SCons
3.1.2 - Version of Python
3.7.13 - Which python distribution if applicable (python.org, cygwin, anaconda, macports, brew,etc)
cpython - How you installed SCons
pip install - What Platform are you on? (Linux/Windows and which version)
Windows 10 Enterprise version1909 - How to reproduce your issue? Please include a small self contained reproducer. Likely a SConstruct should do for most issues.
- How you invoke scons (The command line you're using "scons --flags some_arguments")
scons -j8