Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5884449

Browse files
committed
- Issue #3754: Use readelf instead of ldd for the cross build readline check
1 parent f2967c7 commit 5884449

File tree

4 files changed

+135
-6
lines changed

4 files changed

+135
-6
lines changed

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ MAINCC= @MAINCC@
3434
LINKCC= @LINKCC@
3535
AR= @AR@
3636
RANLIB= @RANLIB@
37+
READELF= @READELF@
3738
SOABI= @SOABI@
3839
LDVERSION= @LDVERSION@
3940
HGVERSION= @HGVERSION@

configure

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,8 @@ INSTALL_SCRIPT
646646
INSTALL_PROGRAM
647647
HAS_PYTHON
648648
DISABLE_ASDLGEN
649+
ac_ct_READELF
650+
READELF
649651
ARFLAGS
650652
ac_ct_AR
651653
AR
@@ -5742,6 +5744,115 @@ then
57425744
ARFLAGS="rc"
57435745
fi
57445746

5747+
if test -n "$ac_tool_prefix"; then
5748+
for ac_prog in readelf
5749+
do
5750+
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
5751+
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
5752+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5753+
$as_echo_n "checking for $ac_word... " >&6; }
5754+
if ${ac_cv_prog_READELF+:} false; then :
5755+
$as_echo_n "(cached) " >&6
5756+
else
5757+
if test -n "$READELF"; then
5758+
ac_cv_prog_READELF="$READELF" # Let the user override the test.
5759+
else
5760+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5761+
for as_dir in $PATH
5762+
do
5763+
IFS=$as_save_IFS
5764+
test -z "$as_dir" && as_dir=.
5765+
for ac_exec_ext in '' $ac_executable_extensions; do
5766+
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5767+
ac_cv_prog_READELF="$ac_tool_prefix$ac_prog"
5768+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5769+
break 2
5770+
fi
5771+
done
5772+
done
5773+
IFS=$as_save_IFS
5774+
5775+
fi
5776+
fi
5777+
READELF=$ac_cv_prog_READELF
5778+
if test -n "$READELF"; then
5779+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $READELF" >&5
5780+
$as_echo "$READELF" >&6; }
5781+
else
5782+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5783+
$as_echo "no" >&6; }
5784+
fi
5785+
5786+
5787+
test -n "$READELF" && break
5788+
done
5789+
fi
5790+
if test -z "$READELF"; then
5791+
ac_ct_READELF=$READELF
5792+
for ac_prog in readelf
5793+
do
5794+
# Extract the first word of "$ac_prog", so it can be a program name with args.
5795+
set dummy $ac_prog; ac_word=$2
5796+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5797+
$as_echo_n "checking for $ac_word... " >&6; }
5798+
if ${ac_cv_prog_ac_ct_READELF+:} false; then :
5799+
$as_echo_n "(cached) " >&6
5800+
else
5801+
if test -n "$ac_ct_READELF"; then
5802+
ac_cv_prog_ac_ct_READELF="$ac_ct_READELF" # Let the user override the test.
5803+
else
5804+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5805+
for as_dir in $PATH
5806+
do
5807+
IFS=$as_save_IFS
5808+
test -z "$as_dir" && as_dir=.
5809+
for ac_exec_ext in '' $ac_executable_extensions; do
5810+
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5811+
ac_cv_prog_ac_ct_READELF="$ac_prog"
5812+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5813+
break 2
5814+
fi
5815+
done
5816+
done
5817+
IFS=$as_save_IFS
5818+
5819+
fi
5820+
fi
5821+
ac_ct_READELF=$ac_cv_prog_ac_ct_READELF
5822+
if test -n "$ac_ct_READELF"; then
5823+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_READELF" >&5
5824+
$as_echo "$ac_ct_READELF" >&6; }
5825+
else
5826+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5827+
$as_echo "no" >&6; }
5828+
fi
5829+
5830+
5831+
test -n "$ac_ct_READELF" && break
5832+
done
5833+
5834+
if test "x$ac_ct_READELF" = x; then
5835+
READELF=":"
5836+
else
5837+
case $cross_compiling:$ac_tool_warned in
5838+
yes:)
5839+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
5840+
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
5841+
ac_tool_warned=yes ;;
5842+
esac
5843+
READELF=$ac_ct_READELF
5844+
fi
5845+
fi
5846+
5847+
if test "$cross_compiling" = yes; then
5848+
case "$READELF" in
5849+
readelf|:)
5850+
as_fn_error $? "readelf for the host is required for cross builds" "$LINENO" 5
5851+
;;
5852+
esac
5853+
fi
5854+
5855+
57455856

57465857
DISABLE_ASDLGEN=""
57475858
# Extract the first word of "python", so it can be a program name with args.

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,16 @@ then
926926
ARFLAGS="rc"
927927
fi
928928

929+
AC_CHECK_TOOLS([READELF], [readelf], [:])
930+
if test "$cross_compiling" = yes; then
931+
case "$READELF" in
932+
readelf|:)
933+
AC_MSG_ERROR([readelf for the host is required for cross builds])
934+
;;
935+
esac
936+
fi
937+
AC_SUBST(READELF)
938+
929939
AC_SUBST(DISABLE_ASDLGEN)
930940
DISABLE_ASDLGEN=""
931941
AC_CHECK_PROG(HAS_PYTHON, python, found, not-found)

setup.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,20 @@ def detect_modules(self):
590590
do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
591591
readline_termcap_library = ""
592592
curses_library = ""
593+
# Cannot use os.popen here in py3k.
594+
tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib')
595+
if not os.path.exists(self.build_temp):
596+
os.makedirs(self.build_temp)
593597
# Determine if readline is already linked against curses or tinfo.
594-
if do_readline and find_executable('ldd'):
595-
# Cannot use os.popen here in py3k.
596-
tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib')
597-
if not os.path.exists(self.build_temp):
598-
os.makedirs(self.build_temp)
599-
ret = os.system("ldd %s > %s" % (do_readline, tmpfile))
598+
if do_readline:
599+
if cross_compiling:
600+
ret = os.system("%s -d %s | grep '(NEEDED)' > %s" \
601+
% (sysconfig.get_config_var('READELF'),
602+
do_readline, tmpfile))
603+
elif find_executable('ldd'):
604+
ret = os.system("ldd %s > %s" % (do_readline, tmpfile))
605+
else:
606+
ret = 256
600607
if ret >> 8 == 0:
601608
with open(tmpfile) as fp:
602609
for ln in fp:

0 commit comments

Comments
 (0)