In searching through $PATH, the list of compiler versions to check
doesn't need to be manually maintained
Change-Id: I49f6a92e9319fc15cc8c31ff0ec7f458f355a709
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
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