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

Tim Keith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 22 09:04:11 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8720ec6b9a28: [flang] Add -J and -module-dir to f18 driver (authored by tskeith).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97164/new/

https://reviews.llvm.org/D97164

Files:
  flang/test/Driver/write-module.f90
  flang/test/Flang-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/Flang-Driver/write-module.f90
===================================================================
--- flang/test/Flang-Driver/write-module.f90
+++ flang/test/Flang-Driver/write-module.f90
@@ -1,8 +1,14 @@
-! RUN: mkdir -p %t/dir-f18 && %f18 -fparse-only -I tools/flang/include/flang -module %t/dir-f18 %s  2>&1
-! RUN: ls %t/dir-f18/testmodule.mod && not ls %t/testmodule.mod
+! RUN: rm -rf %t && mkdir -p %t/dir-flang
+! RUN: cd %t && %flang -fsyntax-only -module-dir %t/dir-flang %s
+! RUN: ls %t/dir-flang/testmodule.mod && not ls %t/testmodule.mod
 
-! RUN: mkdir -p %t/dir-flang-new && %flang-new -fsyntax-only -module-dir %t/dir-flang-new %s  2>&1
-! RUN: ls %t/dir-flang-new/testmodule.mod && not ls %t/testmodule.mod
+! RUN: rm -rf %t && mkdir -p %t/dir-flang
+! RUN: cd %t && %flang -fsyntax-only -J %t/dir-flang %s
+! RUN: ls %t/dir-flang/testmodule.mod && not ls %t/testmodule.mod
+
+! RUN: rm -rf %t && mkdir -p %t/dir-flang
+! RUN: cd %t && %flang -fsyntax-only -J%t/dir-flang %s
+! RUN: ls %t/dir-flang/testmodule.mod && not ls %t/testmodule.mod
 
 module testmodule
   type::t2
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.325465.patch
Type: text/x-patch
Size: 3846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210222/835c0973/attachment.bin>


More information about the llvm-commits mailing list