[flang-commits] [flang] [flang][docs] Document technique for regenerating a module hermetically (PR #139975)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Wed May 14 15:49:35 PDT 2025
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/139975
A flang-new module file is Fortran source, so it can be recompiled with the `-fhermetic-module-files` option to convert it into a hermetic one.
>From 3635e87fe94b3158ec094c329f1196e10cc54c92 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Wed, 14 May 2025 15:46:13 -0700
Subject: [PATCH] [flang][docs] Document technique for regenerating a module
hermetically
A flang-new module file is Fortran source, so it can be recompiled with
the `-fhermetic-module-files` option to convert it into a hermetic
one.
---
flang/docs/ModFiles.md | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/flang/docs/ModFiles.md b/flang/docs/ModFiles.md
index dd0ade5cebbfc..fc05c2677fc26 100644
--- a/flang/docs/ModFiles.md
+++ b/flang/docs/ModFiles.md
@@ -171,3 +171,14 @@ modules of dependent libraries need not also be packaged with the library.
When the compiler reads a hermetic module file, the copies of the dependent
modules are read into their own scope, and will not conflict with other modules
of the same name that client code might `USE`.
+
+One can use the `-fhermetic-module-files` option when building the top-level
+module files of a library for which not all of the implementation modules
+will (or can) be shipped.
+
+It is also possible to convert a default module file to a hermetic one after
+the fact.
+Since module files are Fortran source, simply copy the module file to a new
+temporary free form Fortran source file and recompile it (`-fsyntax-only`)
+with the `-fhermetic-module-files` flag, and that will regenerate the module
+file in place with all of its dependent modules included.
More information about the flang-commits
mailing list