[PATCH] D97164: [flang] Add -J and -module-dir to f18 driver

Tim Keith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 21 14:40:35 PST 2021


tskeith created this revision.
tskeith added reviewers: klausler, sscalpone.
tskeith added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a reviewer: awarzynski.
tskeith requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add -J to the f18 driver for compatibility with gfortran.
Add -module-dir for compatibility with the new flang driver.

They both set the output directory for .mod files and add the
directory to the search list. -module still only does the former.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97164

Files:
  flang/test/Driver/write-module.f90
  flang/tools/f18/f18.cpp


Index: flang/tools/f18/f18.cpp
===================================================================
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -583,6 +583,10 @@
     } else if (arg == "-module") {
       driver.moduleDirectory = args.front();
       args.pop_front();
+    } else if (arg == "-module-dir") {
+      driver.moduleDirectory = args.front();
+      driver.searchDirectories.push_back(driver.moduleDirectory);
+      args.pop_front();
     } else if (arg == "-module-suffix") {
       driver.moduleFileSuffix = args.front();
       args.pop_front();
@@ -654,7 +658,8 @@
           << "  -module dir          module output directory (default .)\n"
           << "  -flatin              interpret source as Latin-1 (ISO 8859-1) "
              "rather than UTF-8\n"
-          << "  -fsyntax-only        parsing and semantics only, no output except messages\n"
+          << "  -fsyntax-only        parsing and semantics only, no output "
+             "except messages\n"
           << "  -funparse            parse & reformat only, no code "
              "generation\n"
           << "  -funparse-with-symbols  parse, resolve symbols, and unparse\n"
@@ -691,6 +696,14 @@
         args.pop_front();
       } else if (arg.substr(0, 2) == "-I") {
         driver.searchDirectories.push_back(arg.substr(2));
+      } else if (arg == "-J") {
+        driver.F18_FCArgs.push_back(args.front());
+        driver.moduleDirectory = args.front();
+        driver.searchDirectories.push_back(driver.moduleDirectory);
+        args.pop_front();
+      } else if (arg.substr(0, 2) == "-J") {
+        driver.moduleDirectory = arg.substr(2);
+        driver.searchDirectories.push_back(driver.moduleDirectory);
       }
     }
   }
Index: flang/test/Driver/write-module.f90
===================================================================
--- /dev/null
+++ flang/test/Driver/write-module.f90
@@ -0,0 +1,19 @@
+! RUN: rm -rf %t && mkdir -p %t/mod-dir && cd %t && %f18 -fparse-only %s
+! RUN: ls %t/testmodule.mod && not ls %t/mod-dir/testmodule.mod
+
+! RUN: rm -rf %t && mkdir -p %t/mod-dir && cd %t && %f18 -fparse-only -module mod-dir %s
+! RUN: ls %t/mod-dir/testmodule.mod && not ls %t/testmodule.mod
+
+! RUN: rm -rf %t && mkdir -p %t/mod-dir && cd %t && %f18 -fparse-only -module-dir mod-dir %s
+! RUN: ls %t/mod-dir/testmodule.mod && not ls %t/testmodule.mod
+
+! RUN: rm -rf %t && mkdir -p %t/mod-dir && cd %t && %f18 -fparse-only -J mod-dir %s
+! RUN: ls %t/mod-dir/testmodule.mod && not ls %t/testmodule.mod
+
+! RUN: rm -rf %t && mkdir -p %t/mod-dir && cd %t && %f18 -fparse-only -Jmod-dir %s
+! RUN: ls %t/mod-dir/testmodule.mod && not ls %t/testmodule.mod
+
+module testmodule
+  type::t2
+  end type
+end


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97164.325343.patch
Type: text/x-patch
Size: 2735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210221/82b50c8a/attachment.bin>


More information about the llvm-commits mailing list