From patchwork Wed Jul 7 15:55:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 44205 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A2FDB395BC18 for ; Wed, 7 Jul 2021 15:56:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2FDB395BC18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625673390; bh=tWx3L0xF1kw9wy5H9x0F4Hy5bpDYCim1YYh7AvzfEBc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=DKbOiKOc3xWdDCq7ZXwdB1RwlucMlX0vdpqAlSKoWkJkGCXDuIFyEMM/p7L2yUoVD MRb2cdqleFOciT6JxVnkcDW8g69/m6N16G1f1Ol/HjYzja2ZYZZsXkFWH/aImD0AxU 2xKZbxbeWK55CCy8ncArg5u5vk6NZRAP79gJlimg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 90B6E3847818 for ; Wed, 7 Jul 2021 15:56:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 90B6E3847818 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34054) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m19u7-0003kk-LO; Wed, 07 Jul 2021 11:56:03 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42802 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m19u7-00022e-E3; Wed, 07 Jul 2021 11:56:03 -0400 To: libc-alpha@sourceware.org Subject: [PATCH powerpc64le] Use the target 'objcopy' when cross-compiling. Date: Wed, 7 Jul 2021 17:55:47 +0200 Message-Id: <20210707155547.15277-1-ludo@gnu.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, 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-Patchwork-Original-From: =?utf-8?q?Ludovic_Court=C3=A8s_via_Libc-alpha?= From: =?utf-8?q?Ludovic_Court=C3=A8s?= Reply-To: =?utf-8?q?Ludovic_Court=C3=A8s?= Cc: =?utf-8?q?Ludovic_Court=C3=A8s?= Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" When cross-compiling to powerpc64le-linux-gnu, sysdeps/powerpc/powerpc64/le/Makefile would use "objcopy", leading to errors like: objcopy: Unable to recognise the format of the input file `…/no_ldbl_gnu_attribute.o' This patch changes 'configure.ac' to use AC_CHECK_TOOL rather than '$CC -print-prog-name=objcopy' to determine the value of the OBJCOPY variable. That way, OBJCOPY is set to TRIPLET-objcopy when cross-compiling for TRIPLET. --- aclocal.m4 | 2 -- configure | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++-- configure.ac | 1 + 3 files changed, 94 insertions(+), 5 deletions(-) The issue was initially reported at: https://issues.guix.gnu.org/49417 It is a followup to a similar patch I sent regarding objdump: https://sourceware.org/pipermail/libc-alpha/2021-July/128333.html Thanks, Ludo’. diff --git a/aclocal.m4 b/aclocal.m4 index 13a791ffde..5b370c07a2 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) -OBJCOPY=`$CC -print-prog-name=objcopy` -AC_SUBST(OBJCOPY) GPROF=`$CC -print-prog-name=gprof` AC_SUBST(GPROF) diff --git a/configure b/configure index fe0eda1cd5..3a08270734 100755 --- a/configure +++ b/configure @@ -654,7 +654,6 @@ MAKE LD AS GPROF -OBJCOPY AR LN_S INSTALL_DATA @@ -689,6 +688,7 @@ sysheaders ac_ct_CXX CXXFLAGS CXX +OBJCOPY OBJDUMP READELF CPP @@ -3054,6 +3054,98 @@ else OBJDUMP="$ac_cv_prog_OBJDUMP" fi +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name with args. +set dummy ${ac_tool_prefix}objcopy; 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_OBJCOPY+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJCOPY"; then + ac_cv_prog_OBJCOPY="$OBJCOPY" # 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_OBJCOPY="${ac_tool_prefix}objcopy" + $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 +OBJCOPY=$ac_cv_prog_OBJCOPY +if test -n "$OBJCOPY"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJCOPY" >&5 +$as_echo "$OBJCOPY" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJCOPY"; then + ac_ct_OBJCOPY=$OBJCOPY + # Extract the first word of "objcopy", so it can be a program name with args. +set dummy objcopy; 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_OBJCOPY+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OBJCOPY"; then + ac_cv_prog_ac_ct_OBJCOPY="$ac_ct_OBJCOPY" # 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_OBJCOPY="objcopy" + $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_OBJCOPY=$ac_cv_prog_ac_ct_OBJCOPY +if test -n "$ac_ct_OBJCOPY"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJCOPY" >&5 +$as_echo "$ac_ct_OBJCOPY" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OBJCOPY" = x; then + OBJCOPY="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 + OBJCOPY=$ac_ct_OBJCOPY + fi +else + OBJCOPY="$ac_cv_prog_OBJCOPY" +fi + # We need the C++ compiler only for testing. ac_ext=cpp @@ -4645,8 +4737,6 @@ AS=`$CC -print-prog-name=as` LD=`$CC -print-prog-name=ld` AR=`$CC -print-prog-name=ar` -OBJCOPY=`$CC -print-prog-name=objcopy` - GPROF=`$CC -print-prog-name=gprof` diff --git a/configure.ac b/configure.ac index 924af12738..2148cd2ec8 100644 --- a/configure.ac +++ b/configure.ac @@ -53,6 +53,7 @@ AC_SUBST(cross_compiling) AC_PROG_CPP AC_CHECK_TOOL(READELF, readelf, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) +AC_CHECK_TOOL(OBJCOPY, objcopy, false) # We need the C++ compiler only for testing. AC_PROG_CXX