[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
Related show

Commit Message

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

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

-- 
2.31.1

Comments

Andreas Schwab July 20, 2021, 7:42 a.m. | #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.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Richard Biener via Gcc-patches July 21, 2021, 8:30 a.m. | #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. | #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.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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