Re: [LKP] Fix make.cross for 0day bot
From: Philip Li
Date: Thu Sep 01 2022 - 03:07:34 EST
On Thu, Sep 01, 2022 at 03:55:52PM +0900, Masahiro Yamada wrote:
> Hello, maintainers of Intel 0day bot,
>
> make.cross is supposed to use the latest GCC by default
> (according to the comment "use highest available version")
> but actually chooses GCC 9.3.0 rather than gcc-12.1.0.
thanks a lot for pointing out the issue and fixing it. Do you mind to send
a PR to https://github.com/intel/lkp-tests, or you suggest we composing
a patch based on your fix below?
>
> If both gcc-9.3.0-nolibc and gcc-12.1.0-nolibc exist
> in COMPILER_INSTALL_PATH, make.cross chooses gcc-9.3.0.
>
> Likewise, make.cross installs gcc-9.3.0 when no suitable compiler is found.
>
>
> This is due the fact that compiler is sorted like follows:
>
> gcc-10.2.0-nolibc
> gcc-10.3.0-nolibc
> gcc-11.1.0-nolibc
> gcc-11.2.0-nolibc
> gcc-11.3.0-nolibc
> gcc-12.1.0-nolibc
> gcc-4.9.4-nolibc
> gcc-5.5.0-nolibc
> gcc-6.4.0-nolibc
> gcc-6.5.0-nolibc
> gcc-7.5.0-nolibc
> gcc-8.1.0-nolibc
> gcc-9.2.0-nolibc
> gcc-9.3.0-nolibc
>
>
> Then, gcc-9.3.0-nolibc is picked up since it is listed at the last.
>
>
>
> 'sort -V' can do natural sort for versions:
>
> gcc-4.9.4-nolibc
> gcc-5.5.0-nolibc
> gcc-6.4.0-nolibc
> gcc-6.5.0-nolibc
> gcc-7.5.0-nolibc
> gcc-8.1.0-nolibc
> gcc-9.2.0-nolibc
> gcc-9.3.0-nolibc
> gcc-10.2.0-nolibc
> gcc-10.3.0-nolibc
> gcc-11.1.0-nolibc
> gcc-11.2.0-nolibc
> gcc-11.3.0-nolibc
> gcc-12.1.0-nolibc
>
>
>
>
> One example code change is like follows:
>
>
>
> --- make.cross.old 2022-09-01 12:18:20.933154233 +0900
> +++ make.cross 2022-09-01 15:06:48.995945712 +0900
> @@ -143,7 +143,7 @@
> local URL='https://download.01.org/0day-ci/cross-package'
> local list=/tmp/0day-ci-crosstool-files
>
> - lftp -c "open $URL && find -d 3 > $list" || return
> + lftp -c "open $URL && find -d 3" | sort -V > $list || return
>
> local file
> local gcc_arch_pattern=$(echo "${gcc_arch}" | sed 's/*/.*/g')
> @@ -206,7 +206,7 @@
> }
>
> # use highest available version
> - gcc_exec=${gcc_exec[-1]}
> + gcc_evec=$(tr ' ' '\n' <<< ${gcc_exec[@]} | sort -V | tail -n1)
> }
>
> update_path_env_for_parisc()
> @@ -340,7 +340,7 @@
>
> # load build-in depends libs
> local
> deplibs_path=($COMPILER_INSTALL_PATH/${COMPILER}*/${gcc_arch}/libexec/gcc/${gcc_arch}/*)
> - deplibs_path=${deplibs_path[-1]}
> + deplibs_path=$(tr ' ' '\n' <<< ${deplibs_path[@]} |
> sort -V | tail -n1)
> [[ -d $deplibs_path ]] && export
> LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$deplibs_path
>
> install_dependence "$gcc_exec" || return
>
>
>
> --
> Best Regards
> Masahiro Yamada
> _______________________________________________
> LKP mailing list -- lkp@xxxxxxxxxxxx
> To unsubscribe send an email to lkp-leave@xxxxxxxxxxxx