Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[Flang][Driver] Add -print-resource-dir command line flag to emit Flang's resource directory" #96557

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

DavidTruby
Copy link
Member

Reverts #90886

These changes broke linking to compiler-rt on Windows

@DavidTruby DavidTruby requested a review from mjklemm June 24, 2024 20:54
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' flang:driver flang Flang issues not falling into any other category labels Jun 24, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 24, 2024

@llvm/pr-subscribers-clang-driver
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-flang-driver

Author: David Truby (DavidTruby)

Changes

Reverts llvm/llvm-project#90886

These changes broke linking to compiler-rt on Windows


Full diff: https://github.com/llvm/llvm-project/pull/96557.diff

4 Files Affected:

  • (modified) clang/include/clang/Driver/Driver.h (-3)
  • (modified) clang/include/clang/Driver/Options.td (+1-4)
  • (modified) clang/lib/Driver/Driver.cpp (+3-19)
  • (removed) flang/test/Driver/print-resource-dir.F90 (-4)
diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h
index 084c3ffe69ae8..cc1538372d5f8 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -747,9 +747,6 @@ class Driver {
   /// option.
   void setDriverMode(StringRef DriverModeValue);
 
-  /// Set the resource directory, depending on which driver is being used.
-  void setResourceDirectory();
-
   /// Parse the \p Args list for LTO options and record the type of LTO
   /// compilation based on which -f(no-)?lto(=.*)? option occurs last.
   void setLTOMode(const llvm::opt::ArgList &Args);
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 6416261077ed1..dfdf0741e28eb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5535,10 +5535,7 @@ 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">,
-  HelpTextForVariants<[FlangOption],
-                      "Print the resource directory pathname that contains lib and "
-                      "include directories with the runtime libraries and MODULE files.">,
-  Visibility<[ClangOption, CLOption, FlangOption]>;
+  Visibility<[ClangOption, CLOption]>;
 def print_search_dirs : Flag<["-", "--"], "print-search-dirs">,
   HelpText<"Print the paths used for finding libraries and programs">,
   Visibility<[ClangOption, CLOption]>;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 0298d22203d9d..33ab7cc3f3968 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -229,6 +229,9 @@ Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
     UserConfigDir = static_cast<std::string>(P);
   }
 #endif
+
+  // Compute the path to the resource directory.
+  ResourceDir = GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
 }
 
 void Driver::setDriverMode(StringRef Value) {
@@ -247,24 +250,6 @@ 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:
-    SmallString<64> customResourcePathRelativeToDriver{".."};
-    ResourceDir =
-        GetResourcesPath(ClangExecutable, customResourcePathRelativeToDriver);
-    break;
-  }
-}
-
 InputArgList Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings,
                                      bool UseDriverMode, bool &ContainsError) {
   llvm::PrettyStackTraceString CrashInfo("Command line argument parsing");
@@ -1217,7 +1202,6 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
   if (!DriverMode.empty())
     setDriverMode(DriverMode);
 
-  setResourceDirectory();
   // FIXME: What are we going to do with -V and -b?
 
   // Arguments specified in command line.
diff --git a/flang/test/Driver/print-resource-dir.F90 b/flang/test/Driver/print-resource-dir.F90
deleted file mode 100644
index 8fd35f1800df2..0000000000000
--- a/flang/test/Driver/print-resource-dir.F90
+++ /dev/null
@@ -1,4 +0,0 @@
-! 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]]

@DavidTruby DavidTruby merged commit a2d340b into main Jun 24, 2024
10 of 11 checks passed
@DavidTruby DavidTruby deleted the revert-90886-flang-print-resource-dir branch June 24, 2024 23:46
mjklemm added a commit that referenced this pull request Jun 28, 2024
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.
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
This PR re-enables the command line option `-print-resources-dir` after
PR llvm#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.
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
…emit Flang's resource directory" (llvm#96557)

Reverts llvm#90886

These changes broke linking to compiler-rt on Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants