[flang-commits] [flang] 45e5214 - [flang][driver] Add support for `--version` in the bash wrapper

Andrzej Warzynski via flang-commits flang-commits at lists.llvm.org
Sat Jul 3 02:49:34 PDT 2021


Author: Andrzej Warzynski
Date: 2021-07-03T10:47:41+01:00
New Revision: 45e5214b4354d4f9150fcc1ea1997280f709b3dc

URL: https://github.com/llvm/llvm-project/commit/45e5214b4354d4f9150fcc1ea1997280f709b3dc
DIFF: https://github.com/llvm/llvm-project/commit/45e5214b4354d4f9150fcc1ea1997280f709b3dc.diff

LOG: [flang][driver] Add support for `--version` in the bash wrapper

The bash wrapper script, `flang`, calls `flang-new -fc1` under the hood,
which does not support `--version` (this is consistent with `clang -cc1
--version`). This change is needed for `flang --version` to work as
expected.

Note that `flang --version` (the Flang bash wrapper script for the
compiler driver) gives rather minimal output compared to `flang-new
--version` (the Flang compiler driver). As the wrapper script is just a
temporary solution for us, this should be sufficient.

Differential Revision: https://reviews.llvm.org/D105352

Added: 
    

Modified: 
    flang/tools/f18/flang.in

Removed: 
    


################################################################################
diff  --git a/flang/tools/f18/flang.in b/flang/tools/f18/flang.in
index f0371efecd849..9620821dc1d35 100755
--- a/flang/tools/f18/flang.in
+++ b/flang/tools/f18/flang.in
@@ -24,6 +24,7 @@ INTRINSICS_MOD_DIR=""
 COMPILE_ONLY="False"
 PREPROCESS_ONLY="False"
 TEMP_OUTPUT="flang_temp_out_"
+PRINT_VERSION="False"
 
 # === parse_args ==============================================================
 #
@@ -90,6 +91,10 @@ parse_args()
           PREPROCESS_ONLY="True"
         fi
 
+        if [[ $1 == "-v" || $1 == "--version" ]]; then
+          PRINT_VERSION="True"
+        fi
+
         shift
         continue
 
@@ -204,7 +209,6 @@ categorise_opts()
       [[ $opt == "-pedantic" ]] ||
       [[ $opt =~ ^-std=.* ]] ||
       [[ $opt =~ ^-U.* ]] ||
-      [[ $opt == "--version" ]] ||
       [[ $opt == "-Werror" ]]; then
       flang_opts+=($opt)
     elif [[ $opt =~ -I.* ]] || [[ $opt =~ -J.* ]]; then
@@ -266,6 +270,11 @@ preprocess() {
 main() {
   parse_args "$@"
 
+  if [[ $PRINT_VERSION == "True" ]]; then
+    echo "flang version @FLANG_VERSION@"
+    exit 0
+  fi
+
   fortran_source_files=()
   other_source_files=()
   object_files=()


        


More information about the flang-commits mailing list