From: Kienan Stewart Date: Wed, 2 Aug 2023 21:31:16 +0000 (-0400) Subject: jjb: Search for all available gcc binaries when selecting compiler X-Git-Url: http://git.liburcu.org/?a=commitdiff_plain;h=6c0b27105576fac689b415ae3fbdb98b8b0d6945;p=lttng-ci.git jjb: Search for all available gcc binaries when selecting compiler In searching through $PATH, the list of compiler versions to check doesn't need to be manually maintained Change-Id: I49f6a92e9319fc15cc8c31ff0ec7f458f355a709 --- diff --git a/scripts/lttng-modules/param-build.sh b/scripts/lttng-modules/param-build.sh index 4147c44..3657fc8 100644 --- a/scripts/lttng-modules/param-build.sh +++ b/scripts/lttng-modules/param-build.sh @@ -94,6 +94,16 @@ tar_archive_obj() { cd - } +list_gccs() { + local gccs + gccs=() + IFS=: read -r -a path_array <<< "$PATH" + while read -r gcc ; do + gccs+=("$gcc") + done < <(find "${path_array[@]}" -maxdepth 1 -regex '.*/gcc-[0-9\.]+$' -printf '%f\n' | sort -t- -k2 -V -r) + echo "${gccs[@]}" +} + # Find the most recent GCC version supported by the kernel sources select_compiler() { local selected_cc @@ -104,7 +114,7 @@ select_compiler() { set +e - for cc in gcc-8 gcc-5 gcc-4.8; do + for cc in $(list_gccs) ; do if "${CROSS_COMPILE:-}${cc}" -I include/ -D__LINUX_COMPILER_H -D__LINUX_COMPILER_TYPES_H -E include/linux/compiler-gcc.h; then selected_cc="$cc" break