diff --git a/gdb/configure b/gdb/configure
index 1531f62f76a..cfb4f446ef8 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -25005,7 +25005,9 @@ if test x${all_targets} = xtrue; then
   if test x${enable_64_bit_bfd} = xyes; then
     TARGET_OBS='$(ALL_TARGET_OBS) $(ALL_64_TARGET_OBS)'
   else
-    TARGET_OBS='$(ALL_TARGET_OBS)'
+    # If all targets were requested, but 64 bit bfd is not enabled,
+    # the build will fail. See PR 28684.
+    as_fn_error $? "--enable-targets=all requires --enable-64-bit-bfd" "$LINENO" 5
   fi
 fi
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index e9312b1bc64..77f774e23ee 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -257,7 +257,9 @@ if test x${all_targets} = xtrue; then
   if test x${enable_64_bit_bfd} = xyes; then
     TARGET_OBS='$(ALL_TARGET_OBS) $(ALL_64_TARGET_OBS)'
   else
-    TARGET_OBS='$(ALL_TARGET_OBS)'
+    # If all targets were requested, but 64 bit bfd is not enabled,
+    # the build will fail. See PR 28684.
+    AC_MSG_ERROR([--enable-targets=all requires --enable-64-bit-bfd])
   fi
 fi
 
