[clang] 1072fcd - [flang][driver] support -dumpversion and -dumpmachine (#68896)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 24 01:32:43 PDT 2023


Author: Yuanfang Chen
Date: 2023-10-24T01:32:39-07:00
New Revision: 1072fcd222468d36b1d4633f1a091a3376831ae3

URL: https://github.com/llvm/llvm-project/commit/1072fcd222468d36b1d4633f1a091a3376831ae3
DIFF: https://github.com/llvm/llvm-project/commit/1072fcd222468d36b1d4633f1a091a3376831ae3.diff

LOG: [flang][driver] support -dumpversion and -dumpmachine (#68896)

Match GCC driver. GCC has -cc1/-fc1 support too, but this patch does not
address that.

Added: 
    flang/test/Driver/dumpmachine.f90
    flang/test/Driver/immediate-options.f90

Modified: 
    clang/include/clang/Driver/Options.td
    flang/test/Driver/driver-help-hidden.f90
    flang/test/Driver/driver-help.f90

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index e63158fb0e5333a..99e0f823299a999 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1382,9 +1382,13 @@ def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,
 def dumpdir : Separate<["-"], "dumpdir">, Visibility<[ClangOption, CC1Option]>,
   MetaVarName<"<dumppfx>">,
   HelpText<"Use <dumpfpx> as a prefix to form auxiliary and dump file names">;
-def dumpmachine : Flag<["-"], "dumpmachine">;
+def dumpmachine : Flag<["-"], "dumpmachine">,
+  Visibility<[ClangOption, FlangOption]>,
+  HelpText<"Display the compiler's target processor">;
+def dumpversion : Flag<["-"], "dumpversion">,
+  Visibility<[ClangOption, FlangOption]>,
+  HelpText<"Display the version of the compiler">;
 def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>;
-def dumpversion : Flag<["-"], "dumpversion">;
 def dylib__file : Separate<["-"], "dylib_file">;
 def dylinker__install__name : JoinedOrSeparate<["-"], "dylinker_install_name">;
 def dylinker : Flag<["-"], "dylinker">;

diff  --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90
index 0edb84d25f4de37..6d399f1d179a022 100644
--- a/flang/test/Driver/driver-help-hidden.f90
+++ b/flang/test/Driver/driver-help-hidden.f90
@@ -21,6 +21,8 @@
 ! CHECK-NEXT: -ccc-print-phases       Dump list of actions to perform
 ! CHECK-NEXT: -cpp                    Enable predefined and command line preprocessor macros
 ! CHECK-NEXT: -c                      Only run preprocess, compile, and assemble steps
+! CHECK-NEXT: -dumpmachine            Display the compiler's target processor
+! CHECK-NEXT: -dumpversion            Display the version of the compiler
 ! CHECK-NEXT: -D <macro>=<value>      Define <macro> to <value> (or 1 if <value> omitted)
 ! CHECK-NEXT: -emit-llvm              Use the LLVM representation for assembler and object files
 ! CHECK-NEXT: -E                      Only run the preprocessor

diff  --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90
index 53b05a5ac104a7b..31c9caa32ea8292 100644
--- a/flang/test/Driver/driver-help.f90
+++ b/flang/test/Driver/driver-help.f90
@@ -17,6 +17,8 @@
 ! HELP-NEXT: -###                    Print (but do not run) the commands to run for this compilation
 ! HELP-NEXT: -cpp                    Enable predefined and command line preprocessor macros
 ! HELP-NEXT: -c                      Only run preprocess, compile, and assemble steps
+! HELP-NEXT: -dumpmachine            Display the compiler's target processor
+! HELP-NEXT: -dumpversion            Display the version of the compiler
 ! HELP-NEXT: -D <macro>=<value>      Define <macro> to <value> (or 1 if <value> omitted)
 ! HELP-NEXT: -emit-llvm              Use the LLVM representation for assembler and object files
 ! HELP-NEXT: -E                      Only run the preprocessor

diff  --git a/flang/test/Driver/dumpmachine.f90 b/flang/test/Driver/dumpmachine.f90
new file mode 100644
index 000000000000000..b68705707eefa04
--- /dev/null
+++ b/flang/test/Driver/dumpmachine.f90
@@ -0,0 +1,8 @@
+! Test that -dumpmachine prints the target triple.
+
+! Note: Debian GCC may omit "unknown-".
+! RUN: %flang --target=x86_64-linux-gnu -dumpmachine | FileCheck %s --check-prefix=X86_64
+! X86_64: x86_64-unknown-linux-gnu
+
+! RUN: %flang --target=xxx-pc-freebsd -dumpmachine | FileCheck %s --check-prefix=FREEBSD
+! FREEBSD: xxx-pc-freebsd

diff  --git a/flang/test/Driver/immediate-options.f90 b/flang/test/Driver/immediate-options.f90
new file mode 100644
index 000000000000000..81c1e7181ba7935
--- /dev/null
+++ b/flang/test/Driver/immediate-options.f90
@@ -0,0 +1,2 @@
+! RUN: %flang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
+! DUMPVERSION: {{[0-9]+\.[0-9.]+}}


        


More information about the cfe-commits mailing list