This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR46397, PR46362 by de-c99-ifying lto-plugin.


    Hi list,

  A couple of platforms (SPARC, IRIX) have had problems building the
lto-plugin since it was globally enabled for all ELF targets, because it uses
c99 features.  As GCC is only supposed to require c90 to bootstrap, this patch
converts the lto-plugin back to c90 usage.

lto-plugin/ChangeLog:

2010-11-11  Dave Korn  <...>

	PR bootstrap/46397
	PR bootstrap/46362
	* configure.ac: Add AC_TYPE_INT64_T test.
	* config.h.in: Regenerate.
	* configure: Likewise.
	* lto-plugin.c (debug): Use char not bool.
	(nop): Likewise.
	(check_1): Rename from check, and use int not bool for gate argument.
	(check): Macro wrapper for the above to coerce gate argument into
	boolean-valued integer in case it has pointer type.
	(parse_table_entry): Use 0 not false.
	(claim_file_handler): Avoid use of PRIx64 by splitting 64-bit size
	into two 32-bit parts and printing as hex ints.

  Bootstrapped and LTO-bootstrapped without regressions on
x86_64-unknown-linux-gnu, and verified that it fixes bootstrap on SPARC.
(Still waiting to hear on IRIX results.)  OK for trunk?

    cheers,
      DaveK

email:davek@gcc.gnu.org
branch:trunk
revision:HEAD
configure:--prefix=/n/10/davek/gcc --with-mpfr=/opt/cfarm/mpfr-2.4.1 --with-demangler-in-ld  --enable-clocale=gnu --with-system-zlib --with-fpmath=sse  --with-gmp=/opt/cfarm/gmp-4.2.4 --with-mpc=/opt/cfarm/mpc-0.8 '--enable-bootstrap' '--enable-static' '--enable-shared' '--enable-shared-libgcc' '--with-plugin-ld=gold' '--enable-gold' '--enable-languages=c,c++,objc,obj-c++,fortran'
make:-j12
check:-j12

Index: lto-plugin/config.h.in
===================================================================
--- lto-plugin/config.h.in	(revision 166509)
+++ lto-plugin/config.h.in	(working copy)
@@ -75,6 +75,10 @@
    #define below would cause a syntax error. */
 #undef _UINT64_T

+/* Define to the type of a signed integer type of width exactly 64 bits if
+   such a type exists and the standard includes do not define it. */
+#undef int64_t
+
 /* Define to the type of an unsigned integer type of width exactly 64 bits if
    such a type exists and the standard includes do not define it. */
 #undef uint64_t
Index: lto-plugin/configure
===================================================================
--- lto-plugin/configure	(revision 166509)
+++ lto-plugin/configure	(working copy)
@@ -1730,6 +1730,77 @@ $as_echo "$ac_res" >&6; }

 } # ac_fn_c_check_func

+# ac_fn_c_find_intX_t LINENO BITS VAR
+# -----------------------------------
+# Finds a signed integer type with width BITS, setting cache variable VAR
+# accordingly.
+ac_fn_c_find_intX_t ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5
+$as_echo_n "checking for int$2_t... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+     for ac_type in int$2_t 'int' 'long int' \
+	 'long long int' 'short int' 'signed char'; do
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(0 < ($ac_type) (((($ac_type) 1 << ($2 - 2)) - 1) * 2 + 1))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) (((($ac_type) 1 << ($2 - 2)) - 1) * 2 + 1)
+		 < ($ac_type) (((($ac_type) 1 << ($2 - 2)) - 1) * 2 + 2))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  case $ac_type in #(
+  int$2_t) :
+    eval "$3=yes" ;; #(
+  *) :
+    eval "$3=\$ac_type" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       eval as_val=\$$3
+   if test "x$as_val" = x""no; then :
+
+else
+  break
+fi
+     done
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_find_intX_t
+
 # ac_fn_c_find_uintX_t LINENO BITS VAR
 # ------------------------------------
 # Finds an unsigned integer type with width BITS, setting cache variable VAR
@@ -10434,7 +10505,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10437 "configure"
+#line 10508 "configure"
 #include "confdefs.h"

 #if HAVE_DLFCN_H
@@ -10540,7 +10611,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10543 "configure"
+#line 10614 "configure"
 #include "confdefs.h"

 #if HAVE_DLFCN_H
@@ -10796,6 +10867,17 @@ $as_echo "#define SYM_STYLE ss_none" >>confdefs.h

     ;;
 esac
+ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t"
+case $ac_cv_c_int64_t in #(
+  no|yes) ;; #(
+  *)
+
+cat >>confdefs.h <<_ACEOF
+#define int64_t $ac_cv_c_int64_t
+_ACEOF
+;;
+esac
+
 ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t"
 case $ac_cv_c_uint64_t in #(
   no|yes) ;; #(
Index: lto-plugin/configure.ac
===================================================================
--- lto-plugin/configure.ac	(revision 166509)
+++ lto-plugin/configure.ac	(working copy)
@@ -20,6 +20,7 @@ case $target in
     AC_DEFINE([SYM_STYLE], [ss_none], [Default symbol style])
     ;;
 esac
+AC_TYPE_INT64_T
 AC_TYPE_UINT64_T
 AC_CONFIG_FILES(Makefile)
 AC_CONFIG_HEADERS(config.h)
Index: lto-plugin/lto-plugin.c
===================================================================
--- lto-plugin/lto-plugin.c	(revision 166509)
+++ lto-plugin/lto-plugin.c	(working copy)
@@ -35,6 +35,9 @@ along with this program; see the file COPYING3.  I
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
 #include <assert.h>
 #include <string.h>
 #include <stdlib.h>
@@ -45,7 +48,6 @@ along with this program; see the file COPYING3.  I
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <stdbool.h>
 #include <libiberty.h>
 #include <hashtab.h>
 #include "../gcc/lto/common.h"
@@ -138,8 +140,8 @@ static int lto_wrapper_num_args;
 static char **pass_through_items = NULL;
 static unsigned int num_pass_through_items;

-static bool debug;
-static bool nop;
+static char debug;
+static char nop;
 static char *resolution_file = NULL;

 /* Set by default from configure.ac, but can be overridden at runtime
@@ -148,7 +150,7 @@ static char *resolution_file = NULL;
 static enum symbol_style sym_style = SYM_STYLE;

 static void
-check (bool gate, enum ld_plugin_level level, const char *text)
+check_1 (int gate, enum ld_plugin_level level, const char *text)
 {
   if (gate)
     return;
@@ -164,6 +166,11 @@ static void
     }
 }

+/* This little wrapper allows check to be called with a non-integer
+   first argument, such as a pointer that must be non-NULL.  We can't
+   use c99 bool type to coerce it into range, so we explicitly test.  */
+#define check(GATE, LEVEL, TEXT) check_1 (((GATE) != 0), (LEVEL), (TEXT))
+
 /* Parse an entry of the IL symbol table. The data to be parsed is pointed
    by P and the result is written in ENTRY. The slot number is stored in SLOT.
    Returns the address of the next entry. */
@@ -205,7 +212,7 @@ parse_table_entry (char *p, struct ld_plugin_symbo
       entry->name = concat ("_", p, NULL);
       break;
     default:
-      check (false, LDPL_FATAL, "invalid symbol style requested");
+      check (0, LDPL_FATAL, "invalid symbol style requested");
       break;
     }
   while (*p)
@@ -825,9 +832,14 @@ claim_file_handler (const struct ld_plugin_input_f
   if (file->offset != 0)
     {
       char *objname;
-      /* We pass the offset of the actual file, not the archive header. */
-      int t = asprintf (&objname, "%s@0x%" PRIx64, file->name,
-                        (int64_t) file->offset);
+      /* We pass the offset of the actual file, not the archive header.
+         Can't use PRIx64, because that's C99, so we have to print the
+	 64-bit hex int as two 32-bit ones. */
+      int lo, hi;
+      lo = file->offset & 0xffffffff;
+      hi = ((int64_t)file->offset >> 32) & 0xffffffff;
+      int t = hi ? asprintf (&objname, "%s@0x%x%08x", file->name, lo, hi)
+		: asprintf (&objname, "%s@0x%x", file->name, lo);
       check (t >= 0, LDPL_FATAL, "asprintf failed");
       lto_file.name = objname;
     }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]