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

Andrzej WarzyƄski via flang-commits flang-commits at lists.llvm.org
Fri May 3 00:07:10 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;
----------------
banach-space wrote:

Presumably `relPath` stands for "relative path"? Why not `customResoursePath` as in https://github.com/llvm/llvm-project/blob/6d44a1ef55b559e59d725b07ffe1da988b4e5f1c/clang/lib/Driver/Driver.cpp#L166-L192
?

Or, probably more accurate, `customResourcePathReleativeToDriver` (long names are fine with me).

Wouldn't the above also add things that are only relevant for Clang? As in, shouldn't `GetResourcesPath` be specialised for Flang?

Btw, where is `ClangExecutable` defined? In ideal world it would be something more generic, e.g. `DriverExecutable`. But I appreciate that that's tangential to this change :)

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


More information about the flang-commits mailing list