aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2016-01-30 14:20:57 -0800
committerPaul Eggert2016-01-30 15:26:08 -0800
commit7fdc3cf046ee112b883752ea15ca8cb05444d12f (patch)
tree3656fb91c2100d280d0a70d3b81ead2a63ed317e
parenta4817d834e7d125d31049dfb6fd0a0df4782bad0 (diff)
downloademacs-7fdc3cf046ee112b883752ea15ca8cb05444d12f.tar.gz
emacs-7fdc3cf046ee112b883752ea15ca8cb05444d12f.zip
Build lib/e-*.o only on platforms that need it
* configure.ac (hybrid malloc): Simplify configuration. (SHEAP_OBJ): Remove; no longer needed. (HYBRID_MALLOC): New var. Subst it. (HYBRID_MALLOC_LIB): New Automake conditional. * lib/Makefile.am (noinst_LIBRARIES): Add libegnu.a only if HYBRID_MALLOC_LIB. (libegnu_a_CPPFLAGS): Omit AM_CPPFLAGS; not needed. (MOSTLYCLEANFILES): Add libegnu.a. * src/Makefile.in (SHEAP_OBJ): Remove. (HYBRID_MALLOC): New macro. (base_obj): Use it to conditionally add sheap.o. (LIBEGNU_ARCHIVE): New macro. ($(LIBEGNU_ARCHIVE)): New rule, replacing $(lib)/libegnu.a. All uses of the latter replaced by the former. * src/alloc.c (USE_ALIGNED_ALLOC): Simplify configuration. Correct misspelling ALIGNED_ALLOC to HAVE_ALIGNED_ALLOC. * src/gmalloc.c: Update comment. * src/lisp.h (aligned_alloc) [!DOUG_LEA_MALLOC && !HYBRID_MALLOC && !SYSTEM_MALLOC]: New decl. (Bug#22086)
-rw-r--r--configure.ac9
-rw-r--r--lib/Makefile.am23
-rw-r--r--src/Makefile.in12
-rw-r--r--src/alloc.c13
-rw-r--r--src/gmalloc.c8
-rw-r--r--src/lisp.h1
6 files changed, 39 insertions, 27 deletions
diff --git a/configure.ac b/configure.ac
index ef6ddc66d4d..856c36c7061 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2123,12 +2123,12 @@ case "$opsys" in
2123esac 2123esac
2124 2124
2125if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \ 2125if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \
2126 && test "${UNEXEC_OBJ}" = unexelf.o && test "${hybrid_malloc}" != no; then 2126 && test "${UNEXEC_OBJ}" = unexelf.o; then
2127 hybrid_malloc=yes 2127 hybrid_malloc=yes
2128fi 2128fi
2129 2129
2130GMALLOC_OBJ= 2130GMALLOC_OBJ=
2131SHEAP_OBJ= 2131HYBRID_MALLOC=
2132if test "${system_malloc}" = "yes"; then 2132if test "${system_malloc}" = "yes"; then
2133 AC_DEFINE([SYSTEM_MALLOC], 1, 2133 AC_DEFINE([SYSTEM_MALLOC], 1,
2134 [Define to 1 to use the system memory allocator, even if it is not 2134 [Define to 1 to use the system memory allocator, even if it is not
@@ -2140,10 +2140,10 @@ if test "${system_malloc}" = "yes"; then
2140elif test "$hybrid_malloc" = yes; then 2140elif test "$hybrid_malloc" = yes; then
2141 AC_DEFINE(HYBRID_MALLOC, 1, 2141 AC_DEFINE(HYBRID_MALLOC, 1,
2142 [Define to use gmalloc before dumping and the system malloc after.]) 2142 [Define to use gmalloc before dumping and the system malloc after.])
2143 HYBRID_MALLOC=1
2143 GNU_MALLOC= 2144 GNU_MALLOC=
2144 GNU_MALLOC_reason="only before dumping" 2145 GNU_MALLOC_reason="only before dumping"
2145 GMALLOC_OBJ=gmalloc.o 2146 GMALLOC_OBJ=gmalloc.o
2146 SHEAP_OBJ=sheap.o
2147 VMLIMIT_OBJ= 2147 VMLIMIT_OBJ=
2148else 2148else
2149 test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o 2149 test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
@@ -2163,8 +2163,9 @@ else
2163 of the main data segment.]) 2163 of the main data segment.])
2164 fi 2164 fi
2165fi 2165fi
2166AC_SUBST([HYBRID_MALLOC])
2167AM_CONDITIONAL([HYBRID_MALLOC_LIB], [test -n "$HYBRID_MALLOC"])
2166AC_SUBST(GMALLOC_OBJ) 2168AC_SUBST(GMALLOC_OBJ)
2167AC_SUBST(SHEAP_OBJ)
2168AC_SUBST(VMLIMIT_OBJ) 2169AC_SUBST(VMLIMIT_OBJ)
2169 2170
2170if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then 2171if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a1dd6a4ca90..74bab4eee06 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,3 +1,20 @@
1# Copyright 2016 Free Software Foundation, Inc.
2
3# This file is part of GNU Emacs.
4
5# GNU Emacs is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9
10# GNU Emacs is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14
15# You should have received a copy of the GNU General Public License
16# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
17
1BUILT_SOURCES = 18BUILT_SOURCES =
2CLEANFILES = 19CLEANFILES =
3EXTRA_DIST = 20EXTRA_DIST =
@@ -17,14 +34,16 @@ include gnulib.mk
17libgnu_a_SOURCES += openat-die.c save-cwd.c 34libgnu_a_SOURCES += openat-die.c save-cwd.c
18endif 35endif
19 36
37if HYBRID_MALLOC_LIB
20noinst_LIBRARIES += libegnu.a 38noinst_LIBRARIES += libegnu.a
39endif
21 40
22libegnu_a_SOURCES = $(libgnu_a_SOURCES) 41libegnu_a_SOURCES = $(libgnu_a_SOURCES)
23libegnu_a_LIBADD = $(patsubst %.o,e-%.o,$(libgnu_a_LIBADD)) 42libegnu_a_LIBADD = $(patsubst %.o,e-%.o,$(libgnu_a_LIBADD))
24EXTRA_libegnu_a_SOURCES = $(EXTRA_libgnu_a_SOURCES) 43EXTRA_libegnu_a_SOURCES = $(EXTRA_libgnu_a_SOURCES)
25libegnu_a_SHORTNAME = e 44libegnu_a_SHORTNAME = e
26 45libegnu_a_CPPFLAGS = -Demacs
27libegnu_a_CPPFLAGS = $(AM_CPPFLAGS) -Demacs 46MOSTLYCLEANFILES += libegnu.a
28 47
29.PHONY: bootstrap-clean 48.PHONY: bootstrap-clean
30 49
diff --git a/src/Makefile.in b/src/Makefile.in
index e59d3b1568f..150575864da 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -254,8 +254,7 @@ XFIXES_CFLAGS = @XFIXES_CFLAGS@
254## widget.o if USE_X_TOOLKIT, otherwise empty. 254## widget.o if USE_X_TOOLKIT, otherwise empty.
255WIDGET_OBJ=@WIDGET_OBJ@ 255WIDGET_OBJ=@WIDGET_OBJ@
256 256
257## sheap.o if HYBRID_MALLOC, otherwise empty. 257HYBRID_MALLOC = @HYBRID_MALLOC@
258SHEAP_OBJ=@SHEAP_OBJ@
259 258
260## cygw32.o if CYGWIN, otherwise empty. 259## cygw32.o if CYGWIN, otherwise empty.
261CYGWIN_OBJ=@CYGWIN_OBJ@ 260CYGWIN_OBJ=@CYGWIN_OBJ@
@@ -400,6 +399,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
400 doprnt.o intervals.o textprop.o composite.o xml.o $(NOTIFY_OBJ) \ 399 doprnt.o intervals.o textprop.o composite.o xml.o $(NOTIFY_OBJ) \
401 $(XWIDGETS_OBJ) \ 400 $(XWIDGETS_OBJ) \
402 profiler.o decompress.o \ 401 profiler.o decompress.o \
402 $(if $(HYBRID_MALLOC),sheap.o) \
403 $(SHEAP_OBJ) \ 403 $(SHEAP_OBJ) \
404 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ 404 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
405 $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) 405 $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ)
@@ -580,7 +580,9 @@ globals.h: gl-stamp; @true
580 580
581$(ALLOBJS): globals.h 581$(ALLOBJS): globals.h
582 582
583$(lib)/libegnu.a: $(config_h) 583LIBEGNU_ARCHIVE = $(lib)/lib$(if $(HYBRID_MALLOC),e)gnu.a
584
585$(LIBEGNU_ARCHIVE): $(config_h)
584 $(MAKE) -C $(lib) all 586 $(MAKE) -C $(lib) all
585 587
586## We have to create $(etc) here because init_cmdargs tests its 588## We have to create $(etc) here because init_cmdargs tests its
@@ -588,9 +590,9 @@ $(lib)/libegnu.a: $(config_h)
588## This goes on to affect various things, and the emacs binary fails 590## This goes on to affect various things, and the emacs binary fails
589## to start if Vinstallation_directory has the wrong value. 591## to start if Vinstallation_directory has the wrong value.
590temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) \ 592temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) \
591 $(lib)/libegnu.a $(EMACSRES) ${charsets} ${charscript} 593 $(LIBEGNU_ARCHIVE) $(EMACSRES) ${charsets} ${charscript}
592 $(AM_V_CCLD)$(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \ 594 $(AM_V_CCLD)$(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
593 -o temacs $(ALLOBJS) $(lib)/libegnu.a $(W32_RES_LINK) $(LIBES) 595 -o temacs $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES)
594 $(MKDIR_P) $(etc) 596 $(MKDIR_P) $(etc)
595ifneq ($(CANNOT_DUMP),yes) 597ifneq ($(CANNOT_DUMP),yes)
596 $(PAXCTL_if_present) -r $@ 598 $(PAXCTL_if_present) -r $@
diff --git a/src/alloc.c b/src/alloc.c
index 039b7285e39..b1d3f2e6511 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1123,17 +1123,12 @@ lisp_free (void *block)
1123 clang 3.3 anyway. */ 1123 clang 3.3 anyway. */
1124 1124
1125#if ! ADDRESS_SANITIZER 1125#if ! ADDRESS_SANITIZER
1126# if !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC 1126# if defined HYBRID_MALLOC
1127# define USE_ALIGNED_ALLOC 1 1127# if defined HAVE_ALIGNED_ALLOC || defined HAVE_POSIX_MEMALIGN
1128/* Defined in gmalloc.c. */
1129void *aligned_alloc (size_t, size_t);
1130# elif defined HYBRID_MALLOC
1131# if defined ALIGNED_ALLOC || defined HAVE_POSIX_MEMALIGN
1132# define USE_ALIGNED_ALLOC 1 1128# define USE_ALIGNED_ALLOC 1
1133# define aligned_alloc hybrid_aligned_alloc
1134/* Defined in gmalloc.c. */
1135void *aligned_alloc (size_t, size_t);
1136# endif 1129# endif
1130# elif !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC
1131# define USE_ALIGNED_ALLOC 1
1137# elif defined HAVE_ALIGNED_ALLOC 1132# elif defined HAVE_ALIGNED_ALLOC
1138# define USE_ALIGNED_ALLOC 1 1133# define USE_ALIGNED_ALLOC 1
1139# elif defined HAVE_POSIX_MEMALIGN 1134# elif defined HAVE_POSIX_MEMALIGN
diff --git a/src/gmalloc.c b/src/gmalloc.c
index 4feff83a2d1..ca862767bb2 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -65,13 +65,7 @@ extern void *__default_morecore (ptrdiff_t);
65 however, will use the system malloc, realloc.... In other source 65 however, will use the system malloc, realloc.... In other source
66 files, malloc, realloc... are renamed hybrid_malloc, 66 files, malloc, realloc... are renamed hybrid_malloc,
67 hybrid_realloc... via macros in conf_post.h. hybrid_malloc and 67 hybrid_realloc... via macros in conf_post.h. hybrid_malloc and
68 friends are wrapper functions defined later in this file. 68 friends are wrapper functions defined later in this file. */
69 aligned_alloc is defined as a macro only in alloc.c.
70
71 As of this writing (August 2014), Cygwin is the only platform on
72 which HYBRID_MACRO is defined. Any other platform that wants to
73 define it will have to define the macros DUMPED and
74 ALLOCATED_BEFORE_DUMPING, defined below for Cygwin. */
75#undef malloc 69#undef malloc
76#undef realloc 70#undef realloc
77#undef calloc 71#undef calloc
diff --git a/src/lisp.h b/src/lisp.h
index 4f4ec2c5fcc..cafcfdef438 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3772,6 +3772,7 @@ INLINE void (check_cons_list) (void) { lisp_h_check_cons_list (); }
3772#if !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC && !defined SYSTEM_MALLOC 3772#if !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC && !defined SYSTEM_MALLOC
3773/* Defined in gmalloc.c. */ 3773/* Defined in gmalloc.c. */
3774extern size_t __malloc_extra_blocks; 3774extern size_t __malloc_extra_blocks;
3775extern void *aligned_alloc (size_t, size_t);
3775#endif 3776#endif
3776extern void malloc_enable_thread (void); 3777extern void malloc_enable_thread (void);
3777 3778