diff options
Diffstat (limited to 'flang/tools/f18/f18.cpp')
-rw-r--r-- | flang/tools/f18/f18.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
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; |