aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorAndrzej Warzynski <andrzej.warzynski@arm.com>2022-03-18 16:20:56 +0000
committerAndrzej Warzynski <andrzej.warzynski@arm.com>2022-04-05 08:25:26 +0000
commitdda366ed37cec7b2f7c96a47b1b32391b514d969 (patch)
tree38446b35f67071561ce14e54e63efc8e6ed20588 /flang/lib/Frontend/CompilerInvocation.cpp
parentd2ca2b94fd4f28993b3a52545b090171dec1724e (diff)
downloadllvm-dda366ed37cec7b2f7c96a47b1b32391b514d969.zip
llvm-dda366ed37cec7b2f7c96a47b1b32391b514d969.tar.gz
llvm-dda366ed37cec7b2f7c96a47b1b32391b514d969.tar.bz2
[flang][cmake] Make CMake copy "omp_lib.h" into the build directory
Any header or module file in the Flang source directory is of no use to the compiler unless it is copied into the build directory. Indeed, all compiler search paths are relative to the compiler executable (flang-new in our case). Hence, "omp_lib.h" should be copied into the build directory alongside other compiler-provided files that can be "included" (header files) or "used" (module files). For now, "omp_lib.h" is copied into "<build-dir>/include/flang/OpenMP". We may decide to change this in future. For example, Clang copies a bunch of runtime headers into “<build-dir>/lib/clang/<version-number>”. We could also consider using a similar header from a different sub-project. Flang's driver search path is updated accordingly. A rule for "installing" the "omp_lib.h" header is _yet to be added_ (we will also need to determine the suitable location for this). Differential Revision: https://reviews.llvm.org/D122015
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index cf92e71..cb94dac 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -381,6 +381,15 @@ static std::string getIntrinsicDir() {
return std::string(driverPath);
}
+// Generate the path to look for OpenMP headers
+static std::string getOpenMPHeadersDir() {
+ llvm::SmallString<128> includePath;
+ includePath.assign(llvm::sys::fs::getMainExecutable(nullptr, nullptr));
+ llvm::sys::path::remove_filename(includePath);
+ includePath.append("/../include/flang/OpenMP/");
+ return std::string(includePath);
+}
+
/// Parses all preprocessor input arguments and populates the preprocessor
/// options accordingly.
///
@@ -626,6 +635,11 @@ void CompilerInvocation::SetDefaultFortranOpts() {
std::vector<std::string> searchDirectories{"."s};
fortranOptions.searchDirectories = searchDirectories;
+
+ // 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.isFixedForm = false;
}