From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 5197F3898380 for ; Thu, 6 Oct 2022 14:55:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5197F3898380 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665068153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SBtYubCMUZqr/DeaSzjIGLfT+GkO9CrwUpp8YWnixz4=; b=ZnrBT+1ERt9AAOYXEF+ImVUmZ8r1x74fbSxpqGv3PUSk3xJSsGKBsUn44fOuY/w2vv570C N6QSgQZoEYMbKprVj9LHmSTD8fVC8jiJ2I8F+xu+Z0hYDlUJ/ZIRaPHnDBpLskETRRSDZW C2ISboZ7MHB6uHr6aOJIf+2CHFZaWXA= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-257-kHzno2wLPVKiYqmBNSyEnQ-1; Thu, 06 Oct 2022 10:55:52 -0400 X-MC-Unique: kHzno2wLPVKiYqmBNSyEnQ-1 Received: by mail-qv1-f72.google.com with SMTP id kr13-20020a0562142b8d00b004b1d5953a2cso1248613qvb.3 for ; Thu, 06 Oct 2022 07:55:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SBtYubCMUZqr/DeaSzjIGLfT+GkO9CrwUpp8YWnixz4=; b=wXxWxSMaX6iBQS9s076Hk+eE2obl8m6Xmqb+AHKX93YHTUw8idEl2u9r2uI5o1reCT 81w7GfS7ixtdeTuTnNiSyYkj5KrNE9LXzdwHr6LcRZFrTkf04mIFTnD+pYd1Oj7lQ8GM Zp58ftE2asi5BpI6qe9Od/bEzpjFCAme+8oehXNrHTQkWCbJ0VTPtPhHO1EwahZD9y5Y hfGNKCQ7zGdqQSbmM+3fW90qT7q++X/cZTWL68phUpWCUP3dmnUohK9deZWssyuHexqh nmiVtVdQcWoOUxnAaoCDpW/PfTAvXXjxg2Vci1j3z6WMBybN+GgZR5+jgt52IYMOiTqg IZuA== X-Gm-Message-State: ACrzQf0SmHdknIwfU5IbKM74aqBB0iUl/uX+N8PGMcJc/bnTp8i62ZAF 9aEo8LZJQI3SkV2On3UgS1PnSZH0d1TG4RalUa21TQ6LI5BAJOvg0y1UUGyOmHMhq8l8D8U1YB0 1YanWdrvyqKOwOZlVXSpt X-Received: by 2002:a05:622a:1715:b0:35b:b13d:6bb2 with SMTP id h21-20020a05622a171500b0035bb13d6bb2mr378307qtk.480.1665068152217; Thu, 06 Oct 2022 07:55:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4DR9RSBrqhfOl1jjkDSck5ugi94ZG/VMnb79HUVIjqKEjarmPhW6MFYn5k4O9J+fkgQ1RpZw== X-Received: by 2002:a05:622a:1715:b0:35b:b13d:6bb2 with SMTP id h21-20020a05622a171500b0035bb13d6bb2mr378273qtk.480.1665068151890; Thu, 06 Oct 2022 07:55:51 -0700 (PDT) Received: from fedora ([66.187.232.65]) by smtp.gmail.com with ESMTPSA id i13-20020a05620a248d00b006cbe3be300esm20639353qkn.12.2022.10.06.07.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 07:55:51 -0700 (PDT) Date: Thu, 6 Oct 2022 10:55:49 -0400 From: Carlos O'Donell To: Ludovic =?iso-8859-1?Q?Court=E8s?= Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] Correctly determine libc.so 'OUTPUT_FORMAT' when cross-compiling. Message-ID: References: <20210701210019.5594-1-ludo@gnu.org> MIME-Version: 1.0 In-Reply-To: <20210701210019.5594-1-ludo@gnu.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=WINDOWS-1252 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Jul 01, 2021 at 11:00:19PM +0200, Ludovic Courtès via Libc-alpha wrote: > Commit 87d583c6e8cd0e49f64da76636ebeec033298b4d replaces the sed script > with an "objdump -f" invocation to determine the 'OUTPUT_FORMAT' bit of > the libc.so linker script. > > However, when cross-compiling, for example from x86_64-linux-gnu to > aarch64-linux-gnu, "objdump -f" would report the wrong > format ("elf64-little"). Conversely, "aarch64-linux-gnu-objdump -f" > reports "elf64-littleaarch64" as expected. > > This patch changes 'configure.ac' to use AC_CHECK_TOOL rather than > '$CC -print-prog-name=objdump' to determine the value of the OBJDUMP > variable. That way, OBJDUMP is set to TRIPLET-objdump when > cross-compiling for TRIPLET. I've been tackling a backlog of old glibc patches, and this one is up next. Yes it's been over a year, but this patch still applies and the idea is sound. I've tested this with build-many-glibcs (bmg) on x86_64 and it has no impact because bmg always sets OBJDUMP. My opinion is that bmg is the "base standard" for how we build native and cross tooling and so it your changes work here, they should work in other instances. The change looks good to me. No regresions on x86_64. Would you like me to commit this? :-) Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell > --- > aclocal.m4 | 2 -- > configure | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++-- > configure.ac | 1 + > 3 files changed, 94 insertions(+), 5 deletions(-) > > diff --git a/aclocal.m4 b/aclocal.m4 > index c195c4db56..13a791ffde 100644 > --- a/aclocal.m4 > +++ b/aclocal.m4 > @@ -118,8 +118,6 @@ AS=`$CC -print-prog-name=as` > LD=`$CC -print-prog-name=ld` > AR=`$CC -print-prog-name=ar` > 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` > diff --git a/configure b/configure > index 9619c10991..fe0eda1cd5 100755 > --- a/configure > +++ b/configure > @@ -655,7 +655,6 @@ LD > AS > GPROF > OBJCOPY > -OBJDUMP > AR > LN_S > INSTALL_DATA > @@ -690,6 +689,7 @@ sysheaders > ac_ct_CXX > CXXFLAGS > CXX > +OBJDUMP > READELF > CPP > cross_compiling > @@ -2962,6 +2962,98 @@ else > READELF="$ac_cv_prog_READELF" > fi > > +if test -n "$ac_tool_prefix"; then > + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. > +set dummy ${ac_tool_prefix}objdump; ac_word=$2 > +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 > +$as_echo_n "checking for $ac_word... " >&6; } > +if ${ac_cv_prog_OBJDUMP+:} false; then : > + $as_echo_n "(cached) " >&6 > +else > + if test -n "$OBJDUMP"; then > + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. > +else > +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR > +for as_dir in $PATH > +do > + IFS=$as_save_IFS > + test -z "$as_dir" && as_dir=. > + for ac_exec_ext in '' $ac_executable_extensions; do > + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then > + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" > + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 > + break 2 > + fi > +done > + done > +IFS=$as_save_IFS > + > +fi > +fi > +OBJDUMP=$ac_cv_prog_OBJDUMP > +if test -n "$OBJDUMP"; then > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 > +$as_echo "$OBJDUMP" >&6; } > +else > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 > +$as_echo "no" >&6; } > +fi > + > + > +fi > +if test -z "$ac_cv_prog_OBJDUMP"; then > + ac_ct_OBJDUMP=$OBJDUMP > + # Extract the first word of "objdump", so it can be a program name with args. > +set dummy objdump; ac_word=$2 > +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 > +$as_echo_n "checking for $ac_word... " >&6; } > +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : > + $as_echo_n "(cached) " >&6 > +else > + if test -n "$ac_ct_OBJDUMP"; then > + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. > +else > +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR > +for as_dir in $PATH > +do > + IFS=$as_save_IFS > + test -z "$as_dir" && as_dir=. > + for ac_exec_ext in '' $ac_executable_extensions; do > + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then > + ac_cv_prog_ac_ct_OBJDUMP="objdump" > + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 > + break 2 > + fi > +done > + done > +IFS=$as_save_IFS > + > +fi > +fi > +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP > +if test -n "$ac_ct_OBJDUMP"; then > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 > +$as_echo "$ac_ct_OBJDUMP" >&6; } > +else > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 > +$as_echo "no" >&6; } > +fi > + > + if test "x$ac_ct_OBJDUMP" = x; then > + OBJDUMP="false" > + else > + case $cross_compiling:$ac_tool_warned in > +yes:) > +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 > +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} > +ac_tool_warned=yes ;; > +esac > + OBJDUMP=$ac_ct_OBJDUMP > + fi > +else > + OBJDUMP="$ac_cv_prog_OBJDUMP" > +fi > + > > # We need the C++ compiler only for testing. > ac_ext=cpp > @@ -4553,8 +4645,6 @@ AS=`$CC -print-prog-name=as` > LD=`$CC -print-prog-name=ld` > AR=`$CC -print-prog-name=ar` > > -OBJDUMP=`$CC -print-prog-name=objdump` > - > OBJCOPY=`$CC -print-prog-name=objcopy` > > GPROF=`$CC -print-prog-name=gprof` > diff --git a/configure.ac b/configure.ac > index 34ecbba540..924af12738 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -52,6 +52,7 @@ fi > AC_SUBST(cross_compiling) > AC_PROG_CPP > AC_CHECK_TOOL(READELF, readelf, false) > +AC_CHECK_TOOL(OBJDUMP, objdump, false) > > # We need the C++ compiler only for testing. > AC_PROG_CXX > > base-commit: eb68d7d23cc411acdf68a60f194343a6774d6194 > -- > 2.32.0 >