[PATCH] Fix make installcheck when using program-prefix

Samuel Zeter samuelzeter@gmail.com
Fri Mar 28 08:45:21 GMT 2025


sanity.sh does not check for the presence of a program-prefix,
so when make installcheck is ran and files have been installed
with a prefix, the operation fails.

This patch checks for the presence of a prefix, and strips the
sed command attached to it.

BUG: https://sourceware.org/bugzilla/show_bug.cgi?id=23120

Signed-off-by: Samuel Zeter <samuelzeter@gmail.com>
---
 binutils/Makefile.am |  2 +-
 binutils/sanity.sh   | 22 ++++++++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/binutils/Makefile.am b/binutils/Makefile.am
index 20c711aca92..2e3e3cccb46 100644
--- a/binutils/Makefile.am
+++ b/binutils/Makefile.am
@@ -224,7 +224,7 @@ development.exp: $(BFDDIR)/development.sh
 	  | $(AWK) -F= '{ print "set " $$1 " " $$2 }' > $@
 
 installcheck-local:
-	/bin/sh $(srcdir)/sanity.sh $(bindir)
+	/bin/sh $(srcdir)/sanity.sh $(bindir) "$(program_transform_name)"
 
 # There's no global DEPENDENCIES.  So, we must explicitly list everything
 # which depends on libintl, since we don't know whether LIBINTL_DEP will be
diff --git a/binutils/sanity.sh b/binutils/sanity.sh
index e16df6163fb..b0caa012594 100755
--- a/binutils/sanity.sh
+++ b/binutils/sanity.sh
@@ -30,32 +30,38 @@ case "$1" in
 *)  BIN="$1" ;;
 esac
 
+PREFIX=$2
+if [ -n "$PREFIX" ]; then
+### Regex strips the sed command from the prefix: s&^&prefix_& -> prefix_
+   PREFIX=$(echo "$2" | sed -E 's/^s[^&]*&\^?&//; s/&$//')
+fi
+
 ### size
 for i in size objdump nm ar strip ranlib ; do
-	${BIN}/size ${BIN}/$i > /dev/null
+	"${BIN}/${PREFIX}size" "${BIN}/${PREFIX}$i" > /dev/null
 done
 
 ### objdump
 for i in size objdump nm ar strip ranlib ; do
-	${BIN}/objdump -ahifdrtxsl ${BIN}/$i > /dev/null
+	"${BIN}/${PREFIX}objdump" -ahifdrtxsl "${BIN}/${PREFIX}$i" > /dev/null
 done
 
 ### nm
 for i in size objdump nm ar strip ranlib ; do
-	${BIN}/nm ${BIN}/$i > /dev/null
+	"${BIN}/${PREFIX}nm" "${BIN}/${PREFIX}$i" > /dev/null
 done
 
 ### strip
 TMPDIR=./binutils-$$
 mkdir ${TMPDIR}
 
-cp ${BIN}/strip ${TMPDIR}/strip
+cp "${BIN}/${PREFIX}strip" "${TMPDIR}/${PREFIX}strip"
 
 for i in size objdump nm ar ranlib ; do
-	cp ${BIN}/$i ${TMPDIR}/$i
-	${BIN}/strip ${TMPDIR}/$i
-	cp ${BIN}/$i ${TMPDIR}/$i
-	${TMPDIR}/strip ${TMPDIR}/$i
+	cp "${BIN}/${PREFIX}$i" "${TMPDIR}/${PREFIX}$i"
+	"${BIN}/${PREFIX}strip" "${TMPDIR}/${PREFIX}$i"
+	cp "${BIN}/${PREFIX}$i" "${TMPDIR}/${PREFIX}$i"
+	"${TMPDIR}/${PREFIX}strip" "${TMPDIR}/${PREFIX}$i"
 done
 
 ### ar
-- 
2.49.0



More information about the Binutils mailing list