public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Make using non-default as/ld/etc easier.
@ 2021-08-22  7:11 Olivier Galibert
  2021-08-22 20:14 ` Fangrui Song
  2021-08-23  1:43 ` Mike Frysinger
  0 siblings, 2 replies; 7+ messages in thread
From: Olivier Galibert @ 2021-08-22  7:11 UTC (permalink / raw)
  To: libc-alpha

Add the configure parameters
--with-{as,ld,ar,objdump,objcopy,gprof}=path to optionally force the
path for these programs without having to tweak the output of
$CC -print-prog-name in some way.

In addition, when --with-{as,ld} is used the corresponding program
version is not check.  The user gets to keep all the pieces if it
blows.

In practice, according to a build log on x86-64, $AS and $LD are never
used directly.  $AR, $OBJDUMP and $OBJCOPY are though, and the llvm
variants don't seem to have any issue.

Signed-off-by: Olivier Galibert <galibert@pobox.com>
---
 aclocal.m4   | 31 ++++++++++++++----
 configure    | 89 +++++++++++++++++++++++++++++++++++++++++++---------
 configure.ac | 38 ++++++++++++----------
 3 files changed, 121 insertions(+), 37 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index c195c4db56..cf19230145 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -114,15 +114,34 @@ if test -n "$path_binutils"; then
     path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
     CC="$CC -B$path_binutils"
 fi
-AS=`$CC -print-prog-name=as`
-LD=`$CC -print-prog-name=ld`
-AR=`$CC -print-prog-name=ar`
+AC_ARG_WITH([as],
+    [AS_HELP_STRING([--with-as=path], [select the as program to use])],
+    [AS=$with_as],
+    [AS=`$CC -print-prog-name=as`])
+AC_ARG_WITH([ld],
+    [AS_HELP_STRING([--with-ld=path], [select the ld program to use])],
+    [LD=$with_ld],
+    [LD=`$CC -print-prog-name=ld`])
+AC_ARG_WITH([ar],
+    [AS_HELP_STRING([--with-ar=path], [select the ar program to use])],
+    [AR=$with_ar],
+    [AR=`$CC -print-prog-name=ar`])
+AC_ARG_WITH([objdump],
+    [AS_HELP_STRING([--with-objdump=path], [select the objdump program to use])],
+    [OBJDUMP=$with_objdump],
+    [OBJDUMP=`$CC -print-prog-name=objdump`])
+AC_ARG_WITH([objcopy],
+    [AS_HELP_STRING([--with-objcopy=path], [select the objcopy program to use])],
+    [OBJCOPY=$with_objcopy],
+    [OBJCOPY=`$CC -print-prog-name=objcopy`])
+AC_ARG_WITH([gprof],
+    [AS_HELP_STRING([--with-gprof=path], [select the gprof program to use])],
+    [GPROF=$with_gprof],
+    [GPROF=`$CC -print-prog-name=gprof`])
+
 AC_SUBST(AR)
-OBJDUMP=`$CC -print-prog-name=objdump`
 AC_SUBST(OBJDUMP)
-OBJCOPY=`$CC -print-prog-name=objcopy`
 AC_SUBST(OBJCOPY)
-GPROF=`$CC -print-prog-name=gprof`
 AC_SUBST(GPROF)
 
 # Determine whether we are using GNU binutils.
diff --git a/configure b/configure
index 7272fbf6ea..2778ac6307 100755
--- a/configure
+++ b/configure
@@ -793,6 +793,12 @@ enable_mathvec
 enable_cet
 enable_scv
 with_cpu
+with_as
+with_ld
+with_ar
+with_objdump
+with_objcopy
+with_gprof
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1483,6 +1489,12 @@ Optional Packages:
   --with-nonshared-cflags=CFLAGS
                           build nonshared libraries with additional CFLAGS
   --with-cpu=CPU          select code for CPU variant
+  --with-as=path          select the as program to use
+  --with-ld=path          select the ld program to use
+  --with-ar=path          select the ar program to use
+  --with-objdump=path     select the objdump program to use
+  --with-objcopy=path     select the objcopy program to use
+  --with-gprof=path       select the gprof program to use
 
 Some influential environment variables:
   CC          C compiler command
@@ -4549,15 +4561,58 @@ if test -n "$path_binutils"; then
     path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
     CC="$CC -B$path_binutils"
 fi
-AS=`$CC -print-prog-name=as`
-LD=`$CC -print-prog-name=ld`
-AR=`$CC -print-prog-name=ar`
 
-OBJDUMP=`$CC -print-prog-name=objdump`
+# Check whether --with-as was given.
+if test "${with_as+set}" = set; then :
+  withval=$with_as; AS=$with_as
+else
+  AS=`$CC -print-prog-name=as`
+fi
+
+
+# Check whether --with-ld was given.
+if test "${with_ld+set}" = set; then :
+  withval=$with_ld; LD=$with_ld
+else
+  LD=`$CC -print-prog-name=ld`
+fi
+
+
+# Check whether --with-ar was given.
+if test "${with_ar+set}" = set; then :
+  withval=$with_ar; AR=$with_ar
+else
+  AR=`$CC -print-prog-name=ar`
+fi
+
+
+# Check whether --with-objdump was given.
+if test "${with_objdump+set}" = set; then :
+  withval=$with_objdump; OBJDUMP=$with_objdump
+else
+  OBJDUMP=`$CC -print-prog-name=objdump`
+fi
+
+
+# Check whether --with-objcopy was given.
+if test "${with_objcopy+set}" = set; then :
+  withval=$with_objcopy; OBJCOPY=$with_objcopy
+else
+  OBJCOPY=`$CC -print-prog-name=objcopy`
+fi
+
+
+# Check whether --with-gprof was given.
+if test "${with_gprof+set}" = set; then :
+  withval=$with_gprof; GPROF=$with_gprof
+else
+  GPROF=`$CC -print-prog-name=gprof`
+fi
+
+
+
 
-OBJCOPY=`$CC -print-prog-name=objcopy`
 
-GPROF=`$CC -print-prog-name=gprof`
 
 
 # Determine whether we are using GNU binutils.
@@ -4599,8 +4654,9 @@ $as_echo "$libc_cv_prog_ld_gnu" >&6; }
 gnu_ld=$libc_cv_prog_ld_gnu
 
 
-# Accept binutils 2.25 or newer.
-for ac_prog in $AS
+# Accept binutils 2.25 or newer.  Don't check version if the path is forced.
+if test "x$with_as" == x; then :
+  for ac_prog in $AS
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4660,13 +4716,16 @@ $as_echo_n "checking version of $AS... " >&6; }
 $as_echo "$ac_prog_version" >&6; }
 fi
 if test $ac_verc_fail = yes; then
-  AS=: critic_missing="$critic_missing as"
+  AS=: critic_missing="$critic_missing GNU as"
 fi
 
 
-if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
-  # Accept gold 1.14 or higher
-  for ac_prog in $LD
+fi
+
+if test "x$with_as" == x; then :
+  if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
+     # Accept gold 1.14 or higher
+     for ac_prog in $LD
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4729,8 +4788,8 @@ if test $ac_verc_fail = yes; then
   LD=: critic_missing="$critic_missing GNU gold"
 fi
 
-else
-  for ac_prog in $LD
+   else
+     for ac_prog in $LD
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4793,6 +4852,8 @@ if test $ac_verc_fail = yes; then
   LD=: critic_missing="$critic_missing GNU ld"
 fi
 
+   fi
+
 fi
 
 # These programs are version sensitive.
diff --git a/configure.ac b/configure.ac
index af47cd51e6..e7af44ba91 100644
--- a/configure.ac
+++ b/configure.ac
@@ -989,24 +989,28 @@ AC_PROG_LN_S
 
 LIBC_PROG_BINUTILS
 
-# Accept binutils 2.25 or newer.
-AC_CHECK_PROG_VER(AS, $AS, --version,
-		  [GNU assembler.* \([0-9]*\.[0-9.]*\)],
-		  [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
-		  AS=: critic_missing="$critic_missing as")
-
-if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
-  # Accept gold 1.14 or higher
-  AC_CHECK_PROG_VER(LD, $LD, --version,
-		    [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
-		    [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
-		    LD=: critic_missing="$critic_missing GNU gold")
-else
-  AC_CHECK_PROG_VER(LD, $LD, --version,
-		    [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
+# Accept binutils 2.25 or newer.  Don't check version if the path is forced.
+AS_IF([test "x$with_as" == x],
+  [AC_CHECK_PROG_VER(AS, $AS, --version,
+		    [GNU assembler.* \([0-9]*\.[0-9.]*\)],
 		    [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
-		    LD=: critic_missing="$critic_missing GNU ld")
-fi
+		    AS=: critic_missing="$critic_missing GNU as")
+])
+
+AS_IF([test "x$with_as" == x],
+  [if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
+     # Accept gold 1.14 or higher
+     AC_CHECK_PROG_VER(LD, $LD, --version,
+		      [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
+		      [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
+		      LD=: critic_missing="$critic_missing GNU gold")
+   else
+     AC_CHECK_PROG_VER(LD, $LD, --version,
+		      [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
+		      [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
+		      LD=: critic_missing="$critic_missing GNU ld")
+   fi
+])
 
 # These programs are version sensitive.
 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
-- 
2.33.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Make using non-default as/ld/etc easier.
  2021-08-22  7:11 [PATCH] Make using non-default as/ld/etc easier Olivier Galibert
@ 2021-08-22 20:14 ` Fangrui Song
  2021-08-23  1:43 ` Mike Frysinger
  1 sibling, 0 replies; 7+ messages in thread
From: Fangrui Song @ 2021-08-22 20:14 UTC (permalink / raw)
  To: Olivier Galibert; +Cc: libc-alpha

On 2021-08-22, Olivier Galibert via Libc-alpha wrote:
>Add the configure parameters
>--with-{as,ld,ar,objdump,objcopy,gprof}=path to optionally force the
>path for these programs without having to tweak the output of
>$CC -print-prog-name in some way.
>
>In addition, when --with-{as,ld} is used the corresponding program
>version is not check.  The user gets to keep all the pieces if it
>blows.
>
>In practice, according to a build log on x86-64, $AS and $LD are never
>used directly.  $AR, $OBJDUMP and $OBJCOPY are though, and the llvm
>variants don't seem to have any issue.
>
>Signed-off-by: Olivier Galibert <galibert@pobox.com>

Thanks:) This will make
https://sourceware.org/pipermail/libc-alpha/2021-August/129864.html
("[PATCH v2 0/3] Allow LLD 13.0.0 and improve compatibility with gold and clang")
easier to use.

Currently I do
```
sudo ln -sf ~/Stable/bin/lld /usr/local/bin/ld
or
sudo ln -sf /usr/bin/ld.bfd /usr/local/bin/ld
``
when switching between GNU ld and LLD...

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Make using non-default as/ld/etc easier.
  2021-08-22  7:11 [PATCH] Make using non-default as/ld/etc easier Olivier Galibert
  2021-08-22 20:14 ` Fangrui Song
@ 2021-08-23  1:43 ` Mike Frysinger
  2021-08-23 19:17   ` Olivier Galibert
  1 sibling, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2021-08-23  1:43 UTC (permalink / raw)
  To: Olivier Galibert; +Cc: libc-alpha

On 22 Aug 2021 09:11, Olivier Galibert via Libc-alpha wrote:
> Add the configure parameters
> --with-{as,ld,ar,objdump,objcopy,gprof}=path to optionally force the
> path for these programs without having to tweak the output of
> $CC -print-prog-name in some way.
> 
> In addition, when --with-{as,ld} is used the corresponding program
> version is not check.  The user gets to keep all the pieces if it
> blows.
> 
> In practice, according to a build log on x86-64, $AS and $LD are never
> used directly.  $AR, $OBJDUMP and $OBJCOPY are though, and the llvm
> variants don't seem to have any issue.

i don't think we need configure flags for these.  we don't have them for CC
or CXX or CPP.  you just need to declare AC_ARG_VAR on these and omit the
AC_ARG_WITH logic.
-mike

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Make using non-default as/ld/etc easier.
  2021-08-23  1:43 ` Mike Frysinger
@ 2021-08-23 19:17   ` Olivier Galibert
  2021-08-23 21:33     ` Mike Frysinger
  0 siblings, 1 reply; 7+ messages in thread
From: Olivier Galibert @ 2021-08-23 19:17 UTC (permalink / raw)
  To: libc-alpha

Add the configure parameters
{AS,LD,AR,OBJDUMP,OBJCOPY,GPROF}=path to optionally force the
path for these programs without having to tweak the output of
$CC -print-prog-name in some way.

In addition, when {AS,LD}=... is used the corresponding program
version is not check.  The user gets to keep all the pieces if it
blows.

In practice, according to a build log on x86-64, $AS and $LD are never
used directly.  $AR, $OBJDUMP and $OBJCOPY are though, and the llvm
variants don't seem to have any issue.

v2: Use variable assignments instead of --with-xxx

Signed-off-by: Olivier Galibert <galibert@pobox.com>
---
 aclocal.m4   | 35 +++++++++++++++++++-----
 configure    | 75 ++++++++++++++++++++++++++++++++++++++++------------
 configure.ac | 38 ++++++++++++++------------
 3 files changed, 108 insertions(+), 40 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index c195c4db56..79e67a4c92 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -114,15 +114,38 @@ if test -n "$path_binutils"; then
     path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
     CC="$CC -B$path_binutils"
 fi
-AS=`$CC -print-prog-name=as`
-LD=`$CC -print-prog-name=ld`
-AR=`$CC -print-prog-name=ar`
+check_as_version=0
+AC_ARG_VAR([AS], [as program to use])
+if test -z "$AS"; then
+    AS=`$CC -print-prog-name=as`
+    check_as_version=1
+fi
+check_ld_version=0
+AC_ARG_VAR([LD], [ld program to use])
+if test -z "$LD"; then
+    LD=`$CC -print-prog-name=ld`
+    check_ld_version=1
+fi
+AC_ARG_VAR([AR], [ar program to use])
+if test -z "$AR"; then
+    AR=`$CC -print-prog-name=ar`
+fi
+AC_ARG_VAR([OBJDUMP], [objdump program to use])
+if test -z "$OBJDUMP"; then
+    OBJDUMP=`$CC -print-prog-name=objdump`
+fi
+AC_ARG_VAR([OBJCOPY], [objcopy program to use])
+if test -z "$OBJCOPY"; then
+    OBJCOPY=`$CC -print-prog-name=objcopy`
+fi
+AC_ARG_VAR([GPROF], [gprof program to use])
+if test -z "$GPROF"; then
+    GPROF=`$CC -print-prog-name=gprof`
+fi
+
 AC_SUBST(AR)
-OBJDUMP=`$CC -print-prog-name=objdump`
 AC_SUBST(OBJDUMP)
-OBJCOPY=`$CC -print-prog-name=objcopy`
 AC_SUBST(OBJCOPY)
-GPROF=`$CC -print-prog-name=gprof`
 AC_SUBST(GPROF)
 
 # Determine whether we are using GNU binutils.
diff --git a/configure b/configure
index 7272fbf6ea..23f5e69445 100755
--- a/configure
+++ b/configure
@@ -651,12 +651,12 @@ SED
 MAKEINFO
 MSGFMT
 MAKE
-LD
-AS
 GPROF
 OBJCOPY
 OBJDUMP
 AR
+LD
+AS
 LN_S
 INSTALL_DATA
 INSTALL_SCRIPT
@@ -805,7 +805,13 @@ CPPFLAGS
 CPP
 CXX
 CXXFLAGS
-CCC'
+CCC
+AS
+LD
+AR
+OBJDUMP
+OBJCOPY
+GPROF'
 ac_subdirs_all=''
 
 # Initialize some variables set by options.
@@ -1495,6 +1501,12 @@ Some influential environment variables:
   CPP         C preprocessor
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
+  AS          as program to use
+  LD          ld program to use
+  AR          ar program to use
+  OBJDUMP     objdump program to use
+  OBJCOPY     objcopy program to use
+  GPROF       gprof program to use
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -4549,15 +4561,38 @@ if test -n "$path_binutils"; then
     path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
     CC="$CC -B$path_binutils"
 fi
-AS=`$CC -print-prog-name=as`
-LD=`$CC -print-prog-name=ld`
-AR=`$CC -print-prog-name=ar`
+check_as_version=0
+
+if test -z "$AS"; then
+    AS=`$CC -print-prog-name=as`
+    check_as_version=1
+fi
+check_ld_version=0
+
+if test -z "$LD"; then
+    LD=`$CC -print-prog-name=ld`
+    check_ld_version=1
+fi
+
+if test -z "$AR"; then
+    AR=`$CC -print-prog-name=ar`
+fi
+
+if test -z "$OBJDUMP"; then
+    OBJDUMP=`$CC -print-prog-name=objdump`
+fi
+
+if test -z "$OBJCOPY"; then
+    OBJCOPY=`$CC -print-prog-name=objcopy`
+fi
+
+if test -z "$GPROF"; then
+    GPROF=`$CC -print-prog-name=gprof`
+fi
+
 
-OBJDUMP=`$CC -print-prog-name=objdump`
 
-OBJCOPY=`$CC -print-prog-name=objcopy`
 
-GPROF=`$CC -print-prog-name=gprof`
 
 
 # Determine whether we are using GNU binutils.
@@ -4599,8 +4634,9 @@ $as_echo "$libc_cv_prog_ld_gnu" >&6; }
 gnu_ld=$libc_cv_prog_ld_gnu
 
 
-# Accept binutils 2.25 or newer.
-for ac_prog in $AS
+# Accept binutils 2.25 or newer.  Don't check version if the path is forced.
+if test $check_as_version == 1; then :
+  for ac_prog in $AS
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4660,13 +4696,16 @@ $as_echo_n "checking version of $AS... " >&6; }
 $as_echo "$ac_prog_version" >&6; }
 fi
 if test $ac_verc_fail = yes; then
-  AS=: critic_missing="$critic_missing as"
+  AS=: critic_missing="$critic_missing GNU as"
 fi
 
 
-if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
-  # Accept gold 1.14 or higher
-  for ac_prog in $LD
+fi
+
+if test $check_ld_version == 1; then :
+  if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
+     # Accept gold 1.14 or higher
+     for ac_prog in $LD
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4729,8 +4768,8 @@ if test $ac_verc_fail = yes; then
   LD=: critic_missing="$critic_missing GNU gold"
 fi
 
-else
-  for ac_prog in $LD
+   else
+     for ac_prog in $LD
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4793,6 +4832,8 @@ if test $ac_verc_fail = yes; then
   LD=: critic_missing="$critic_missing GNU ld"
 fi
 
+   fi
+
 fi
 
 # These programs are version sensitive.
diff --git a/configure.ac b/configure.ac
index af47cd51e6..53462290a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -989,24 +989,28 @@ AC_PROG_LN_S
 
 LIBC_PROG_BINUTILS
 
-# Accept binutils 2.25 or newer.
-AC_CHECK_PROG_VER(AS, $AS, --version,
-		  [GNU assembler.* \([0-9]*\.[0-9.]*\)],
-		  [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
-		  AS=: critic_missing="$critic_missing as")
-
-if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
-  # Accept gold 1.14 or higher
-  AC_CHECK_PROG_VER(LD, $LD, --version,
-		    [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
-		    [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
-		    LD=: critic_missing="$critic_missing GNU gold")
-else
-  AC_CHECK_PROG_VER(LD, $LD, --version,
-		    [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
+# Accept binutils 2.25 or newer.  Don't check version if the path is forced.
+AS_IF([test $check_as_version == 1],
+  [AC_CHECK_PROG_VER(AS, $AS, --version,
+		    [GNU assembler.* \([0-9]*\.[0-9.]*\)],
 		    [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
-		    LD=: critic_missing="$critic_missing GNU ld")
-fi
+		    AS=: critic_missing="$critic_missing GNU as")
+])
+
+AS_IF([test $check_ld_version == 1],
+  [if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
+     # Accept gold 1.14 or higher
+     AC_CHECK_PROG_VER(LD, $LD, --version,
+		      [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
+		      [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
+		      LD=: critic_missing="$critic_missing GNU gold")
+   else
+     AC_CHECK_PROG_VER(LD, $LD, --version,
+		      [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
+		      [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
+		      LD=: critic_missing="$critic_missing GNU ld")
+   fi
+])
 
 # These programs are version sensitive.
 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
-- 
2.33.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Make using non-default as/ld/etc easier.
  2021-08-23 19:17   ` Olivier Galibert
@ 2021-08-23 21:33     ` Mike Frysinger
  2021-08-24  8:34       ` Olivier Galibert
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2021-08-23 21:33 UTC (permalink / raw)
  To: Olivier Galibert; +Cc: libc-alpha

On 23 Aug 2021 21:17, Olivier Galibert wrote:

just nits.  idea looks fine to me.

> --- a/aclocal.m4
> +++ b/aclocal.m4
> @@ -114,15 +114,38 @@ if test -n "$path_binutils"; then
>      path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
>      CC="$CC -B$path_binutils"
>  fi
> -AS=`$CC -print-prog-name=as`
> -LD=`$CC -print-prog-name=ld`
> -AR=`$CC -print-prog-name=ar`
> +check_as_version=0
> +AC_ARG_VAR([AS], [as program to use])
> +if test -z "$AS"; then
> +    AS=`$CC -print-prog-name=as`
> +    check_as_version=1
> +fi

we do 2 space indents

(i know the CC code above is broken, but best to not keep adding more)

> --- a/configure.ac
> +++ b/configure.ac
>
> +# Accept binutils 2.25 or newer.  Don't check version if the path is forced.

we've been inconsistent, but should use "dnl" instead of "#"

> +AS_IF([test $check_as_version == 1],
> +AS_IF([test $check_ld_version == 1],

== is a bashism.  you want = instead.
-mike

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Make using non-default as/ld/etc easier.
  2021-08-23 21:33     ` Mike Frysinger
@ 2021-08-24  8:34       ` Olivier Galibert
  2021-09-07  7:41         ` Olivier Galibert
  0 siblings, 1 reply; 7+ messages in thread
From: Olivier Galibert @ 2021-08-24  8:34 UTC (permalink / raw)
  To: libc-alpha

Add the configure parameters
{AS,LD,AR,OBJDUMP,OBJCOPY,GPROF}=path to optionally force the
path for these programs without having to tweak the output of
$CC -print-prog-name in some way.

In addition, when {AS,LD}=... is used the corresponding program
version is not check.  The user gets to keep all the pieces if it
blows.

In practice, according to a build log on x86-64, $AS and $LD are never
used directly.  $AR, $OBJDUMP and $OBJCOPY are though, and the llvm
variants don't seem to have any issue.

v2: Use variable assignments instead of --with-xxx
v3: Denitsify

Signed-off-by: Olivier Galibert <galibert@pobox.com>
---
 aclocal.m4   | 41 +++++++++++++++++++++------
 configure    | 80 +++++++++++++++++++++++++++++++++++++++-------------
 configure.ac | 38 ++++++++++++++-----------
 3 files changed, 113 insertions(+), 46 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index c195c4db56..6852875469 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -110,19 +110,42 @@ rm -fr contest*])
 AC_DEFUN([LIBC_PROG_BINUTILS],
 [# Was a --with-binutils option given?
 if test -n "$path_binutils"; then
-    # Make absolute; ensure a single trailing slash.
-    path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
-    CC="$CC -B$path_binutils"
+  # Make absolute; ensure a single trailing slash.
+  path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
+  CC="$CC -B$path_binutils"
 fi
-AS=`$CC -print-prog-name=as`
-LD=`$CC -print-prog-name=ld`
-AR=`$CC -print-prog-name=ar`
+check_as_version=0
+AC_ARG_VAR([AS], [as program to use])
+if test -z "$AS"; then
+  AS=`$CC -print-prog-name=as`
+  check_as_version=1
+fi
+check_ld_version=0
+AC_ARG_VAR([LD], [ld program to use])
+if test -z "$LD"; then
+  LD=`$CC -print-prog-name=ld`
+  check_ld_version=1
+fi
+AC_ARG_VAR([AR], [ar program to use])
+if test -z "$AR"; then
+  AR=`$CC -print-prog-name=ar`
+fi
+AC_ARG_VAR([OBJDUMP], [objdump program to use])
+if test -z "$OBJDUMP"; then
+  OBJDUMP=`$CC -print-prog-name=objdump`
+fi
+AC_ARG_VAR([OBJCOPY], [objcopy program to use])
+if test -z "$OBJCOPY"; then
+  OBJCOPY=`$CC -print-prog-name=objcopy`
+fi
+AC_ARG_VAR([GPROF], [gprof program to use])
+if test -z "$GPROF"; then
+  GPROF=`$CC -print-prog-name=gprof`
+fi
+
 AC_SUBST(AR)
-OBJDUMP=`$CC -print-prog-name=objdump`
 AC_SUBST(OBJDUMP)
-OBJCOPY=`$CC -print-prog-name=objcopy`
 AC_SUBST(OBJCOPY)
-GPROF=`$CC -print-prog-name=gprof`
 AC_SUBST(GPROF)
 
 # Determine whether we are using GNU binutils.
diff --git a/configure b/configure
index 7272fbf6ea..58a23f9b84 100755
--- a/configure
+++ b/configure
@@ -651,12 +651,12 @@ SED
 MAKEINFO
 MSGFMT
 MAKE
-LD
-AS
 GPROF
 OBJCOPY
 OBJDUMP
 AR
+LD
+AS
 LN_S
 INSTALL_DATA
 INSTALL_SCRIPT
@@ -805,7 +805,13 @@ CPPFLAGS
 CPP
 CXX
 CXXFLAGS
-CCC'
+CCC
+AS
+LD
+AR
+OBJDUMP
+OBJCOPY
+GPROF'
 ac_subdirs_all=''
 
 # Initialize some variables set by options.
@@ -1495,6 +1501,12 @@ Some influential environment variables:
   CPP         C preprocessor
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
+  AS          as program to use
+  LD          ld program to use
+  AR          ar program to use
+  OBJDUMP     objdump program to use
+  OBJCOPY     objcopy program to use
+  GPROF       gprof program to use
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -4545,19 +4557,42 @@ fi
 
 # Was a --with-binutils option given?
 if test -n "$path_binutils"; then
-    # Make absolute; ensure a single trailing slash.
-    path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
-    CC="$CC -B$path_binutils"
+  # Make absolute; ensure a single trailing slash.
+  path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
+  CC="$CC -B$path_binutils"
 fi
-AS=`$CC -print-prog-name=as`
-LD=`$CC -print-prog-name=ld`
-AR=`$CC -print-prog-name=ar`
+check_as_version=0
+
+if test -z "$AS"; then
+  AS=`$CC -print-prog-name=as`
+  check_as_version=1
+fi
+check_ld_version=0
+
+if test -z "$LD"; then
+  LD=`$CC -print-prog-name=ld`
+  check_ld_version=1
+fi
+
+if test -z "$AR"; then
+  AR=`$CC -print-prog-name=ar`
+fi
+
+if test -z "$OBJDUMP"; then
+  OBJDUMP=`$CC -print-prog-name=objdump`
+fi
+
+if test -z "$OBJCOPY"; then
+  OBJCOPY=`$CC -print-prog-name=objcopy`
+fi
+
+if test -z "$GPROF"; then
+  GPROF=`$CC -print-prog-name=gprof`
+fi
+
 
-OBJDUMP=`$CC -print-prog-name=objdump`
 
-OBJCOPY=`$CC -print-prog-name=objcopy`
 
-GPROF=`$CC -print-prog-name=gprof`
 
 
 # Determine whether we are using GNU binutils.
@@ -4599,8 +4634,8 @@ $as_echo "$libc_cv_prog_ld_gnu" >&6; }
 gnu_ld=$libc_cv_prog_ld_gnu
 
 
-# Accept binutils 2.25 or newer.
-for ac_prog in $AS
+if test $check_as_version = 1; then :
+  for ac_prog in $AS
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4660,13 +4695,16 @@ $as_echo_n "checking version of $AS... " >&6; }
 $as_echo "$ac_prog_version" >&6; }
 fi
 if test $ac_verc_fail = yes; then
-  AS=: critic_missing="$critic_missing as"
+  AS=: critic_missing="$critic_missing GNU as"
 fi
 
 
-if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
-  # Accept gold 1.14 or higher
-  for ac_prog in $LD
+fi
+
+if test $check_ld_version = 1; then :
+  if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
+     # Accept gold 1.14 or higher
+     for ac_prog in $LD
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4729,8 +4767,8 @@ if test $ac_verc_fail = yes; then
   LD=: critic_missing="$critic_missing GNU gold"
 fi
 
-else
-  for ac_prog in $LD
+   else
+     for ac_prog in $LD
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4793,6 +4831,8 @@ if test $ac_verc_fail = yes; then
   LD=: critic_missing="$critic_missing GNU ld"
 fi
 
+   fi
+
 fi
 
 # These programs are version sensitive.
diff --git a/configure.ac b/configure.ac
index af47cd51e6..a40652ad3c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -989,24 +989,28 @@ AC_PROG_LN_S
 
 LIBC_PROG_BINUTILS
 
-# Accept binutils 2.25 or newer.
-AC_CHECK_PROG_VER(AS, $AS, --version,
-		  [GNU assembler.* \([0-9]*\.[0-9.]*\)],
-		  [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
-		  AS=: critic_missing="$critic_missing as")
-
-if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
-  # Accept gold 1.14 or higher
-  AC_CHECK_PROG_VER(LD, $LD, --version,
-		    [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
-		    [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
-		    LD=: critic_missing="$critic_missing GNU gold")
-else
-  AC_CHECK_PROG_VER(LD, $LD, --version,
-		    [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
+dnl Accept binutils 2.25 or newer.  Don't check version if the path is forced.
+AS_IF([test $check_as_version = 1],
+  [AC_CHECK_PROG_VER(AS, $AS, --version,
+		    [GNU assembler.* \([0-9]*\.[0-9.]*\)],
 		    [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
-		    LD=: critic_missing="$critic_missing GNU ld")
-fi
+		    AS=: critic_missing="$critic_missing GNU as")
+])
+
+AS_IF([test $check_ld_version = 1],
+  [if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
+     # Accept gold 1.14 or higher
+     AC_CHECK_PROG_VER(LD, $LD, --version,
+		      [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
+		      [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
+		      LD=: critic_missing="$critic_missing GNU gold")
+   else
+     AC_CHECK_PROG_VER(LD, $LD, --version,
+		      [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
+		      [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
+		      LD=: critic_missing="$critic_missing GNU ld")
+   fi
+])
 
 # These programs are version sensitive.
 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
-- 
2.33.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Make using non-default as/ld/etc easier.
  2021-08-24  8:34       ` Olivier Galibert
@ 2021-09-07  7:41         ` Olivier Galibert
  0 siblings, 0 replies; 7+ messages in thread
From: Olivier Galibert @ 2021-09-07  7:41 UTC (permalink / raw)
  To: libc-alpha

Add the configure parameters
{AS,LD,AR,OBJDUMP,OBJCOPY,GPROF}=path to optionally force the
path for these programs without having to tweak the output of
$CC -print-prog-name in some way.

In addition, when {AS,LD}=... is used the corresponding program
version is not check.  The user gets to keep all the pieces if it
blows.

In practice, according to a build log on x86-64, $AS and $LD are never
used directly.  $AR, $OBJDUMP and $OBJCOPY are though, and the llvm
variants don't seem to have any issue.

v2: Use variable assignments instead of --with-xxx
v3: Denitsify
v4: Sync with 224edada607ebc6aaa1aadaae423128fae7880df

Signed-off-by: Olivier Galibert <galibert@pobox.com>
---
 aclocal.m4   | 41 +++++++++++++++++++++++-------
 configure    | 72 ++++++++++++++++++++++++++++++++++++++++------------
 configure.ac | 22 +++++++++-------
 3 files changed, 101 insertions(+), 34 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index c195c4db56..6852875469 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -110,19 +110,42 @@ rm -fr contest*])
 AC_DEFUN([LIBC_PROG_BINUTILS],
 [# Was a --with-binutils option given?
 if test -n "$path_binutils"; then
-    # Make absolute; ensure a single trailing slash.
-    path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
-    CC="$CC -B$path_binutils"
+  # Make absolute; ensure a single trailing slash.
+  path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
+  CC="$CC -B$path_binutils"
 fi
-AS=`$CC -print-prog-name=as`
-LD=`$CC -print-prog-name=ld`
-AR=`$CC -print-prog-name=ar`
+check_as_version=0
+AC_ARG_VAR([AS], [as program to use])
+if test -z "$AS"; then
+  AS=`$CC -print-prog-name=as`
+  check_as_version=1
+fi
+check_ld_version=0
+AC_ARG_VAR([LD], [ld program to use])
+if test -z "$LD"; then
+  LD=`$CC -print-prog-name=ld`
+  check_ld_version=1
+fi
+AC_ARG_VAR([AR], [ar program to use])
+if test -z "$AR"; then
+  AR=`$CC -print-prog-name=ar`
+fi
+AC_ARG_VAR([OBJDUMP], [objdump program to use])
+if test -z "$OBJDUMP"; then
+  OBJDUMP=`$CC -print-prog-name=objdump`
+fi
+AC_ARG_VAR([OBJCOPY], [objcopy program to use])
+if test -z "$OBJCOPY"; then
+  OBJCOPY=`$CC -print-prog-name=objcopy`
+fi
+AC_ARG_VAR([GPROF], [gprof program to use])
+if test -z "$GPROF"; then
+  GPROF=`$CC -print-prog-name=gprof`
+fi
+
 AC_SUBST(AR)
-OBJDUMP=`$CC -print-prog-name=objdump`
 AC_SUBST(OBJDUMP)
-OBJCOPY=`$CC -print-prog-name=objcopy`
 AC_SUBST(OBJCOPY)
-GPROF=`$CC -print-prog-name=gprof`
 AC_SUBST(GPROF)
 
 # Determine whether we are using GNU binutils.
diff --git a/configure b/configure
index 542802ad35..45dec1e621 100755
--- a/configure
+++ b/configure
@@ -651,12 +651,12 @@ SED
 MAKEINFO
 MSGFMT
 MAKE
-LD
-AS
 GPROF
 OBJCOPY
 OBJDUMP
 AR
+LD
+AS
 LN_S
 INSTALL_DATA
 INSTALL_SCRIPT
@@ -805,7 +805,13 @@ CPPFLAGS
 CPP
 CXX
 CXXFLAGS
-CCC'
+CCC
+AS
+LD
+AR
+OBJDUMP
+OBJCOPY
+GPROF'
 ac_subdirs_all=''
 
 # Initialize some variables set by options.
@@ -1495,6 +1501,12 @@ Some influential environment variables:
   CPP         C preprocessor
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
+  AS          as program to use
+  LD          ld program to use
+  AR          ar program to use
+  OBJDUMP     objdump program to use
+  OBJCOPY     objcopy program to use
+  GPROF       gprof program to use
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -4545,19 +4557,42 @@ fi
 
 # Was a --with-binutils option given?
 if test -n "$path_binutils"; then
-    # Make absolute; ensure a single trailing slash.
-    path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
-    CC="$CC -B$path_binutils"
+  # Make absolute; ensure a single trailing slash.
+  path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'`
+  CC="$CC -B$path_binutils"
 fi
-AS=`$CC -print-prog-name=as`
-LD=`$CC -print-prog-name=ld`
-AR=`$CC -print-prog-name=ar`
+check_as_version=0
+
+if test -z "$AS"; then
+  AS=`$CC -print-prog-name=as`
+  check_as_version=1
+fi
+check_ld_version=0
+
+if test -z "$LD"; then
+  LD=`$CC -print-prog-name=ld`
+  check_ld_version=1
+fi
+
+if test -z "$AR"; then
+  AR=`$CC -print-prog-name=ar`
+fi
+
+if test -z "$OBJDUMP"; then
+  OBJDUMP=`$CC -print-prog-name=objdump`
+fi
+
+if test -z "$OBJCOPY"; then
+  OBJCOPY=`$CC -print-prog-name=objcopy`
+fi
+
+if test -z "$GPROF"; then
+  GPROF=`$CC -print-prog-name=gprof`
+fi
+
 
-OBJDUMP=`$CC -print-prog-name=objdump`
 
-OBJCOPY=`$CC -print-prog-name=objcopy`
 
-GPROF=`$CC -print-prog-name=gprof`
 
 
 # Determine whether we are using GNU binutils.
@@ -4599,8 +4634,8 @@ $as_echo "$libc_cv_prog_ld_gnu" >&6; }
 gnu_ld=$libc_cv_prog_ld_gnu
 
 
-# Accept binutils 2.25 or newer.
-for ac_prog in $AS
+if test $check_as_version = 1; then :
+  for ac_prog in $AS
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4660,10 +4695,12 @@ $as_echo_n "checking version of $AS... " >&6; }
 $as_echo "$ac_prog_version" >&6; }
 fi
 if test $ac_verc_fail = yes; then
-  AS=: critic_missing="$critic_missing as"
+  AS=: critic_missing="$critic_missing GNU as"
 fi
 
 
+fi
+
 libc_cv_with_lld=no
 case $($LD --version) in
   "GNU gold"*)
@@ -4800,7 +4837,8 @@ fi
     libc_cv_with_lld=yes
     ;;
   *)
-    for ac_prog in $LD
+    if test $check_ld_version = 1; then :
+  for ac_prog in $LD
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4863,6 +4901,8 @@ if test $ac_verc_fail = yes; then
   LD=: critic_missing="$critic_missing GNU ld"
 fi
 
+
+fi
     ;;
 esac
 config_vars="$config_vars
diff --git a/configure.ac b/configure.ac
index d9232418de..f4ab9664ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -989,11 +989,13 @@ AC_PROG_LN_S
 
 LIBC_PROG_BINUTILS
 
-# Accept binutils 2.25 or newer.
-AC_CHECK_PROG_VER(AS, $AS, --version,
-		  [GNU assembler.* \([0-9]*\.[0-9.]*\)],
-		  [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
-		  AS=: critic_missing="$critic_missing as")
+dnl Accept binutils 2.25 or newer.  Don't check version if the path is forced.
+AS_IF([test $check_as_version = 1],
+  [AC_CHECK_PROG_VER(AS, $AS, --version,
+		    [GNU assembler.* \([0-9]*\.[0-9.]*\)],
+		    [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
+		    AS=: critic_missing="$critic_missing GNU as")
+])
 
 libc_cv_with_lld=no
 case $($LD --version) in
@@ -1013,10 +1015,12 @@ case $($LD --version) in
     libc_cv_with_lld=yes
     ;;
   *)
-    AC_CHECK_PROG_VER(LD, $LD, --version,
-		    [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
-		    [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
-		    LD=: critic_missing="$critic_missing GNU ld")
+    AS_IF([test $check_ld_version = 1],
+      [AC_CHECK_PROG_VER(LD, $LD, --version,
+			[GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
+			[2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
+			LD=: critic_missing="$critic_missing GNU ld")
+    ])
     ;;
 esac
 LIBC_CONFIG_VAR([with-lld], [$libc_cv_with_lld])
-- 
2.33.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-07  7:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-22  7:11 [PATCH] Make using non-default as/ld/etc easier Olivier Galibert
2021-08-22 20:14 ` Fangrui Song
2021-08-23  1:43 ` Mike Frysinger
2021-08-23 19:17   ` Olivier Galibert
2021-08-23 21:33     ` Mike Frysinger
2021-08-24  8:34       ` Olivier Galibert
2021-09-07  7:41         ` Olivier Galibert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).