From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from pb-smtp21.pobox.com (pb-smtp21.pobox.com [173.228.157.53]) by sourceware.org (Postfix) with ESMTPS id C613A3858C3B for ; Tue, 24 Aug 2021 08:34:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C613A3858C3B Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 8452013EE14; Tue, 24 Aug 2021 04:34:55 -0400 (EDT) (envelope-from galibert@pobox.com) Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 7CE3313EE13; Tue, 24 Aug 2021 04:34:55 -0400 (EDT) (envelope-from galibert@pobox.com) Received: from localhost.localdomain (unknown [78.197.126.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id CD0E713EE12; Tue, 24 Aug 2021 04:34:51 -0400 (EDT) (envelope-from galibert@pobox.com) From: Olivier Galibert To: libc-alpha@sourceware.org Subject: [PATCH] Make using non-default as/ld/etc easier. Date: Tue, 24 Aug 2021 10:34:02 +0200 Message-Id: <20210824083401.619318-1-galibert@pobox.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: 2712F136-04B6-11EC-A540-FA9E2DDBB1FC-92059326!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 08:35:07 -0000 Add the configure parameters {AS,LD,AR,OBJDUMP,OBJCOPY,GPROF}=3Dpath 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}=3D... 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 --- 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=3D`(cd $path_binutils; pwd) | sed 's%/*$%/%'` - CC=3D"$CC -B$path_binutils" + # Make absolute; ensure a single trailing slash. + path_binutils=3D`(cd $path_binutils; pwd) | sed 's%/*$%/%'` + CC=3D"$CC -B$path_binutils" fi -AS=3D`$CC -print-prog-name=3Das` -LD=3D`$CC -print-prog-name=3Dld` -AR=3D`$CC -print-prog-name=3Dar` +check_as_version=3D0 +AC_ARG_VAR([AS], [as program to use]) +if test -z "$AS"; then + AS=3D`$CC -print-prog-name=3Das` + check_as_version=3D1 +fi +check_ld_version=3D0 +AC_ARG_VAR([LD], [ld program to use]) +if test -z "$LD"; then + LD=3D`$CC -print-prog-name=3Dld` + check_ld_version=3D1 +fi +AC_ARG_VAR([AR], [ar program to use]) +if test -z "$AR"; then + AR=3D`$CC -print-prog-name=3Dar` +fi +AC_ARG_VAR([OBJDUMP], [objdump program to use]) +if test -z "$OBJDUMP"; then + OBJDUMP=3D`$CC -print-prog-name=3Dobjdump` +fi +AC_ARG_VAR([OBJCOPY], [objcopy program to use]) +if test -z "$OBJCOPY"; then + OBJCOPY=3D`$CC -print-prog-name=3Dobjcopy` +fi +AC_ARG_VAR([GPROF], [gprof program to use]) +if test -z "$GPROF"; then + GPROF=3D`$CC -print-prog-name=3Dgprof` +fi + AC_SUBST(AR) -OBJDUMP=3D`$CC -print-prog-name=3Dobjdump` AC_SUBST(OBJDUMP) -OBJCOPY=3D`$CC -print-prog-name=3Dobjcopy` AC_SUBST(OBJCOPY) -GPROF=3D`$CC -print-prog-name=3Dgprof` AC_SUBST(GPROF) =20 # 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=3D'' =20 # 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 =20 Use these variables to override the choices made by `configure' or to he= lp it to find libraries and programs with nonstandard names/locations. @@ -4545,19 +4557,42 @@ fi =20 # Was a --with-binutils option given? if test -n "$path_binutils"; then - # Make absolute; ensure a single trailing slash. - path_binutils=3D`(cd $path_binutils; pwd) | sed 's%/*$%/%'` - CC=3D"$CC -B$path_binutils" + # Make absolute; ensure a single trailing slash. + path_binutils=3D`(cd $path_binutils; pwd) | sed 's%/*$%/%'` + CC=3D"$CC -B$path_binutils" fi -AS=3D`$CC -print-prog-name=3Das` -LD=3D`$CC -print-prog-name=3Dld` -AR=3D`$CC -print-prog-name=3Dar` +check_as_version=3D0 + +if test -z "$AS"; then + AS=3D`$CC -print-prog-name=3Das` + check_as_version=3D1 +fi +check_ld_version=3D0 + +if test -z "$LD"; then + LD=3D`$CC -print-prog-name=3Dld` + check_ld_version=3D1 +fi + +if test -z "$AR"; then + AR=3D`$CC -print-prog-name=3Dar` +fi + +if test -z "$OBJDUMP"; then + OBJDUMP=3D`$CC -print-prog-name=3Dobjdump` +fi + +if test -z "$OBJCOPY"; then + OBJCOPY=3D`$CC -print-prog-name=3Dobjcopy` +fi + +if test -z "$GPROF"; then + GPROF=3D`$CC -print-prog-name=3Dgprof` +fi + =20 -OBJDUMP=3D`$CC -print-prog-name=3Dobjdump` =20 -OBJCOPY=3D`$CC -print-prog-name=3Dobjcopy` =20 -GPROF=3D`$CC -print-prog-name=3Dgprof` =20 =20 # Determine whether we are using GNU binutils. @@ -4599,8 +4634,8 @@ $as_echo "$libc_cv_prog_ld_gnu" >&6; } gnu_ld=3D$libc_cv_prog_ld_gnu =20 =20 -# Accept binutils 2.25 or newer. -for ac_prog in $AS +if test $check_as_version =3D 1; then : + for ac_prog in $AS do # Extract the first word of "$ac_prog", so it can be a program name wi= th args. set dummy $ac_prog; ac_word=3D$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 =3D yes; then - AS=3D: critic_missing=3D"$critic_missing as" + AS=3D: critic_missing=3D"$critic_missing GNU as" fi =20 =20 -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 =3D 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 wi= th args. set dummy $ac_prog; ac_word=3D$2 @@ -4729,8 +4767,8 @@ if test $ac_verc_fail =3D yes; then LD=3D: critic_missing=3D"$critic_missing GNU gold" fi =20 -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 wi= th args. set dummy $ac_prog; ac_word=3D$2 @@ -4793,6 +4831,8 @@ if test $ac_verc_fail =3D yes; then LD=3D: critic_missing=3D"$critic_missing GNU ld" fi =20 + fi + fi =20 # 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 =20 LIBC_PROG_BINUTILS =20 -# 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=3D: critic_missing=3D"$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=3D: critic_missing=3D"$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 f= orced. +AS_IF([test $check_as_version =3D 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=3D: critic_missing=3D"$critic_missing GNU ld") -fi + AS=3D: critic_missing=3D"$critic_missing GNU as") +]) + +AS_IF([test $check_ld_version =3D 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=3D: critic_missing=3D"$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=3D: critic_missing=3D"$critic_missing GNU ld") + fi +]) =20 # These programs are version sensitive. AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version, --=20 2.33.0