aboutsummaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorArnamoy Bhattacharyya <arnamoy.bhattacharyya@huawei.com>2021-03-29 09:47:38 -0400
committerArnamoy Bhattacharyya <arnamoy10@gmail.com>2021-03-29 10:01:08 -0400
commitd0d92fee6f41c0f3c18a1644d4d7ac5d58f63586 (patch)
tree7c6fe0ad37a244f9cb76ab9dbca372cb79beb161 /flang
parent[OPENMP]Fix PR49636: Assertion `(!Entry.getAddress() || Entry.getAddress() ==... (diff)
downloadllvm-project-d0d92fee6f41c0f3c18a1644d4d7ac5d58f63586.tar.gz
llvm-project-d0d92fee6f41c0f3c18a1644d4d7ac5d58f63586.tar.bz2
llvm-project-d0d92fee6f41c0f3c18a1644d4d7ac5d58f63586.zip
[flang][driver] Add default intrinsic module path in f18 to make f18 behave like flang-new (with respect to the module paths), make it possible to share more tests between the drivers and make using f18 easier (the default path means that users are no longer required to specify it)
Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D99336
Diffstat (limited to 'flang')
-rw-r--r--flang/test/Driver/intrinsic_module_path.f9013
-rw-r--r--flang/test/lit.cfg.py3
-rw-r--r--flang/tools/f18/f18.cpp22
-rw-r--r--flang/tools/f18/flang2
4 files changed, 23 insertions, 17 deletions
diff --git a/flang/test/Driver/intrinsic_module_path.f90 b/flang/test/Driver/intrinsic_module_path.f90
index 3f11512289a6..1105220b8456 100644
--- a/flang/test/Driver/intrinsic_module_path.f90
+++ b/flang/test/Driver/intrinsic_module_path.f90
@@ -3,20 +3,11 @@
! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
! default one, causing a CHECKSUM error.
-! REQUIRES: new-flang-driver
-
-
-!--------------------------
-! FLANG DRIVER (flang-new)
-!--------------------------
-! RUN: %flang-new -fsyntax-only %s 2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
-! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=GIVEN
-
!-----------------------------------------
! FRONTEND FLANG DRIVER (flang-new -fc1)
!-----------------------------------------
-! RUN: %flang-new -fc1 %s 2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
-! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang_fc1 -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=GIVEN
!-----------------------------------------
! EXPECTED OUTPUT WITHOUT
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index 4392da680e7f..7c99d6f7636d 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -64,7 +64,6 @@ if config.flang_standalone_build:
# the build directory holding that tool.
tools = [
ToolSubst('%f18', command=FindTool('f18'),
- extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
unresolved='fatal')
]
@@ -75,10 +74,8 @@ if config.include_flang_new_driver_test:
extra_args=['-fc1'], unresolved='fatal'))
else:
tools.append(ToolSubst('%flang', command=FindTool('f18'),
- extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
unresolved='fatal'))
tools.append(ToolSubst('%flang_fc1', command=FindTool('f18'),
- extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
unresolved='fatal'))
if config.flang_standalone_build:
diff --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp
index e22905a86a92..9c5e6c9802fb 100644
--- a/flang/tools/f18/f18.cpp
+++ b/flang/tools/f18/f18.cpp
@@ -27,6 +27,7 @@
#include "flang/Version.inc"
#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"
@@ -395,6 +396,16 @@ int printVersion() {
return exitStatus;
}
+// Generate the path to look for intrinsic modules
+static std::string getIntrinsicDir() {
+ // TODO: Find a system independent API
+ llvm::SmallString<128> driverPath;
+ driverPath.assign(llvm::sys::fs::getMainExecutable(nullptr, nullptr));
+ llvm::sys::path::remove_filename(driverPath);
+ driverPath.append("/../include/flang/");
+ return std::string(driverPath);
+}
+
int main(int argc, char *const argv[]) {
atexit(CleanUpAtExit);
@@ -431,6 +442,10 @@ int main(int argc, char *const argv[]) {
std::vector<std::string> fortranSources, otherSources;
bool anyFiles{false};
+ // Add the default intrinsic module directory to the list of search
+ // directories
+ driver.searchDirectories.push_back(getIntrinsicDir());
+
while (!args.empty()) {
std::string arg{std::move(args.front())};
auto dot{arg.rfind(".")};
@@ -603,8 +618,11 @@ int main(int argc, char *const argv[]) {
} else if (arg == "-module-suffix") {
driver.moduleFileSuffix = args.front();
args.pop_front();
- } else if (arg == "-intrinsic-module-directory") {
- driver.searchDirectories.push_back(args.front());
+ } else if (arg == "-intrinsic-module-directory" ||
+ arg == "-fintrinsic-modules-path") {
+ // prepend to the list of search directories
+ driver.searchDirectories.insert(
+ driver.searchDirectories.begin(), args.front());
args.pop_front();
} else if (arg == "-futf-8") {
driver.encoding = Fortran::parser::Encoding::UTF_8;
diff --git a/flang/tools/f18/flang b/flang/tools/f18/flang
index 8dda836c86c4..81fac7b28345 100644
--- a/flang/tools/f18/flang
+++ b/flang/tools/f18/flang
@@ -8,7 +8,7 @@
#===------------------------------------------------------------------------===#
wd=$(cd $(dirname "$0")/.. && pwd)
-opts="-module-suffix .f18.mod -intrinsic-module-directory $wd/include/flang"
+opts="-module-suffix .f18.mod "
if ! $wd/bin/f18 $opts "$@"
then status=$?
echo flang: in $PWD, f18 failed with exit status $status: $wd/bin/f18 $opts "$@" >&2