[flang-commits] [flang] [flang][driver] support -dumpversion and -dumpmachine (PR #68896)
Yuanfang Chen via flang-commits
flang-commits at lists.llvm.org
Fri Oct 20 18:23:01 PDT 2023
https://github.com/yuanfang-chen updated https://github.com/llvm/llvm-project/pull/68896
>From db72a97acc7fd5a517b5ccd525fcf8a7b714fa29 Mon Sep 17 00:00:00 2001
From: Yuanfang Chen <tabloid.adroit at gmail.com>
Date: Sat, 21 Oct 2023 01:18:47 +0000
Subject: [PATCH] [flang][driver] support -dumpversion and -dumpmachine
Match GCC driver. GCC has -cc1/-fc1 support too, but this patch does not address that.
---
clang/include/clang/Driver/Options.td | 8 ++++++--
flang/test/Driver/driver-help-hidden.f90 | 2 ++
flang/test/Driver/driver-help.f90 | 2 ++
flang/test/Driver/dumpmachine.f90 | 8 ++++++++
flang/test/Driver/immediate-options.f90 | 2 ++
5 files changed, 20 insertions(+), 2 deletions(-)
create mode 100644 flang/test/Driver/dumpmachine.f90
create mode 100644 flang/test/Driver/immediate-options.f90
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index c272a7f1c398aa6..cae7bd07fc3cc54 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1375,9 +1375,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 807b0f938d27b5c..caea8880ba8fb8e 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 4894f90f5310439..1580c267cfc6ae6 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 flang-commits
mailing list