emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Anyone built Emacs with gcc-3.3?


From: Paul Eggert
Subject: Re: Anyone built Emacs with gcc-3.3?
Date: Fri, 11 Jul 2003 02:55:13 -0700 (PDT)

> From: Richard Stallman <address@hidden>
> Date: Sat, 05 Jul 2003 18:25:56 -0400
> 
> The way to debug this is to treat it as an Emacs bug.  When you
> find the bug, it will actually be a miscompiled function (if this
> is GCC's fault).  Then you can send a useful GCC bug report.

I looked into this a bit, and there seem to be at least two problems.
One is an Emacs portability problem; the rest I don't know yet.

Emacs assumes that a top-level declaration like "int pure[1000] = {0};"
puts "pure" into the data area.  However, this assumption is no longer
true with GCC 3.3 on Solaris 8, which notices that "pure" has an
initializer that is all zeros, and puts "pure" into BSS instead.
This is a valid optimization, so I guess Emacs should deal with it.

I checked for all static variables that Emacs 21.3 defines to be zero
in Solaris 8, and which become readonly after dumping with GCC 3.2.3
but not with GCC 3.3, and I came up with the following patch to fix
this portability problem.  This fixes part of the bug, but not all;
Emacs still dumps core.  I'll see if I can investigate this further if
I find more time but that won't be before this weekend.

2003-07-11  Paul Eggert  <address@hidden>

        GCC 3.3 no longer puts "int foo = 0;" into data; it optimizes
        this case and puts it into BSS instead, at least on Solaris 8.
        * src/alloc.c (pure, staticvec, staticidx):
        Initialize to nonzero, so that it's data.
        * src/emacs.c (bss_end): Likewise.
        (main): Use bss_end==1 to mean it's unset.

        The following changes don't fix any bugs, but they remove
        initializations to zero that do not need to be in pure space.
        I am including them in this patch (if only to document them).
        * src/emacs.c (gdb_data_seg_bits): Do not initialize to zero
        explicitly, since it's OK for this to be in BSS.
        * src/xfns.c (cursor_bits): Likewise.
        * src/xterm.c (Xt_default_resources): Likewise.

diff -pru emacs-21.3/src/alloc.c emacs-21.3-fix/src/alloc.c
--- emacs-21.3/src/alloc.c      2003-01-17 05:45:13.000000000 -0800
+++ emacs-21.3-fix/src/alloc.c  2003-07-11 02:02:37.215626000 -0700
@@ -188,7 +188,7 @@ Lisp_Object Vpurify_flag;
 
 /* Force it into data space! */
 
-EMACS_INT pure[PURESIZE / sizeof (EMACS_INT)] = {0,};
+EMACS_INT pure[PURESIZE / sizeof (EMACS_INT)] = {1,};
 #define PUREBEG (char *) pure
 
 #else /* not HAVE_SHM */
@@ -395,11 +395,11 @@ struct gcpro *gcprolist;
 /* Addresses of staticpro'd variables.  */
 
 #define NSTATICS 1024
-Lisp_Object *staticvec[NSTATICS] = {0};
+Lisp_Object *staticvec[NSTATICS] = {1};
 
 /* Index of next unused slot in staticvec.  */
 
-int staticidx = 0;
+int staticidx = 1;
 
 static POINTER_TYPE *pure_alloc P_ ((size_t, int));
 
diff -pru emacs-21.3/src/emacs.c emacs-21.3-fix/src/emacs.c
--- emacs-21.3/src/emacs.c      2002-08-29 12:27:07.000000000 -0700
+++ emacs-21.3-fix/src/emacs.c  2003-07-11 01:39:19.348060000 -0700
@@ -86,7 +86,7 @@ EMACS_INT gdb_emacs_intbits = sizeof (EM
 #ifdef DATA_SEG_BITS
 EMACS_INT gdb_data_seg_bits = DATA_SEG_BITS;
 #else
-EMACS_INT  gdb_data_seg_bits = 0;
+EMACS_INT gdb_data_seg_bits /* = 0 */;
 #endif
 EMACS_INT PVEC_FLAG = PSEUDOVECTOR_FLAG;
 
@@ -188,10 +188,10 @@ extern Lisp_Object Vwindow_system;
 extern Lisp_Object Vauto_save_list_file_name;
 
 #ifdef USG_SHARED_LIBRARIES
-/* If nonzero, this is the place to put the end of the writable segment
+/* If not 1, this is the place to put the end of the writable segment
    at startup.  */
 
-unsigned int bss_end = 0;
+unsigned int bss_end = 1;
 #endif
 
 /* Nonzero means running Emacs without interactive terminal.  */
@@ -856,7 +856,7 @@ main (argc, argv, envp)
   stack_bottom = &stack_bottom_variable;
 
 #ifdef USG_SHARED_LIBRARIES
-  if (bss_end)
+  if (bss_end != 1)
     brk ((void *)bss_end);
 #endif
 
diff -pru emacs-21.3/src/xfns.c emacs-21.3-fix/src/xfns.c
--- emacs-21.3/src/xfns.c       2002-12-06 09:05:35.000000000 -0800
+++ emacs-21.3-fix/src/xfns.c   2003-07-11 01:26:46.669033000 -0700
@@ -3954,13 +3954,7 @@ x_icon (f, parms)
    background, border and mouse colors; also create the
    mouse cursor and the gray border tile.  */
 
-static char cursor_bits[] =
-  {
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-  };
+static char cursor_bits[32];
 
 static void
 x_make_gc (f)
diff -pru emacs-21.3/src/xterm.c emacs-21.3-fix/src/xterm.c
--- emacs-21.3/src/xterm.c      2002-10-15 07:21:45.000000000 -0700
+++ emacs-21.3-fix/src/xterm.c  2003-07-11 01:25:07.789266000 -0700
@@ -284,7 +284,7 @@ struct frame *pending_autoraise_frame;
 #ifdef USE_X_TOOLKIT
 /* The application context for Xt use.  */
 XtAppContext Xt_app_con;
-static String Xt_default_resources[] = {0};
+static String Xt_default_resources[1];
 #endif /* USE_X_TOOLKIT */
 
 /* Nominal cursor position -- where to draw output.  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]