[binutils-gdb] bfd ASSOCIATED_VECS
Alan Modra
amodra@sourceware.org
Sat Dec 20 04:53:42 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f4e835a40ccdab7e6d463cf419e4cba593fb524f
commit f4e835a40ccdab7e6d463cf419e4cba593fb524f
Author: Alan Modra <amodra@gmail.com>
Date: Sat Dec 20 14:12:31 2025 +1030
bfd ASSOCIATED_VECS
Tidy code setting ASSOCIATED_VECS, which could be fooled by unusual
configure options such as --enable-targets="srec,all".
* targets.c (_bfd_associated_vector): Remove comma after
ASSOCIATED_VECS.
* configure.ac: Set assocvecs from targ_defvec and
targ_selvecs when handling the target, rather than assuming
those variables are still set for the target when handling
--enable-targets=all. Move code making assocvecs unique
later. Do so in a way that need not run sed afterwards, and
leave a trailing comma.
* configure: Regenerate.
Diff:
---
bfd/configure | 24 +++++++++---------------
bfd/configure.ac | 24 +++++++++---------------
bfd/targets.c | 7 ++++---
3 files changed, 22 insertions(+), 33 deletions(-)
diff --git a/bfd/configure b/bfd/configure
index fdabacea4f0..e30030e5e13 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -15785,11 +15785,11 @@ for targ in $target $canon_targets
do
if test $targ = all; then
all_targets=true
- assocvecs="$assocvecs $targ_defvec $targ_selvecs"
elif test $targ != plugin; then
. $srcdir/config.bfd
if test $targ = $target; then
defvec=$targ_defvec
+ assocvecs="$targ_defvec $targ_selvecs"
fi
selvecs="$selvecs $targ_defvec $targ_selvecs"
selarchs="$selarchs $targ_archs"
@@ -15815,18 +15815,6 @@ for i in $selvecs ; do
done
selvecs="$f"
-
-# uniq the associated vectors in all the configured targets.
-f=""
-for i in $assocvecs ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-assocvecs="$f"
-
-
# uniq the architectures in all the configured targets.
f=""
for i in $selarchs ; do
@@ -16180,8 +16168,14 @@ if test x${all_targets} = xtrue ; then
selvecs=
havevecs=-DHAVE_all_vecs
selarchs=
- test -n "$assocvecs" &&
- assocvecs=`echo $assocvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
+ f=
+ for i in $assocvecs ; do
+ case "&${f}," in
+ *"&${i},"*) ;;
+ *) f="${f}&${i}," ;;
+ esac
+ done
+ assocvecs=$f
else # all_targets is true
# Only set these if they will be nonempty, for the clever echo.
havevecs=
diff --git a/bfd/configure.ac b/bfd/configure.ac
index c36594c5291..c264cc215af 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -326,11 +326,11 @@ for targ in $target $canon_targets
do
if test $targ = all; then
all_targets=true
- assocvecs="$assocvecs $targ_defvec $targ_selvecs"
elif test $targ != plugin; then
. $srcdir/config.bfd
if test $targ = $target; then
defvec=$targ_defvec
+ assocvecs="$targ_defvec $targ_selvecs"
fi
selvecs="$selvecs $targ_defvec $targ_selvecs"
selarchs="$selarchs $targ_archs"
@@ -356,18 +356,6 @@ for i in $selvecs ; do
done
selvecs="$f"
-
-# uniq the associated vectors in all the configured targets.
-f=""
-for i in $assocvecs ; do
- case " $f " in
- *" $i "*) ;;
- *) f="$f $i" ;;
- esac
-done
-assocvecs="$f"
-
-
# uniq the architectures in all the configured targets.
f=""
for i in $selarchs ; do
@@ -721,8 +709,14 @@ if test x${all_targets} = xtrue ; then
selvecs=
havevecs=-DHAVE_all_vecs
selarchs=
- test -n "$assocvecs" &&
- assocvecs=`echo $assocvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
+ f=
+ for i in $assocvecs ; do
+ case "&${f}," in
+ *"&${i},"*) ;;
+ *) f="${f}&${i}," ;;
+ esac
+ done
+ assocvecs=$f
else # all_targets is true
# Only set these if they will be nonempty, for the clever echo.
havevecs=
diff --git a/bfd/targets.c b/bfd/targets.c
index 2eac73962ef..f6e4c2aa5aa 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -1429,12 +1429,13 @@ const bfd_target *bfd_default_vector[] = {
NULL
};
-/* bfd_associated_vector[] contains the associated target vectors used
- to reduce the ambiguity in bfd_check_format_matches. */
+/* bfd_associated_vector[] contains the main target vectors when
+ configuring with --enable-targets=all, to match those
+ preferentially over others that might match. */
static const bfd_target *const _bfd_associated_vector[] = {
#ifdef ASSOCIATED_VECS
- ASSOCIATED_VECS,
+ ASSOCIATED_VECS
#endif
NULL
};
More information about the Binutils-cvs
mailing list