jjb: Search for all available gcc binaries when selecting compiler
authorKienan Stewart <kstewart@efficios.com>
Wed, 2 Aug 2023 21:31:16 +0000 (17:31 -0400)
committerKienan Stewart <kstewart@efficios.com>
Mon, 7 Aug 2023 20:55:57 +0000 (16:55 -0400)
In searching through $PATH, the list of compiler versions to check
doesn't need to be manually maintained

Change-Id: I49f6a92e9319fc15cc8c31ff0ec7f458f355a709

scripts/lttng-modules/param-build.sh

index 4147c44a64a95688a6123680ccf5e50b7671ad0a..3657fc86a815caf2fdac06f991336e74aa49815d 100644 (file)
@@ -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
This page took 0.024445 seconds and 4 git commands to generate.