[5/6] configure: Allow user override LD, AR, OBJCOPY, and GPROF

Message ID 20221202190030.1671870-6-adhemerval.zanella@linaro.org
State Superseded
Headers
Series Refactor binutils configure usage |

Commit Message

Adhemerval Zanella Dec. 2, 2022, 7 p.m. UTC
  The only way to override LD, AR, OBJCOPY, and GPROF is through
--with-binutils (setting the environments variables on configure is
overridden by LIBC_PROG_BINUTILS).
---
 aclocal.m4 | 16 ++++++++++++----
 configure  | 16 ++++++++++++----
 2 files changed, 24 insertions(+), 8 deletions(-)
  

Comments

Carlos O'Donell Dec. 5, 2022, 3:56 p.m. UTC | #1
On 12/2/22 14:00, Adhemerval Zanella via Libc-alpha wrote:
> The only way to override LD, AR, OBJCOPY, and GPROF is through
> --with-binutils (setting the environments variables on configure is
> overridden by LIBC_PROG_BINUTILS).

If this is true then doesn't build-many-glibcs.py need --with-binutils?

We set LD, AR, OBJCOPY in bmg (not GPROF though).

I'd think we'd either set them or let the defaults be used (remove their setting).

> ---
>  aclocal.m4 | 16 ++++++++++++----
>  configure  | 16 ++++++++++++----
>  2 files changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/aclocal.m4 b/aclocal.m4
> index 7ab8ac023b..cbe3c4698a 100644
> --- a/aclocal.m4
> +++ b/aclocal.m4
> @@ -118,12 +118,20 @@ case "$CC" in
>      *fuse-ld=lld*) LDNAME=ld.lld;;
>      *)             LDNAME=ld;;
>  esac
> -LD=`$CC -print-prog-name=$LDNAME`
> -AR=`$CC -print-prog-name=ar`
> +if test -z "$LD"; then
> +    LD=`$CC -print-prog-name=$LDNAME`
> +fi
> +if test -z "$AR"; then
> +    AR=`$CC -print-prog-name=ar`
> +fi
>  AC_SUBST(AR)
> -OBJCOPY=`$CC -print-prog-name=objcopy`
> +if test -z "$OBJCOPY"; then
> +    OBJCOPY=`$CC -print-prog-name=objcopy`
> +fi
>  AC_SUBST(OBJCOPY)
> -GPROF=`$CC -print-prog-name=gprof`
> +if test -z "$GPROF"; then
> +    GPROF=`$CC -print-prog-name=gprof`
> +fi
>  AC_SUBST(GPROF)
>  ])

OK.

>  
> diff --git a/configure b/configure
> index 62c2581cb0..8f91bb6e11 100755
> --- a/configure
> +++ b/configure

Regenerate.

> @@ -4145,12 +4145,20 @@ case "$CC" in
>      *fuse-ld=lld*) LDNAME=ld.lld;;
>      *)             LDNAME=ld;;
>  esac
> -LD=`$CC -print-prog-name=$LDNAME`
> -AR=`$CC -print-prog-name=ar`
> +if test -z "$LD"; then
> +    LD=`$CC -print-prog-name=$LDNAME`
> +fi
> +if test -z "$AR"; then
> +    AR=`$CC -print-prog-name=ar`
> +fi
>  
> -OBJCOPY=`$CC -print-prog-name=objcopy`
> +if test -z "$OBJCOPY"; then
> +    OBJCOPY=`$CC -print-prog-name=objcopy`
> +fi
>  
> -GPROF=`$CC -print-prog-name=gprof`
> +if test -z "$GPROF"; then
> +    GPROF=`$CC -print-prog-name=gprof`
> +fi
>  
>  
>
  
Adhemerval Zanella Dec. 7, 2022, 8:04 p.m. UTC | #2
On 05/12/22 12:56, Carlos O'Donell wrote:
> On 12/2/22 14:00, Adhemerval Zanella via Libc-alpha wrote:
>> The only way to override LD, AR, OBJCOPY, and GPROF is through
>> --with-binutils (setting the environments variables on configure is
>> overridden by LIBC_PROG_BINUTILS).
> 
> If this is true then doesn't build-many-glibcs.py need --with-binutils?
> 
> We set LD, AR, OBJCOPY in bmg (not GPROF though).
> 
> I'd think we'd either set them or let the defaults be used (remove their setting).

build-many-glibcs.py (bmg) glibcs option generates a working config, but not
fully concise:

$ grep -e "AR =" -e "AS =" -e "LD =" -e "NM =" -e "OBJCOPY =" -e "OBJDUMP =" -e "RANLIB =" -e "READELF =" -e "STRIP =" config.make
AR = [...]/x86_64-linux-gnu/bin/../lib/gcc/x86_64-glibc-linux-gnu/12.1.1/../../../../x86_64-glibc-linux-gnu/bin/ar
NM = x86_64-glibc-linux-gnu-nm
AS = $(CC) -c
OBJDUMP = [...]/x86_64-linux-gnu/bin/../lib/gcc/x86_64-glibc-linux-gnu/12.1.1/../../../../x86_64-glibc-linux-gnu/bin/objdump
OBJCOPY = [...]/x86_64-linux-gnu/bin/../lib/gcc/x86_64-glibc-linux-gnu/12.1.1/../../../../x86_64-glibc-linux-gnu/bin/objcopy
READELF = x86_64-glibc-linux-gnu-readelf

So some tools are set from "$CC --print-prog-name", while others are set from
the environment variable.  It works for bmg because it sets the PATH to the
bmg own toolchain.

So I agree that with this change there is no need to setup the bmg env. vars
anymore.  I have sent an updated version.
  

Patch

diff --git a/aclocal.m4 b/aclocal.m4
index 7ab8ac023b..cbe3c4698a 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -118,12 +118,20 @@  case "$CC" in
     *fuse-ld=lld*) LDNAME=ld.lld;;
     *)             LDNAME=ld;;
 esac
-LD=`$CC -print-prog-name=$LDNAME`
-AR=`$CC -print-prog-name=ar`
+if test -z "$LD"; then
+    LD=`$CC -print-prog-name=$LDNAME`
+fi
+if test -z "$AR"; then
+    AR=`$CC -print-prog-name=ar`
+fi
 AC_SUBST(AR)
-OBJCOPY=`$CC -print-prog-name=objcopy`
+if test -z "$OBJCOPY"; then
+    OBJCOPY=`$CC -print-prog-name=objcopy`
+fi
 AC_SUBST(OBJCOPY)
-GPROF=`$CC -print-prog-name=gprof`
+if test -z "$GPROF"; then
+    GPROF=`$CC -print-prog-name=gprof`
+fi
 AC_SUBST(GPROF)
 ])
 
diff --git a/configure b/configure
index 62c2581cb0..8f91bb6e11 100755
--- a/configure
+++ b/configure
@@ -4145,12 +4145,20 @@  case "$CC" in
     *fuse-ld=lld*) LDNAME=ld.lld;;
     *)             LDNAME=ld;;
 esac
-LD=`$CC -print-prog-name=$LDNAME`
-AR=`$CC -print-prog-name=ar`
+if test -z "$LD"; then
+    LD=`$CC -print-prog-name=$LDNAME`
+fi
+if test -z "$AR"; then
+    AR=`$CC -print-prog-name=ar`
+fi
 
-OBJCOPY=`$CC -print-prog-name=objcopy`
+if test -z "$OBJCOPY"; then
+    OBJCOPY=`$CC -print-prog-name=objcopy`
+fi
 
-GPROF=`$CC -print-prog-name=gprof`
+if test -z "$GPROF"; then
+    GPROF=`$CC -print-prog-name=gprof`
+fi