[clang] [flang] [Flang] Re-enable -print-resource-dir compiler option (PR #96799)

Michael Klemm via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 26 10:03:23 PDT 2024


https://github.com/mjklemm created https://github.com/llvm/llvm-project/pull/96799

This PR re-enables the command line option `-print-resources-dir` after PR #96557 has reverted the changes made.

The way this works now, is that it simply prints the current resource dir, which points to clang/$version.

>From 4384ec3965433ed4590a9403e71dad44ff7b0337 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Tue, 25 Jun 2024 09:59:42 +0200
Subject: [PATCH 1/2] Add test for -print-resource-dir

---
 flang/test/Driver/print-resource-dir.F90 | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 flang/test/Driver/print-resource-dir.F90

diff --git a/flang/test/Driver/print-resource-dir.F90 b/flang/test/Driver/print-resource-dir.F90
new file mode 100644
index 00000000000000..8fd35f1800df21
--- /dev/null
+++ b/flang/test/Driver/print-resource-dir.F90
@@ -0,0 +1,4 @@
+! DEFINE: %{resource_dir} = %S/Inputs/resource_dir
+! RUN: %flang -print-resource-dir -resource-dir=%{resource_dir}.. \
+! RUN:  | FileCheck -check-prefix=PRINT-RESOURCE-DIR -DFILE=%{resource_dir} %s
+! PRINT-RESOURCE-DIR: [[FILE]]

>From b4e9c8267072384434f957f5181638482ac7dcfc Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Tue, 25 Jun 2024 10:00:56 +0200
Subject: [PATCH 2/2] Add -print-resource-dir command line option for Flang

---
 clang/include/clang/Driver/Options.td | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index dd55838dcf384b..4c514197de3ac9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5535,7 +5535,10 @@ def print_prog_name_EQ : Joined<["-", "--"], "print-prog-name=">,
   Visibility<[ClangOption, CLOption]>;
 def print_resource_dir : Flag<["-", "--"], "print-resource-dir">,
   HelpText<"Print the resource directory pathname">,
-  Visibility<[ClangOption, CLOption]>;
+  HelpTextForVariants<[FlangOption],
+                      "Print the resource directory pathname that contains lib and "
+                      "include directories with the runtime libraries and MODULE files.">,
+  Visibility<[ClangOption, CLOption, FlangOption]>;
 def print_search_dirs : Flag<["-", "--"], "print-search-dirs">,
   HelpText<"Print the paths used for finding libraries and programs">,
   Visibility<[ClangOption, CLOption]>;



More information about the cfe-commits mailing list