================
@@ -236,6 +236,21 @@ is `ParseSyntaxOnlyAction`, which corresponds to 
`-fsyntax-only`. In other
 words, `flang -fc1 <input-file>` is equivalent to `flang -fc1 -fsyntax-only
 <input-file>`.
 
+## Dependency File Generation
+Flang can emit Makefile-style dependency rules with `-M`, `-MM`, `-MD` and
+`-MMD` (paired with `-MF`, `-MT` and `-MQ` to control the output file and the
+rule target).
+
+There is one behavioural difference to be aware of regarding module
+dependencies (the `.mod` files brought in by `use` statements):
+
+* `-MD` and `-MMD` run a full compilation, so the `.mod` files opened during
+  semantic analysis are recorded and appear in the dependency rule.
+* `-M` and `-MM` run the prescanner only. They report textual dependencies
----------------
Thirumalai-Shaktivel wrote:

gfortran `-M` requires .mod files to already exist to resolve USE statements. 
If they are present, it correctly emits "main.o: main.f90 mymod.mod". If not, 
it fails with a "fatal error" saying the mod file is not found.

In flang-new, USE statements are resolved during the semantics phase, which 
-M/-MM does not run (prescanner only). Replicating gfortran's behaviour, where 
-M resolves USE if .mod files are present, is therefore not straightforward. 
This limitation was initially a reason to omit -M/-MM altogether, but later on 
I decided to retain it to maintain consistency with clang.

-M/-MM resolves include statement, though.

https://github.com/llvm/llvm-project/pull/209379
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to