diff --git a/ninjabackend.py b/ninjabackend.py index 5cb77052c..d7b1cf127 100644 --- a/ninjabackend.py +++ b/ninjabackend.py @@ -1012,6 +1012,11 @@ class NinjaBackend(backends.Backend): raise InvalidArguments('Module %s in file %s not provided by any other source file.' % (usename, src)) mod_source_file = tdeps[usename] + # Check if a source uses a module it exports itself. + # Potential bug if multiple targets have a file with + # the same name. + if mod_source_file == os.path.split(src)[1]: + continue # WORKAROUND, we should set up a file level dependency to the # module file and mark it as an output of this target. However # we can't do that as Ninja does not support dependency tracking diff --git a/test cases/fortran/4 self dependency/meson.build b/test cases/fortran/4 self dependency/meson.build new file mode 100644 index 000000000..bc5dab4ed --- /dev/null +++ b/test cases/fortran/4 self dependency/meson.build @@ -0,0 +1,4 @@ +project('selfdep', 'fortran') + +e = executable('selfdep', 'selfdep.f90') +test('selfdep', e) diff --git a/test cases/fortran/4 self dependency/selfdep.f90 b/test cases/fortran/4 self dependency/selfdep.f90 new file mode 100644 index 000000000..a27283283 --- /dev/null +++ b/test cases/fortran/4 self dependency/selfdep.f90 @@ -0,0 +1,11 @@ +MODULE Circle + REAL, PARAMETER :: Pi = 3.1415927 + REAL :: radius +END MODULE Circle + +PROGRAM prog + +use Circle +IMPLICIT NONE + +END PROGRAM prog