[clang] [flang] [Flang][Driver] Add -print-resource-dir command line flag to emit Flang's resource directory (PR #90886)

Michael Klemm via cfe-commits cfe-commits at lists.llvm.org
Thu May 2 11:38:26 PDT 2024


================
@@ -250,6 +247,25 @@ void Driver::setDriverMode(StringRef Value) {
     Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
 }
 
+void Driver::setResourceDirectory() {
+  // Compute the path to the resource directory, depending on the driver mode.
+  switch (Mode) {
+  case GCCMode:
+  case GXXMode:
+  case CPPMode:
+  case CLMode:
+  case DXCMode:
+    ResourceDir = GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
+    break;
+  case FlangMode:
+    // TODO: Is there a better way to add the "../include/flang/" component?
+    SmallString<64> relPath{};
+    llvm::sys::path::append(relPath, "..", "include", "flang");
+    ResourceDir = GetResourcesPath(ClangExecutable, relPath);
+    break;
----------------
mjklemm wrote:

Reviewers, please let me know if that approach is too simplistic.  I would also like to get your feedback on whether this should be pointing to `$FLANG_BIN/../include` instead.  Please suggest.

https://github.com/llvm/llvm-project/pull/90886


More information about the cfe-commits mailing list