Skip to content

Commit 1072fcd

Browse files
[flang][driver] support -dumpversion and -dumpmachine (#68896)
Match GCC driver. GCC has -cc1/-fc1 support too, but this patch does not address that.
1 parent ba468d4 commit 1072fcd

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

clang/include/clang/Driver/Options.td

+6-2
Original file line numberDiff line numberDiff line change
@@ -1382,9 +1382,13 @@ def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,
13821382
def dumpdir : Separate<["-"], "dumpdir">, Visibility<[ClangOption, CC1Option]>,
13831383
MetaVarName<"<dumppfx>">,
13841384
HelpText<"Use <dumpfpx> as a prefix to form auxiliary and dump file names">;
1385-
def dumpmachine : Flag<["-"], "dumpmachine">;
1385+
def dumpmachine : Flag<["-"], "dumpmachine">,
1386+
Visibility<[ClangOption, FlangOption]>,
1387+
HelpText<"Display the compiler's target processor">;
1388+
def dumpversion : Flag<["-"], "dumpversion">,
1389+
Visibility<[ClangOption, FlangOption]>,
1390+
HelpText<"Display the version of the compiler">;
13861391
def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>;
1387-
def dumpversion : Flag<["-"], "dumpversion">;
13881392
def dylib__file : Separate<["-"], "dylib_file">;
13891393
def dylinker__install__name : JoinedOrSeparate<["-"], "dylinker_install_name">;
13901394
def dylinker : Flag<["-"], "dylinker">;

flang/test/Driver/driver-help-hidden.f90

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
! CHECK-NEXT: -ccc-print-phases Dump list of actions to perform
2222
! CHECK-NEXT: -cpp Enable predefined and command line preprocessor macros
2323
! CHECK-NEXT: -c Only run preprocess, compile, and assemble steps
24+
! CHECK-NEXT: -dumpmachine Display the compiler's target processor
25+
! CHECK-NEXT: -dumpversion Display the version of the compiler
2426
! CHECK-NEXT: -D <macro>=<value> Define <macro> to <value> (or 1 if <value> omitted)
2527
! CHECK-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
2628
! CHECK-NEXT: -E Only run the preprocessor

flang/test/Driver/driver-help.f90

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
! HELP-NEXT: -### Print (but do not run) the commands to run for this compilation
1818
! HELP-NEXT: -cpp Enable predefined and command line preprocessor macros
1919
! HELP-NEXT: -c Only run preprocess, compile, and assemble steps
20+
! HELP-NEXT: -dumpmachine Display the compiler's target processor
21+
! HELP-NEXT: -dumpversion Display the version of the compiler
2022
! HELP-NEXT: -D <macro>=<value> Define <macro> to <value> (or 1 if <value> omitted)
2123
! HELP-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
2224
! HELP-NEXT: -E Only run the preprocessor

flang/test/Driver/dumpmachine.f90

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
! Test that -dumpmachine prints the target triple.
2+
3+
! Note: Debian GCC may omit "unknown-".
4+
! RUN: %flang --target=x86_64-linux-gnu -dumpmachine | FileCheck %s --check-prefix=X86_64
5+
! X86_64: x86_64-unknown-linux-gnu
6+
7+
! RUN: %flang --target=xxx-pc-freebsd -dumpmachine | FileCheck %s --check-prefix=FREEBSD
8+
! FREEBSD: xxx-pc-freebsd
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
! RUN: %flang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
2+
! DUMPVERSION: {{[0-9]+\.[0-9.]+}}

0 commit comments

Comments
 (0)