From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2191) id 2A9C13858C20; Sat, 29 Oct 2022 01:44:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A9C13858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667007883; bh=FE5EuVH0TZMYlBFVOG1MUPzxD3n/Ib7im4/Yg3N3/Jw=; h=From:To:Subject:Date:From; b=YpVd/k+p1viktoai8RSezoSQUDZ6wM44lfWvWfTXj76hxb7QPbZU3L1bgR7jb9+FK p7pOsJjLgicoKlZ5m1+JCTD+JdnlZhkt9njhAYYcWTnRrDWtEGpcFo0O4LjVZ03AfV zo1gaOkq5cmCYOW2YzruENdx2zKlcRwxn2TXsz+0= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Carlos O'Donell To: glibc-cvs@sourceware.org Subject: [glibc] Correctly determine libc.so 'OUTPUT_FORMAT' when cross-compiling. X-Act-Checkin: glibc X-Git-Author: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Git-Refname: refs/heads/master X-Git-Oldrev: 8c77e26ba8b360c851b2b9485bb4431aacc51ad1 X-Git-Newrev: 361d6454c034a920f2c96517c277990d390b9652 Message-Id: <20221029014443.2A9C13858C20@sourceware.org> Date: Sat, 29 Oct 2022 01:44:43 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=361d6454c034a920f2c96517c277990d390b9652 commit 361d6454c034a920f2c96517c277990d390b9652 Author: Ludovic Courtès Date: Thu Jul 1 23:00:19 2021 +0200 Correctly determine libc.so 'OUTPUT_FORMAT' when cross-compiling. 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. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell Diff: --- aclocal.m4 | 2 -- configure | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- configure.ac | 1 + 3 files changed, 94 insertions(+), 5 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 3b4df4a371..531b11cb69 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -122,8 +122,6 @@ 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 ff2c406b3b..82e5e9f759 100755 --- a/configure +++ b/configure @@ -649,7 +649,6 @@ LD AS GPROF OBJCOPY -OBJDUMP AR LN_S INSTALL_DATA @@ -685,6 +684,7 @@ sysheaders ac_ct_CXX CXXFLAGS CXX +OBJDUMP READELF CPP cross_compiling @@ -2963,6 +2963,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 @@ -4580,8 +4672,6 @@ 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 eb5bc6a131..973fe59e81 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