diff mbox series

[committed] RISC-V: Detect python and pick best one for calling multilib-generator

Message ID 20210720032529.44593-1-kito.cheng@sifive.com
State New
Headers show
Series [committed] RISC-V: Detect python and pick best one for calling multilib-generator | expand

Commit Message

Kito Cheng July 20, 2021, 3:25 a.m. UTC
gcc/

	* config.gcc (riscv*-*-*): Detect which python is available.
---
 gcc/config.gcc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andreas Schwab July 20, 2021, 7:42 a.m. UTC | #1
On Jul 20 2021, Kito Cheng wrote:

> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index 93e2b3219b9..3df9b52cf25 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -4730,9 +4730,10 @@ case "${target}" in
>  				echo "--with-multilib-list= can't used with --with-multilib-generator= at same time" 1>&2
>  				exit 1
>  			fi
> +			PYTHON=`which python || which python3 || which python2`

which is a non-standard utility.  Additionally, you will get extra
output on stderr when one of the commands is not found.

Andreas.
Kito Cheng July 21, 2021, 8:30 a.m. UTC | #2
> > diff --git a/gcc/config.gcc b/gcc/config.gcc
> > index 93e2b3219b9..3df9b52cf25 100644
> > --- a/gcc/config.gcc
> > +++ b/gcc/config.gcc
> > @@ -4730,9 +4730,10 @@ case "${target}" in
> >                               echo "--with-multilib-list= can't used with --with-multilib-generator= at same time" 1>&2
> >                               exit 1
> >                       fi
> > +                     PYTHON=`which python || which python3 || which python2`
>
> which is a non-standard utility.

hmmm, good point, let me revert this at this moment.

> Additionally, you will get extra
> output on stderr when one of the commands is not found.

I tried PYTHON will get an empty string if all of those are not found,
no stderr from which command.
Andreas Schwab July 21, 2021, 8:45 a.m. UTC | #3
On Jul 21 2021, Kito Cheng wrote:

>> Additionally, you will get extra
>> output on stderr when one of the commands is not found.
>
> I tried PYTHON will get an empty string if all of those are not found,
> no stderr from which command.

$ PATH=/usr/bin which foo >/dev/null
which: no foo in (/usr/bin)

Andreas.
diff mbox series

Patch

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 93e2b3219b9..3df9b52cf25 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4730,9 +4730,10 @@  case "${target}" in
 				echo "--with-multilib-list= can't used with --with-multilib-generator= at same time" 1>&2
 				exit 1
 			fi
+			PYTHON=`which python || which python3 || which python2`
 			case "${target}" in
 			riscv*-*-elf*)
-				if ${srcdir}/config/riscv/multilib-generator \
+				if ${PYTHON} ${srcdir}/config/riscv/multilib-generator \
 					`echo ${with_multilib_generator} | sed 's/;/ /g'`\
 					> t-multilib-config;
 				then