unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Antipov <dmantipov@yandex.ru>
To: emacs-devel@gnu.org
Subject: [patch] combined build
Date: Thu, 15 Nov 2007 14:58:51 +0300	[thread overview]
Message-ID: <473C347B.6080907@yandex.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 1977 bytes --]

This patch provides a minimal support for compiling (the most of) emacs C code at once using
-combine option supported by never versions of GCC. Since an almost everything is compiled
each time when the compiler is invoked, this mode is not suitable for developers. But it might
be useful for package builders and other peoples who just wants to do './configure && make &&
make install' sequence. This feature also gives GCC a chance to optimize something during
inter-module analysis.

Notes:

1. Compiling with -combine implies quite strict function declarations vs. definitions checking,
    so C code is touched in some places. In particular, current 'fatal' implementation bombs
    out combining compilation, and I've redone it with va_args. This might be non-portable or
    may break some ancient compiler.

2. For me, it doesn't work when using GTK toolkit. When using both GTK and -combine, I've got
    the following nasty error messages:

    In file included from /usr/include/gtk-2.0/gtk/gtk.h:74,
                     from xterm.h:46,
                     from fns.c:53:
    /usr/include/gtk-2.0/gtk/gtkcurve.h:104: error: conflicting types for 'gtk_curve_get_vector'
    /usr/include/gtk-2.0/gtk/gtkcurve.h:104: error: previous declaration of 'gtk_curve_get_vector' was here
    /usr/include/gtk-2.0/gtk/gtkcurve.h:106: error: conflicting types for 'gtk_curve_set_vector'
    /usr/include/gtk-2.0/gtk/gtkcurve.h:106: error: previous declaration of 'gtk_curve_set_vector' was here

    I suspect this is a bug in GCC. So I've installed an additional check in configure.in
    to avoid using both GTK and -combine simultaneously.

3. On i386, combined compilation might eat up to 400M of memory, so it shouldn't be used on
    low-memory machines.

4. Dependencies are broken - everything.o depends only on .c files, and .h files included from
    them are ignored. But this should be safe if you just want to compile and install from clean
    sources.

Dmitry


[-- Attachment #2: combined-build.patch --]
[-- Type: text/x-patch, Size: 10118 bytes --]

Index: configure.in
===================================================================
RCS file: /sources/emacs/emacs/configure.in,v
retrieving revision 1.479
diff -u -r1.479 configure.in
--- configure.in	7 Nov 2007 04:00:24 -0000	1.479
+++ configure.in	15 Nov 2007 11:50:05 -0000
@@ -1326,6 +1326,23 @@
 unset has_option
 unset SAVE_CFLAGS
 
+AC_ARG_ENABLE(combine,
+[AS_HELP_STRING([--enable-combine],
+		[compile with -combine option (GCC only)])],
+  AC_MSG_CHECKING([whether combined compilation is supported])
+  combine=no
+  if test $(basename ${CC}) = "gcc"; then
+    LANG=C ${CC} -combine 2>&1 | grep -q unrecognized
+    test $? -eq 1 && combine=yes
+  fi
+  if test "$combine" = "yes"; then
+    AC_DEFINE(COMBINE, [1], [Define to build with -combine GCC option.])
+    AC_MSG_RESULT(yes)
+  else
+    AC_MSG_RESULT(no)
+    AC_MSG_ERROR([Reconfigure without --enable-combine option.])
+  fi)
+
 #### Some other nice autoconf tests.
 
 dnl checks for programs
@@ -2192,6 +2209,11 @@
 
 fi
 
+dnl Using both GTK and -combine doesn't work for now.
+if test "${HAVE_GTK}" = "yes" && test "${enable_combine+set}" = set; then
+   AC_MSG_ERROR([(Due to GCC bugs ?) GTK toolkit may not be used with -combine option.
+Reconfigure either with another X toolkit or without --enable-combine.])
+fi
 
 if test "${HAVE_GTK}" = "yes"; then
 
Index: src/Makefile.in
===================================================================
RCS file: /sources/emacs/emacs/src/Makefile.in,v
retrieving revision 1.359
diff -u -r1.359 Makefile.in
--- src/Makefile.in	1 Nov 2007 07:16:09 -0000	1.359
+++ src/Makefile.in	15 Nov 2007 11:50:06 -0000
@@ -978,7 +978,13 @@
    for the first time, this prevents any variation between configurations
    in the contents of the DOC file.
    Likewise for ${SOME_MACHINE_LISP}.  */
+
+#ifdef COMBINE
+combobj = everything.o
+${etc}DOC: ${libsrc}make-docfile${EXEEXT} ${combobj} ${shortlisp} ${SOME_MACHINE_LISP}
+#else 
 ${etc}DOC: ${libsrc}make-docfile${EXEEXT} ${obj} ${shortlisp} ${SOME_MACHINE_LISP}
+#endif /* COMBINE */
 	-rm -f ${etc}DOC
 	${libsrc}make-docfile -d ${srcdir} ${SOME_MACHINE_OBJECTS} ${obj} > ${etc}DOC
 	${libsrc}make-docfile -a ${etc}DOC -d ${srcdir} ${SOME_MACHINE_LISP} ${shortlisp}
@@ -991,11 +997,21 @@
 #define MAKE_PARALLEL
 #endif
 
+#ifdef COMBINE
+${combobj}: $(obj:.o=.c) $(otherobj:.o=.c) 
+	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -combine $? -o $@
+
+temacs${EXEEXT}: MAKE_PARALLEL $(LOCALCPP) $(STARTFILES) stamp-oldxmenu ${combobj} OBJECTS_MACHINE prefix-args${EXEEXT}
+	echo "${obj} ${otherobj} " OBJECTS_MACHINE > buildobj.lst
+	$(LD) YMF_PASS_LDFLAGS (${STARTFLAGS} ${TEMACS_LDFLAGS}) $(LDFLAGS) \
+    -o temacs ${STARTFILES} ${combobj} OBJECTS_MACHINE ${LIBES}
+#else
 temacs${EXEEXT}: MAKE_PARALLEL $(LOCALCPP) $(STARTFILES) stamp-oldxmenu ${obj} ${otherobj} OBJECTS_MACHINE prefix-args${EXEEXT}
 	echo "${obj} ${otherobj} " OBJECTS_MACHINE > buildobj.lst
 	$(LD) YMF_PASS_LDFLAGS (${STARTFLAGS} ${TEMACS_LDFLAGS}) $(LDFLAGS) \
     -o temacs ${STARTFILES} ${obj} ${otherobj}  \
     OBJECTS_MACHINE ${LIBES}
+#endif /* COMBINE */
 
 /* We do not use ALL_LDFLAGS because LD_SWITCH_SYSTEM and LD_SWITCH_MACHINE
    often contain options that have to do with using Emacs''s crt0,
Index: src/cm.c
===================================================================
RCS file: /sources/emacs/emacs/src/cm.c,v
retrieving revision 1.24
diff -u -r1.24 cm.c
--- src/cm.c	29 Aug 2007 05:27:53 -0000	1.24
+++ src/cm.c	15 Nov 2007 11:50:06 -0000
@@ -30,18 +30,6 @@
 #include "termhooks.h"
 #include "termchar.h"
 
-
-/* For now, don't try to include termcap.h.  On some systems,
-   configure finds a non-standard termcap.h that the main build
-   won't find.  */
-
-#if defined HAVE_TERMCAP_H && 0
-#include <termcap.h>
-#else
-extern void tputs P_ ((const char *, int, int (*)(int)));
-extern char *tgoto P_ ((const char *, int, int));
-#endif
-
 #define	BIG	9999		/* 9999 good on VAXen.  For 16 bit machines
 				   use about 2000.... */
 
Index: src/cm.h
===================================================================
RCS file: /sources/emacs/emacs/src/cm.h,v
retrieving revision 1.23
diff -u -r1.23 cm.h
--- src/cm.h	29 Aug 2007 05:27:54 -0000	1.23
+++ src/cm.h	15 Nov 2007 11:50:06 -0000
@@ -162,6 +162,17 @@
 extern int cost;
 extern int evalcost ();
 
+/* For now, don't try to include termcap.h.  On some systems,
+   configure finds a non-standard termcap.h that the main build
+   won't find.  */
+
+#if defined HAVE_TERMCAP_H && 0
+#include <termcap.h>
+#else
+extern int tputs P_ ((const char *, int, int (*)(int)));
+extern char *tgoto P_ ((const char *, int, int));
+#endif
+
 #define emacs_tputs(tty, str, affcnt, putc) (current_tty = (tty), tputs (str, affcnt, putc))
 
 extern struct tty_display_info *current_tty;
Index: src/config.in
===================================================================
RCS file: /sources/emacs/emacs/src/config.in,v
retrieving revision 1.236
diff -u -r1.236 config.in
--- src/config.in	1 Nov 2007 07:38:58 -0000	1.236
+++ src/config.in	15 Nov 2007 11:50:06 -0000
@@ -32,6 +32,9 @@
 /* Define to 1 if the mktime function is broken. */
 #undef BROKEN_MKTIME
 
+/* Define to build with -combine GCC option. */
+#undef COMBINE
+
 /* 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.
    */
Index: src/fringe.c
===================================================================
RCS file: /sources/emacs/emacs/src/fringe.c,v
retrieving revision 1.48
diff -u -r1.48 fringe.c
--- src/fringe.c	14 Sep 2007 07:33:27 -0000	1.48
+++ src/fringe.c	15 Nov 2007 11:50:06 -0000
@@ -1659,7 +1659,7 @@
 /* Garbage collection hook */
 
 void
-mark_fringe_data ()
+mark_fringe_data (void)
 {
   int i;
 
Index: src/keyboard.c
===================================================================
RCS file: /sources/emacs/emacs/src/keyboard.c,v
retrieving revision 1.929
diff -u -r1.929 keyboard.c
--- src/keyboard.c	9 Nov 2007 12:19:21 -0000	1.929
+++ src/keyboard.c	15 Nov 2007 11:50:06 -0000
@@ -12519,7 +12519,7 @@
 /* Mark the pointers in the kboard objects.
    Called by the Fgarbage_collector.  */
 void
-mark_kboards ()
+mark_kboards (void)
 {
   KBOARD *kb;
   Lisp_Object *p;
Index: src/lisp.h
===================================================================
RCS file: /sources/emacs/emacs/src/lisp.h,v
retrieving revision 1.599
diff -u -r1.599 lisp.h
--- src/lisp.h	29 Oct 2007 18:15:02 -0000	1.599
+++ src/lisp.h	15 Nov 2007 11:50:06 -0000
@@ -2361,6 +2361,7 @@
 void hash_remove P_ ((struct Lisp_Hash_Table *, Lisp_Object));
 void hash_clear P_ ((struct Lisp_Hash_Table *));
 void remove_hash_entry P_ ((struct Lisp_Hash_Table *, int));
+extern void seed_random P_ ((long));
 extern void init_fns P_ ((void));
 EXFUN (Fsxhash, 1);
 EXFUN (Fmake_hash_table, MANY);
@@ -3227,6 +3228,11 @@
 extern int emacs_close P_ ((int));
 extern int emacs_read P_ ((int, char *, unsigned int));
 extern int emacs_write P_ ((int, const char *, unsigned int));
+extern void fatal (const char *, ...) NO_RETURN;
+
+/* Defined in unexec implementation.  */
+extern void unexec P_ ((char *, char *, unsigned int,
+			unsigned int, unsigned int));
 
 /* defined in filelock.c */
 EXFUN (Funlock_buffer, 0);
@@ -3255,7 +3261,6 @@
 
 /* Defined in term.c */
 extern void syms_of_term P_ ((void));
-extern void fatal () NO_RETURN;
 
 /* Defined in terminal.c */
 extern void syms_of_terminal P_ ((void));
Index: src/sysdep.c
===================================================================
RCS file: /sources/emacs/emacs/src/sysdep.c,v
retrieving revision 1.288
diff -u -r1.288 sysdep.c
--- src/sysdep.c	27 Sep 2007 21:20:06 -0000	1.288
+++ src/sysdep.c	15 Nov 2007 11:50:06 -0000
@@ -26,6 +26,8 @@
 #include <signal.h>
 #include <stdio.h>
 #include <setjmp.h>
+#include <stdarg.h>
+
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -2421,7 +2423,7 @@
  */
 
 #ifndef start_of_data
-char *
+POINTER_TYPE *
 start_of_data ()
 {
 #ifdef DATA_START
@@ -5496,5 +5498,19 @@
 }
 #endif /* HAVE_STRSIGNAL */
 
+void
+fatal (const char *fmt, ...)
+{
+  va_list ap;
+  
+  va_start (ap, fmt);
+  fprintf (stderr, "emacs: ");
+  vfprintf (stderr, fmt, ap);
+  va_end (ap);
+  fprintf (stderr, "\n");
+  fflush (stderr);
+  exit (1);
+}
+
 /* arch-tag: edb43589-4e09-4544-b325-978b5b121dcf
    (do not change this comment) */
Index: src/term.c
===================================================================
RCS file: /sources/emacs/emacs/src/term.c,v
retrieving revision 1.209
diff -u -r1.209 term.c
--- src/term.c	25 Oct 2007 02:38:37 -0000	1.209
+++ src/term.c	15 Nov 2007 11:50:06 -0000
@@ -54,20 +54,6 @@
 #include "syssignal.h"
 #include "systty.h"
 #include "intervals.h"
-
-/* For now, don't try to include termcap.h.  On some systems,
-   configure finds a non-standard termcap.h that the main build
-   won't find.  */
-
-#if defined HAVE_TERMCAP_H && 0
-#include <termcap.h>
-#else
-extern void tputs P_ ((const char *, int, int (*)(int)));
-extern int tgetent P_ ((char *, const char *));
-extern int tgetflag P_ ((char *id));
-extern int tgetnum P_ ((char *id));
-#endif
-
 #include "cm.h"
 #ifdef HAVE_X_WINDOWS
 #include "xterm.h"
@@ -3754,18 +3740,6 @@
   abort ();
 }
 
-/* VARARGS 1 */
-void
-fatal (str, arg1, arg2)
-     char *str, *arg1, *arg2;
-{
-  fprintf (stderr, "emacs: ");
-  fprintf (stderr, str, arg1, arg2);
-  fprintf (stderr, "\n");
-  fflush (stderr);
-  exit (1);
-}
-
 \f
 
 /* Delete the given tty terminal, closing all frames on it. */
Index: src/terminfo.c
===================================================================
RCS file: /sources/emacs/emacs/src/terminfo.c,v
retrieving revision 1.22
diff -u -r1.22 terminfo.c
--- src/terminfo.c	26 Jul 2007 05:27:57 -0000	1.22
+++ src/terminfo.c	15 Nov 2007 11:50:06 -0000
@@ -42,7 +42,7 @@
      int len, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9;
 {
   char *temp;
-  extern char *tparm();
+  extern char *tparm (char *, ...);
 
   temp = tparm (string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
   if (outstring == 0)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

             reply	other threads:[~2007-11-15 11:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-15 11:58 Dmitry Antipov [this message]
2007-11-15 16:28 ` [patch] combined build Dan Nicolaescu
2007-11-15 16:59   ` Stefan Monnier
2007-11-15 19:46     ` Dan Nicolaescu
2007-11-16  4:29     ` Richard Stallman
2007-11-16 11:11       ` Dmitry Antipov
2007-11-16 20:42       ` Dan Nicolaescu
2007-11-17 23:30         ` Richard Stallman
2007-11-16 10:46     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=473C347B.6080907@yandex.ru \
    --to=dmantipov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).