[patch] Require long long for GDB [Re: [patch] Compilation regression on older gcc + 32-bit host]

Jan Kratochvil
2012-05-31T15:40:55Z

On Thu, 31 May 2012 12:04:48 +0200, Pedro Alves wrote:
> Not quite. bfd's only use of "long long" in common code is guarded by HAVE_STRTOULL.
> I can't find any unconditional long long use in the whole of binutils. opcodes
> uses long long in many ports, but then there are many ports that don't use it. It's native
> toolchains on those ports that could be problematic (old hosts with old, non-gcc compilers).
> (People on such hosts wouldn't be using "--enable-targets=all", nor building cross toolchains).

OK, thanks for the analysis.

> In any case, for gdb, I think it's now safe to assume that long long is available
> on all supported hosts.
+
> and this means we're assuming the "#define LONGEST long"
> is never reached nowaways, or that if it does, long is 64-bit.

OK, so I will check in this patch.

> It'd be super fine with the below as well, and it might even be better (stop
> the non-fixed-sized types insanity). You should then change tramp_frame
> to use uint64_t instead of ULONGEST, though.

And ULL afterwards.

Thanks,
Jan

gdb/
2012-05-31 Jan Kratochvil <jan.kratochvil@redhat.com>

* configure.ac (CC_HAS_LONG_LONG): Replace by AC_MSG_ERROR.
* defs.h (LONGEST, ULONGEST): Remove conditionalization for
CC_HAS_LONG_LONG.
* dwarf2-frame.c (DW64_CIE_ID): Likewise.
* printcmd.c (ui_printf): Remove conditionalizations for
CC_HAS_LONG_LONG.
* config.in: Regenerate.
* configure: Regenerate.

gdb/doc/
2012-05-31 Jan Kratochvil <jan.kratochvil@redhat.com>

* gdbint.texinfo (Host Definition): Remove CC_HAS_LONG_LONG.

diff --git a/gdb/configure.ac b/gdb/configure.ac
index d7409d0..dbf8dc0 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1487,9 +1487,9 @@ AC_CACHE_CHECK([for long long support in compiler], gdb_cv_c_long_long,
[[switch (foo & 2) { case 0: return 1; }]])],
gdb_cv_c_long_long=yes,
gdb_cv_c_long_long=no)])
-if test $gdb_cv_c_long_long = yes; then
- AC_DEFINE(CC_HAS_LONG_LONG, 1,
- [Define to 1 if the compiler supports long long.])
+if test $gdb_cv_c_long_long != yes; then
+ # libdecnumber requires long long.
+ AC_MSG_ERROR([Compiler must support long long for GDB.])
fi

# Check if the compiler and runtime support printing long longs.
diff --git a/gdb/defs.h b/gdb/defs.h
index 03092aa..60b738e 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -120,20 +120,8 @@ typedef bfd_vma CORE_ADDR;

#else /* No BFD64 */

-#ifdef CC_HAS_LONG_LONG
#define LONGEST long long
#define ULONGEST unsigned long long
-#else
-#ifdef BFD_HOST_64_BIT
-/* BFD_HOST_64_BIT is defined for some hosts that don't have long long
- (e.g. i386-windows) so try it. */
-#define LONGEST BFD_HOST_64_BIT
-#define ULONGEST BFD_HOST_U_64_BIT
-#else
-#define LONGEST long
-#define ULONGEST unsigned long
-#endif
-#endif

#endif /* No BFD64 */

diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 01786ef..a99ef1e 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -1790,11 +1790,7 @@ add_fde (struct dwarf2_fde_table *fde_table, struct dwarf2_fde *fde)
fde_table->entries[fde_table->num_entries - 1] = fde;
}

-#ifdef CC_HAS_LONG_LONG
#define DW64_CIE_ID 0xffffffffffffffffULL
-#else
-#define DW64_CIE_ID ~0
-#endif

/* Defines the type of eh_frames that are expected to be decoded: CIE, FDE
or any of them. */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 030a4f2..8fee2cb 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2499,7 +2499,7 @@ ui_printf (char *arg, struct ui_file *stream)
error (_("long double not supported in printf"));
#endif
case long_long_arg:
-#if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
+#ifdef PRINTF_HAS_LONG_LONG
{
long long val = value_as_long (val_args[i]);

@@ -2635,7 +2635,7 @@ ui_printf (char *arg, struct ui_file *stream)
handle %p as glibc would: %#x or a literal "(nil)". */

char *p, *fmt, *fmt_p;
-#if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
+#ifdef PRINTF_HAS_LONG_LONG
long long val = value_as_long (val_args[i]);
#else
long val = value_as_long (val_args[i]);
@@ -2670,7 +2670,7 @@ ui_printf (char *arg, struct ui_file *stream)
gdb_assert (*p == 'p' && *(p + 1) == '\0');
if (val != 0)
{
-#if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
+#ifdef PRINTF_HAS_LONG_LONG
*fmt_p++ = 'l';
#endif
*fmt_p++ = 'l';
diff --git a/gdb/config.in b/gdb/config.in
index a3bd8dd..b29a1d9 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -12,9 +12,6 @@
/* Directory of programs. */
#undef BINDIR

-/* Define to 1 if the compiler supports long long. */
-#undef CC_HAS_LONG_LONG
-
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
diff --git a/gdb/configure b/gdb/configure
index f638268..6f31786 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -11494,10 +11494,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_c_long_long" >&5
$as_echo "$gdb_cv_c_long_long" >&6; }
-if test $gdb_cv_c_long_long = yes; then
-
-$as_echo "#define CC_HAS_LONG_LONG 1" >>confdefs.h
-
+if test $gdb_cv_c_long_long != yes; then
+ # libdecnumber requires long long.
+ as_fn_error "Compiler must support long long for GDB." "$LINENO" 5
fi

# Check if the compiler and runtime support printing long longs.
@@ -12805,7 +12804,7 @@ $as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
elif test "`uname -s`" = "Darwin"; then
# If Tcl was built as a framework, attempt to use the libraries
# from the framework at the given location so that linking works
- # against Tcl.framework installed in an arbitary location.
+ # against Tcl.framework installed in an arbitrary location.
case ${TCL_DEFS} in
*TCL_FRAMEWORK*)
if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then
@@ -12920,7 +12919,7 @@ $as_echo "could not find ${TK_BIN_DIR}/tkConfig.sh" >&6; }
elif test "`uname -s`" = "Darwin"; then
# If Tk was built as a framework, attempt to use the libraries
# from the framework at the given location so that linking works
- # against Tk.framework installed in an arbitary location.
+ # against Tk.framework installed in an arbitrary location.
case ${TK_DEFS} in
*TK_FRAMEWORK*)
if test -f "${TK_BIN_DIR}/${TK_LIB_FILE}"; then
diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo
index 267a6eb..3b9d8ed 100644
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
@@ -2770,11 +2770,6 @@ Substitute for isatty, if not available.
@item FOPEN_RB
Define this if binary files are opened the same way as text files.

-@item CC_HAS_LONG_LONG
-@cindex @code{long long} data type
-Define this if the host C compiler supports @code{long long}. This is set
-by the @code{configure} script.
-
@item PRINTF_HAS_LONG_LONG
Define this if the host can handle printing of long long integers via
the printf format conversion specifier @code{ll}. This is set by the