[flang-commits] [flang] 8bbfdf8 - [flang] Get rid of code duplication in wrapper. Fix checking of undefined variables.
Yuri Gribov via flang-commits
flang-commits at lists.llvm.org
Wed Jan 26 00:42:43 PST 2022
Author: Yury Gribov
Date: 2022-01-26T11:42:03+03:00
New Revision: 8bbfdf8ec320e1d0d89f4babf81f4d003ce51e32
URL: https://github.com/llvm/llvm-project/commit/8bbfdf8ec320e1d0d89f4babf81f4d003ce51e32
DIFF: https://github.com/llvm/llvm-project/commit/8bbfdf8ec320e1d0d89f4babf81f4d003ce51e32.diff
LOG: [flang] Get rid of code duplication in wrapper. Fix checking of undefined variables.
Differential Revision: https://reviews.llvm.org/D117767
Added:
Modified:
flang/tools/f18/flang
Removed:
################################################################################
diff --git a/flang/tools/f18/flang b/flang/tools/f18/flang
index 10b055b09879..fc3a3a01556e 100755
--- a/flang/tools/f18/flang
+++ b/flang/tools/f18/flang
@@ -263,6 +263,22 @@ categorise_opts()
done
}
+# === get_external_fc_name ====================================================
+#
+# Returns the name of external Fortran compiler based on values of
+# environment variables.
+# =============================================================================
+get_external_fc_name() {
+ if [[ -v FLANG_FC ]]; then
+ echo ${FLANG_FC}
+ elif [[ -v F18_FC ]]; then
+ # We support F18_FC for backwards compatibility.
+ echo ${F18_FC}
+ else
+ echo gfortran
+ fi
+}
+
# === preprocess ==============================================================
#
# Runs the preprocessing. Fortran files are preprocessed using Flang. Other
@@ -278,18 +294,8 @@ preprocess() {
local -n other_srcs=$2
local -n opts=$3
- local ext_fc=""
- if [[ -v $FLANG_FC ]]; then
- ext_fc="${FLANG_FC}"
- elif [[ -v $F18_FC ]]; then
- # We support F18_FC for backwards compatibility.
- ext_fc="${F18_FC}"
- else
- ext_fc=gfortran
- fi
-
+ local ext_fc="$(get_external_fc_name)"
- local ext_fc="${FLANG_FC:-gfortran}"
local -r wd=$(cd "$(dirname "$0")/.." && pwd)
# Use the provided output file name.
@@ -412,7 +418,7 @@ main() {
done
# STEP 2: Compile Fortran Source Files
- readonly ext_fc="${F18_FC:-gfortran}"
+ local ext_fc="$(get_external_fc_name)"
# Temporary object files generated by this script. To be deleted at the end.
local temp_object_files=()
for idx in "${!fortran_source_files[@]}"; do
More information about the flang-commits
mailing list