From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-2.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS,URIBL_BLACK shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 6B2891F4C1 for ; Mon, 28 Nov 2022 23:26:12 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20210112.gappssmtp.com header.i=@rivosinc-com.20210112.gappssmtp.com header.b="MzrvxXI6"; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3C9D385B18C for ; Mon, 28 Nov 2022 23:26:09 +0000 (GMT) Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 450B03858D28 for ; Mon, 28 Nov 2022 23:25:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 450B03858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-x62f.google.com with SMTP id g10so11707434plo.11 for ; Mon, 28 Nov 2022 15:25:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=6Zx3BC6ynx+pe6h5gaotSzbrO2K+sePQC7RHoXFLIX4=; b=MzrvxXI6g/a94QJ49DDVCRrWgtnWXbou60tB9sT4rp25ntjX4LA0TCdc6jyI2KXKgV 8WlIjLAJL503eadEBgyZl9vnKT6tYAFz7Xs7Fwd5FNLtzOhgoeocgeYmtGai4KMzBM5B TLOVKGIf06aM5xR8hYutoOsTbqm7Ezuz89BAhgnDAV7GiHIrjJ2t5rYXXWbZ1MAZUwtn XmvJ9XI5pjYnDucmsRnjRbCFLxbBvHQmeUXL5hfIKdAmWSvv7UsD5hvMWKY+yzZbbZDU Brs6FuV7m18XiS4+N/EVVpCKnIdhLKi7HlyshoDX4LD95Nf1gHMWc4nl6buzqp+t1C92 v35A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6Zx3BC6ynx+pe6h5gaotSzbrO2K+sePQC7RHoXFLIX4=; b=uedFqMS9R68ww8VcVLZzYzrZ+tzqgWMAU1kXd4aAMqxJkbehIivfOAqIY4tP3QpXs/ wZEPzI4MRHUkKEHnXGBfobRiUwvcysHcKBs/p/BP1buE9gWcm7BswEFXQcyUhOEv0Tss f0vl3XaDTARfFjNMTP4JooGMwyE3BpRXWGrttDRcTK1e0vABnPLxjOW+05OEElg8GgVW JBXgejK0cWc0khdJQpZYIsi9I20pmZCDUcHRNjeV5zdOB9MFHjkreG0fo89EByVEKDo+ csR9pnEhru2MVPBY7Z25Ha68ULbh6xKynr2BGpoYFpqF56cZ3OBUcPiOCENW+C+j2HPn +SCw== X-Gm-Message-State: ANoB5plENPixe97jR3waIjFcHQ7qsszz/EbTlwFU6ePIE++f271P/hH/ 7DFueU8nFlmedY+Nvte6leOVrdp5q5K9nA== X-Google-Smtp-Source: AA0mqf5mZVGEWgI0Fa54IwRsJqWsLZzKbvuHMVE2y1RZFDmeu8QZ9edD6DuFuTWUH1hOImvczmf1Wg== X-Received: by 2002:a17:902:7089:b0:187:4ace:e20c with SMTP id z9-20020a170902708900b001874acee20cmr34924826plk.75.1669677953968; Mon, 28 Nov 2022 15:25:53 -0800 (PST) Received: from localhost ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id s28-20020aa78bdc000000b0056bcb102e7bsm8573701pfd.68.2022.11.28.15.25.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 15:25:53 -0800 (PST) Date: Mon, 28 Nov 2022 15:25:53 -0800 (PST) X-Google-Original-Date: Mon, 28 Nov 2022 15:25:42 PST (-0800) Subject: Re: [PATCH] Revert "Correctly determine libc.so 'OUTPUT_FORMAT' when cross-compiling." In-Reply-To: <20221123025932.473655-1-vineetg@rivosinc.com> CC: libc-alpha@sourceware.org, carlos@redhat.com, maskray@google.com, ludo@gnu.org, nelson@rivosinc.com, gnu-toolchain@rivosinc.com, Vineet Gupta From: Palmer Dabbelt To: Vineet Gupta Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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: , Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On Tue, 22 Nov 2022 18:59:32 PST (-0800), Vineet Gupta wrote: > This reverts commit 361d6454c034a920f2c96517c277990d390b9652. > > This trips up riscv gnu toolchain builds [1] > > riscv ld segfaults when linking libgcc because libc.so linker script > contains `OUTPUT_FORMAT(elf32-little)` vs. `OUTPUT_FORMAT(elf32-littleriscv)`. Sounds like a linker bug? > This patch causes builds to lookup riscv32* prefixed objdump and failing > to find it falls back to host objdump which is the root of the issue. > The host objdump in turn generates `OUTPUT_FORMAT(elf32-little)` > > riscv glibc multilib builds lack riscv32 prefix binaries. They have a > single set of "riscv64" prefixed binaries supporting both 32 and 64-bit > abis: ilp32/ilp32d/lp64/lp64d using -march/-mabi. Though we _could_ have riscv32-* and riscv64-* binaries (and also riscv*- too), it just doesn't make much of a difference as the riscv64-* binaries can target everything. If the answer here is just "fix riscv-gnu-toolchain" that seems reasonable to me, but also happy to avoid touching that so Acked-by: Palmer Dabbelt Though some sort of global reviewer should take a look here, I definately don't understand the glibc build process well enough to review this one. Thanks! > FWIW I'm not sure how this patch fixed a real problem to begin with. > At least for the riscv toolchain builds the non-prefixed objdump was > still from the cross-tools and behaved exactly same as the prefixed one. > At least it was not picking up the host version which would fail - > ironically what this patch ended up triggering for riscv. > > | $ find TC_INSTALL -name *objdump -exec md5sum {} \; > | 5fd0b967d4977a4f8bc3a7b7a9318b1d ./bin/riscv64-unknown-linux-gnu-objdump > | 5fd0b967d4977a4f8bc3a7b7a9318b1d ./riscv64-unknown-linux-gnu/bin/objdump > | > | $ ./bin/riscv64-unknown-linux-gnu-objdump -f ./xx.lds.so | grep "file format" > | ./xx.lds.so: file format elf32-littleriscv > | > | $ ./riscv64-unknown-linux-gnu/bin/objdump -f ./xx.lds.so | grep "file format" > | ./xx.lds.so: file format elf32-littleriscv > > [1] https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1161 > > Signed-off-by: Vineet Gupta > --- > aclocal.m4 | 2 ++ > configure | 96 ++-------------------------------------------------- > configure.ac | 1 - > 3 files changed, 5 insertions(+), 94 deletions(-) > > diff --git a/aclocal.m4 b/aclocal.m4 > index 531b11cb6988..3b4df4a37197 100644 > --- a/aclocal.m4 > +++ b/aclocal.m4 > @@ -122,6 +122,8 @@ AS=`$CC -print-prog-name=as` > LD=`$CC -print-prog-name=$LDNAME` > 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 cb0996d59e21..fbaa20e040b5 100755 > --- a/configure > +++ b/configure > @@ -649,6 +649,7 @@ LD > AS > GPROF > OBJCOPY > +OBJDUMP > AR > LN_S > INSTALL_DATA > @@ -684,7 +685,6 @@ sysheaders > ac_ct_CXX > CXXFLAGS > CXX > -OBJDUMP > READELF > CPP > cross_compiling > @@ -2963,98 +2963,6 @@ 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 > @@ -4672,6 +4580,8 @@ AS=`$CC -print-prog-name=as` > LD=`$CC -print-prog-name=$LDNAME` > 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 20b5e8043fad..0ca4bf56ef76 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -52,7 +52,6 @@ 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