aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authormadanial0 <118996571+madanial0@users.noreply.github.com>2023-12-04 16:34:08 -0500
committerGitHub <noreply@github.com>2023-12-04 16:34:08 -0500
commit8dc474c6b7d5fc4e0e7f18aac7750eb8c6bb6b26 (patch)
tree66d25f932f18a35ab5179111086c8a94458caced /flang/lib/Frontend/CompilerInvocation.cpp
parent0d59cfc7a3446dc6078dfc57783048f490d8d998 (diff)
downloadllvm-8dc474c6b7d5fc4e0e7f18aac7750eb8c6bb6b26.zip
llvm-8dc474c6b7d5fc4e0e7f18aac7750eb8c6bb6b26.tar.gz
llvm-8dc474c6b7d5fc4e0e7f18aac7750eb8c6bb6b26.tar.bz2
[flang] Pass Argv0 to getIntriniscDir and getOpenMPHeadersDir (#73254)
The `llvm::sys::fs::getMainExecutable(nullptr, nullptr)` is not able to obtain the correct executable path on AIX without Argv0 due to the lack of a current process on AIX's `proc` filesystem. This causes a build failure on AIX as intrinsic module directory is missing. --------- Co-authored-by: Mark Danial <mak.danial@ibm.com>
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index ec04727..62b6c38 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -700,19 +700,19 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
}
// Generate the path to look for intrinsic modules
-static std::string getIntrinsicDir() {
+static std::string getIntrinsicDir(const char *argv) {
// TODO: Find a system independent API
llvm::SmallString<128> driverPath;
- driverPath.assign(llvm::sys::fs::getMainExecutable(nullptr, nullptr));
+ driverPath.assign(llvm::sys::fs::getMainExecutable(argv, nullptr));
llvm::sys::path::remove_filename(driverPath);
driverPath.append("/../include/flang/");
return std::string(driverPath);
}
// Generate the path to look for OpenMP headers
-static std::string getOpenMPHeadersDir() {
+static std::string getOpenMPHeadersDir(const char *argv) {
llvm::SmallString<128> includePath;
- includePath.assign(llvm::sys::fs::getMainExecutable(nullptr, nullptr));
+ includePath.assign(llvm::sys::fs::getMainExecutable(argv, nullptr));
llvm::sys::path::remove_filename(includePath);
includePath.append("/../include/flang/OpenMP/");
return std::string(includePath);
@@ -1216,6 +1216,8 @@ bool CompilerInvocation::createFromArgs(
}
}
+ res.setArgv0(argv0);
+
return success;
}
@@ -1258,7 +1260,8 @@ void CompilerInvocation::setDefaultFortranOpts() {
// Add the location of omp_lib.h to the search directories. Currently this is
// identical to the modules' directory.
- fortranOptions.searchDirectories.emplace_back(getOpenMPHeadersDir());
+ fortranOptions.searchDirectories.emplace_back(
+ getOpenMPHeadersDir(getArgv0()));
fortranOptions.isFixedForm = false;
}
@@ -1323,7 +1326,8 @@ void CompilerInvocation::setFortranOpts() {
preprocessorOptions.searchDirectoriesFromIntrModPath.end());
// Add the default intrinsic module directory
- fortranOptions.intrinsicModuleDirectories.emplace_back(getIntrinsicDir());
+ fortranOptions.intrinsicModuleDirectories.emplace_back(
+ getIntrinsicDir(getArgv0()));
// Add the directory supplied through -J/-module-dir to the list of search
// directories