[PATCH] D116608: [flang] Document the requirements for the `flang` wrapper script
Andrzej Warzynski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 6 04:11:02 PST 2022
awarzynski updated this revision to Diff 397851.
awarzynski added a comment.
Add a function to check the Bash version. It will exit immediately if an unsupported version of Bash is used.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116608/new/
https://reviews.llvm.org/D116608
Files:
flang/tools/f18/flang
Index: flang/tools/f18/flang
===================================================================
--- flang/tools/f18/flang
+++ flang/tools/f18/flang
@@ -12,6 +12,9 @@
# * run Flang's compiler driver to unparse the input source files
# * use the external compiler (defined via FLANG_FC environment variable) to
# compile the unparsed source files
+#
+# Tested with Bash 4.4.23. This script will exit immediately if you use an
+# older version of Bash.
#===------------------------------------------------------------------------===#
set -euo pipefail
@@ -25,6 +28,27 @@
PREPROCESS_ONLY="False"
PRINT_VERSION="False"
+# === check_bash_version ======================================================
+#
+# Checks the Bash version that's used to run this script. Exits immediately if
+# it's lower than 4.4.23
+# =============================================================================
+check_bash_version() {
+ message="Error: Your Bash is too old. Please use Bash >= 4.4.23"
+ # Major version
+ [[ "${BASH_VERSINFO[0]:-0}" -lt 4 ]] && echo $message && exit 1
+
+ # Minor version
+ if [[ "${BASH_VERSINFO[0]}" == 4 ]]; then
+ [[ "${BASH_VERSINFO[1]:-0}" -lt 4 ]] && echo $message && exit 1
+ fi
+
+ # Patch version
+ if [[ "${BASH_VERSINFO[0]}" == 4 ]] && [[ "${BASH_VERSINFO[1]}" == 4 ]] ; then
+ [[ "${BASH_VERSINFO[2]:-0}" -lt 23 ]] && echo $message && exit 1
+ fi
+}
+
# === parse_args ==============================================================
#
# Parse the input arguments passed to this script. Sets the global variables
@@ -323,6 +347,7 @@
# Main entry point for this script
# =============================================================================
main() {
+ check_bash_version
parse_args "$@"
if [[ $PRINT_VERSION == "True" ]]; then
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116608.397851.patch
Type: text/x-patch
Size: 1801 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220106/8f25a981/attachment.bin>
More information about the llvm-commits
mailing list