Skip to content

[flang][driver] Avoid mentions of Clang in Flang's command line reference. #88932

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

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

Meinersbur
Copy link
Member

The help text was not updated in #87360.

Clang is also mentioned for the diagnostic warnings reference, which mostly applies to C/C++/Obj-C, not Fortran. #81726 already tried to fix this, and I don't know a better solution.

The help text was not updated in llvm#87360.

Clang is also mentioned for the diagnositic warnings reference, which
mostly applies to C/C++/Obj-C, not Fortran. llvm#81726 already tried to fix
this, and I don't know a better solution.
@Meinersbur Meinersbur changed the title Avoid mentions of Clang in Flang's command line reference. [flang][driver] Avoid mentions of Clang in Flang's command line reference. Apr 16, 2024
@Meinersbur Meinersbur marked this pull request as ready for review April 17, 2024 07:59
@llvmbot llvmbot added clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category labels Apr 17, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 17, 2024

@llvm/pr-subscribers-clang

Author: Michael Kruse (Meinersbur)

Changes

The help text was not updated in #87360.

Clang is also mentioned for the diagnostic warnings reference, which mostly applies to C/C++/Obj-C, not Fortran. #81726 already tried to fix this, and I don't know a better solution.


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

3 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+6-2)
  • (modified) flang/test/Driver/driver-help-hidden.f90 (+1-1)
  • (modified) flang/test/Driver/driver-help.f90 (+1-1)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index e24626913add76..d89b53e4049cf6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -807,8 +807,12 @@ def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">,
   "Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation">;
 def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, FlangOption]>,
-  HelpText<"Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
-  "Clang will use the GCC installation with the largest version">;
+  HelpText<
+    "Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
+    "Clang will use the GCC installation with the largest version">,
+  HelpTextForVariants<[FlangOption],
+    "Specify a directory where Flang can find 'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
+    "Flang will use the GCC installation with the largest version">;
 def gcc_triple_EQ : Joined<["--"], "gcc-triple=">,
   HelpText<"Search for the GCC installation with the specified triple.">;
 def CC : Flag<["-"], "CC">, Visibility<[ClangOption, CC1Option]>,
diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90
index de2fe3048f993c..b5bb0f1c1b2560 100644
--- a/flang/test/Driver/driver-help-hidden.f90
+++ b/flang/test/Driver/driver-help-hidden.f90
@@ -109,7 +109,7 @@
 ! CHECK-NEXT: -fxor-operator          Enable .XOR. as a synonym of .NEQV.
 ! CHECK-NEXT: --gcc-install-dir=<value>
 ! CHECK-NEXT:                         Use GCC installation in the specified directory. The directory ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation
-! CHECK-NEXT: --gcc-toolchain=<value> Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Clang will use the GCC installation with the largest version
+! CHECK-NEXT: --gcc-toolchain=<value> Specify a directory where Flang can find 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Flang will use the GCC installation with the largest version
 ! CHECK-NEXT: -gline-directives-only  Emit debug line info directives only
 ! CHECK-NEXT: -gline-tables-only      Emit debug line number tables only
 ! CHECK-NEXT: -gpulibc                Link the LLVM C Library for GPUs
diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90
index b258eb59c18629..0b0a493baf07f7 100644
--- a/flang/test/Driver/driver-help.f90
+++ b/flang/test/Driver/driver-help.f90
@@ -97,7 +97,7 @@
 ! HELP-NEXT: -fxor-operator          Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: --gcc-install-dir=<value>
 ! HELP-NEXT:                         Use GCC installation in the specified directory. The directory ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation
-! HELP-NEXT: --gcc-toolchain=<value> Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Clang will use the GCC installation with the largest version
+! HELP-NEXT: --gcc-toolchain=<value> Specify a directory where Flang can find 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Flang will use the GCC installation with the largest version
 ! HELP-NEXT: -gline-directives-only  Emit debug line info directives only
 ! HELP-NEXT: -gline-tables-only      Emit debug line number tables only
 ! HELP-NEXT: -gpulibc                Link the LLVM C Library for GPUs

@llvmbot
Copy link
Member

llvmbot commented Apr 17, 2024

@llvm/pr-subscribers-flang-driver

Author: Michael Kruse (Meinersbur)

Changes

The help text was not updated in #87360.

Clang is also mentioned for the diagnostic warnings reference, which mostly applies to C/C++/Obj-C, not Fortran. #81726 already tried to fix this, and I don't know a better solution.


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

3 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+6-2)
  • (modified) flang/test/Driver/driver-help-hidden.f90 (+1-1)
  • (modified) flang/test/Driver/driver-help.f90 (+1-1)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index e24626913add76..d89b53e4049cf6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -807,8 +807,12 @@ def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">,
   "Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation">;
 def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, FlangOption]>,
-  HelpText<"Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
-  "Clang will use the GCC installation with the largest version">;
+  HelpText<
+    "Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
+    "Clang will use the GCC installation with the largest version">,
+  HelpTextForVariants<[FlangOption],
+    "Specify a directory where Flang can find 'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
+    "Flang will use the GCC installation with the largest version">;
 def gcc_triple_EQ : Joined<["--"], "gcc-triple=">,
   HelpText<"Search for the GCC installation with the specified triple.">;
 def CC : Flag<["-"], "CC">, Visibility<[ClangOption, CC1Option]>,
diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90
index de2fe3048f993c..b5bb0f1c1b2560 100644
--- a/flang/test/Driver/driver-help-hidden.f90
+++ b/flang/test/Driver/driver-help-hidden.f90
@@ -109,7 +109,7 @@
 ! CHECK-NEXT: -fxor-operator          Enable .XOR. as a synonym of .NEQV.
 ! CHECK-NEXT: --gcc-install-dir=<value>
 ! CHECK-NEXT:                         Use GCC installation in the specified directory. The directory ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation
-! CHECK-NEXT: --gcc-toolchain=<value> Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Clang will use the GCC installation with the largest version
+! CHECK-NEXT: --gcc-toolchain=<value> Specify a directory where Flang can find 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Flang will use the GCC installation with the largest version
 ! CHECK-NEXT: -gline-directives-only  Emit debug line info directives only
 ! CHECK-NEXT: -gline-tables-only      Emit debug line number tables only
 ! CHECK-NEXT: -gpulibc                Link the LLVM C Library for GPUs
diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90
index b258eb59c18629..0b0a493baf07f7 100644
--- a/flang/test/Driver/driver-help.f90
+++ b/flang/test/Driver/driver-help.f90
@@ -97,7 +97,7 @@
 ! HELP-NEXT: -fxor-operator          Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: --gcc-install-dir=<value>
 ! HELP-NEXT:                         Use GCC installation in the specified directory. The directory ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation
-! HELP-NEXT: --gcc-toolchain=<value> Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Clang will use the GCC installation with the largest version
+! HELP-NEXT: --gcc-toolchain=<value> Specify a directory where Flang can find 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Flang will use the GCC installation with the largest version
 ! HELP-NEXT: -gline-directives-only  Emit debug line info directives only
 ! HELP-NEXT: -gline-tables-only      Emit debug line number tables only
 ! HELP-NEXT: -gpulibc                Link the LLVM C Library for GPUs

Copy link
Contributor

@banach-space banach-space left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you! LGTM

@DavidSpickett
Copy link
Collaborator

Clang is also mentioned for the diagnostic warnings reference, which mostly applies to C/C++/Obj-C, not Fortran. #81726 already tried to fix this, and I don't know a better solution.

Do you mean that this PR fixes this, or that you noticed this problem while working on this?

If it's the latter it may be as @banach-space mentioned to me, that the docbrief is still shared between Flang and Clang. This could be solved in a similar, albeit tedious way to what I did for the help text.

@banach-space
Copy link
Contributor

Clang is also mentioned for the diagnostic warnings reference, which mostly applies to C/C++/Obj-C, not Fortran. #81726 already tried to fix this, and I don't know a better solution.

Do you mean that this PR fixes this, or that you noticed this problem while working on this?

If it's the latter it may be as @banach-space mentioned to me, that the docbrief is still shared between Flang and Clang. This could be solved in a similar, albeit tedious way to what I did for the help text.

@Meinersbur Could you share an example? If it's a problem specific to diagnostics then we should possibly just start separating Clang and Flang diagnostics. That could mean a bit of duplication, but not too much, so I'm not worried.

@Meinersbur
Copy link
Member Author

Do you mean that this PR fixes this, or that you noticed this problem while working on this?

I noticed this when working on the patch, .i.e that https://flang.llvm.org/docs/FlangCommandLineReference.html still mentioned Clang in several places and since it was common, I didn't want to fix it only for --gcc-toolchain. HelpTextForVariants was introduced later, reducing the number of "Clang" in FlangCommandLineReference already. This fixes --gcc-toolchain, but there is no list of warnings supported by Flang, so I don't have anything beyond what #81726 already did.

If it's the latter it may be as @banach-space mentioned to me, that the docbrief is still shared between Flang and Clang. This could be solved in a similar, albeit tedious way to what I did for the help text.

The docbrief strings already use %Program/GlobalDocumentation.Program which seems to work and made me think that HelpTextForVariants was actually unnecessary. Would you like me to introduce DocBriefForVariants?

@Meinersbur Could you share an example? If it's a problem specific to diagnostics then we should possibly just start separating Clang and Flang diagnostics. That could mean a bit of duplication, but not too much, so I'm not worried.

def Diag_Group : OptionGroup<"<W/R group>">, Group<CompileOnly_Group>,
                 DocName<"Diagnostic options">,
                 DocBrief<!strconcat(
                   StringForProgram<"Flags controlling which warnings, errors, and remarks %Program will generate. ">.str,
                   !cond(!eq(GlobalDocumentation.Program, "Clang"):
                       "See the :doc:`full list of warning and remark flags <DiagnosticsReference>`.",
                     true:
                       "See Clang's Diagnostic Reference for a full list of warning and remark flags."
                   )
                 )>;

@DavidSpickett
Copy link
Collaborator

DavidSpickett commented Apr 17, 2024

The docbrief strings already use %Program/GlobalDocumentation.Program which seems to work and made me think that HelpTextForVariants was actually unnecessary. Would you like me to introduce DocBriefForVariants?

IIRC it was unnecessary for the documentation because it gets built multiple times, for the driver it's built once so it has to include all possible variants the first time.

I have no preference for how it's done, if the %Program thing works then fine. We only need a ForVariants if it's something people see when interacting with Flang itself I think.

Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes themselves LGTM, thanks for fixing this.

@banach-space
Copy link
Contributor

Would you like me to introduce DocBriefForVariants?

+1 That would be helpful for -I:

Ideally we'd find more examples (so that you are not adding it for just one option).

As for this:

def Diag_Group : OptionGroup<"<W/R group>">, Group<CompileOnly_Group>,
                 DocName<"Diagnostic options">,
                 DocBrief<!strconcat(
                   StringForProgram<"Flags controlling which warnings, errors, and remarks %Program will generate. ">.str,
                   !cond(!eq(GlobalDocumentation.Program, "Clang"):
                       "See the :doc:`full list of warning and remark flags <DiagnosticsReference>`.",
                     true:
                       "See Clang's Diagnostic Reference for a full list of warning and remark flags."
                   )
                 )>;

Wouldn't replacing Clang's with %Program's be sufficient in this case?

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this PR look good to me. Thanks for the fix!

@Meinersbur
Copy link
Member Author

IIRC it was unnecessary for the documentation because it gets built multiple times, for the driver it's built once so it has to include all possible variants the first time.

I have no preference for how it's done, if the %Program thing works then fine. We only need a ForVariants if it's something people see when interacting with Flang itself I think.

I didn't know this and experimented a bit. Indeed %Program in HelpText gets emitted as "Clang" in flang-new --help. DocBrief and HelpText are "Flang" for FlangCommandLineReference.rst.

So DocBriefForVariant would not add new functionality, but might be useful so DocBrief[ForVariant] and HelpText[ForVariant] can use the same syntax and avoid confusion. I will merge this patch and work on DocBriefForVariant after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

6 participants