>From 925eb6dc43fe4a7fd3ad90caf5dd29101c7577a8 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 30 Jan 2016 00:47:26 -0800 Subject: [PATCH 10/12] 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) --- configure.ac | 9 +++++---- lib/Makefile.am | 23 +++++++++++++++++++++-- src/Makefile.in | 12 +++++++----- src/alloc.c | 13 ++++--------- src/gmalloc.c | 8 +------- src/lisp.h | 1 + 6 files changed, 39 insertions(+), 27 deletions(-) diff --git a/configure.ac b/configure.ac index fe3a990..3d70893 100644 --- a/configure.ac +++ b/configure.ac @@ -2123,12 +2123,12 @@ case "$opsys" in esac if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \ - && test "${UNEXEC_OBJ}" = unexelf.o && test "${hybrid_malloc}" != no; then + && test "${UNEXEC_OBJ}" = unexelf.o; then hybrid_malloc=yes fi GMALLOC_OBJ= -SHEAP_OBJ= +HYBRID_MALLOC= if test "${system_malloc}" = "yes"; then AC_DEFINE([SYSTEM_MALLOC], 1, [Define to 1 to use the system memory allocator, even if it is not @@ -2140,10 +2140,10 @@ if test "${system_malloc}" = "yes"; then elif test "$hybrid_malloc" = yes; then AC_DEFINE(HYBRID_MALLOC, 1, [Define to use gmalloc before dumping and the system malloc after.]) + HYBRID_MALLOC=1 GNU_MALLOC= GNU_MALLOC_reason="only before dumping" GMALLOC_OBJ=gmalloc.o - SHEAP_OBJ=sheap.o VMLIMIT_OBJ= else test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o @@ -2163,8 +2163,9 @@ else of the main data segment.]) fi fi +AC_SUBST([HYBRID_MALLOC]) +AM_CONDITIONAL([HYBRID_MALLOC_LIB], [test -n "$HYBRID_MALLOC"]) AC_SUBST(GMALLOC_OBJ) -AC_SUBST(SHEAP_OBJ) AC_SUBST(VMLIMIT_OBJ) if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then diff --git a/lib/Makefile.am b/lib/Makefile.am index a1dd6a4..74bab4e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,3 +1,20 @@ +# Copyright 2016 Free Software Foundation, Inc. + +# This file is part of GNU Emacs. + +# GNU Emacs is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# GNU Emacs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs. If not, see . + BUILT_SOURCES = CLEANFILES = EXTRA_DIST = @@ -17,14 +34,16 @@ include gnulib.mk libgnu_a_SOURCES += openat-die.c save-cwd.c endif +if HYBRID_MALLOC_LIB noinst_LIBRARIES += libegnu.a +endif libegnu_a_SOURCES = $(libgnu_a_SOURCES) libegnu_a_LIBADD = $(patsubst %.o,e-%.o,$(libgnu_a_LIBADD)) EXTRA_libegnu_a_SOURCES = $(EXTRA_libgnu_a_SOURCES) libegnu_a_SHORTNAME = e - -libegnu_a_CPPFLAGS = $(AM_CPPFLAGS) -Demacs +libegnu_a_CPPFLAGS = -Demacs +MOSTLYCLEANFILES += libegnu.a .PHONY: bootstrap-clean diff --git a/src/Makefile.in b/src/Makefile.in index 25dc3f8..cc9a6e9 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -254,8 +254,7 @@ XFIXES_CFLAGS = @XFIXES_CFLAGS@ ## widget.o if USE_X_TOOLKIT, otherwise empty. WIDGET_OBJ=@WIDGET_OBJ@ -## sheap.o if HYBRID_MALLOC, otherwise empty. -SHEAP_OBJ=@SHEAP_OBJ@ +HYBRID_MALLOC = @HYBRID_MALLOC@ ## cygw32.o if CYGWIN, otherwise empty. CYGWIN_OBJ=@CYGWIN_OBJ@ @@ -400,6 +399,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ doprnt.o intervals.o textprop.o composite.o xml.o $(NOTIFY_OBJ) \ $(XWIDGETS_OBJ) \ profiler.o decompress.o \ + $(if $(HYBRID_MALLOC),sheap.o) \ $(SHEAP_OBJ) \ $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) @@ -580,7 +580,9 @@ globals.h: gl-stamp; @true $(ALLOBJS): globals.h -$(lib)/libegnu.a: $(config_h) +LIBEGNU_ARCHIVE = $(lib)/lib$(if $(HYBRID_MALLOC),e)gnu.a + +$(LIBEGNU_ARCHIVE): $(config_h) $(MAKE) -C $(lib) all ## We have to create $(etc) here because init_cmdargs tests its @@ -588,9 +590,9 @@ $(lib)/libegnu.a: $(config_h) ## This goes on to affect various things, and the emacs binary fails ## to start if Vinstallation_directory has the wrong value. temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) \ - $(lib)/libegnu.a $(EMACSRES) ${charsets} ${charscript} + $(LIBEGNU_ARCHIVE) $(EMACSRES) ${charsets} ${charscript} $(AM_V_CCLD)$(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \ - -o temacs $(ALLOBJS) $(lib)/libegnu.a $(W32_RES_LINK) $(LIBES) + -o temacs $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES) $(MKDIR_P) $(etc) ifneq ($(CANNOT_DUMP),yes) $(PAXCTL_if_present) -r $@ diff --git a/src/alloc.c b/src/alloc.c index 039b728..b1d3f2e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1123,17 +1123,12 @@ lisp_free (void *block) clang 3.3 anyway. */ #if ! ADDRESS_SANITIZER -# if !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC -# define USE_ALIGNED_ALLOC 1 -/* Defined in gmalloc.c. */ -void *aligned_alloc (size_t, size_t); -# elif defined HYBRID_MALLOC -# if defined ALIGNED_ALLOC || defined HAVE_POSIX_MEMALIGN +# if defined HYBRID_MALLOC +# if defined HAVE_ALIGNED_ALLOC || defined HAVE_POSIX_MEMALIGN # define USE_ALIGNED_ALLOC 1 -# define aligned_alloc hybrid_aligned_alloc -/* Defined in gmalloc.c. */ -void *aligned_alloc (size_t, size_t); # endif +# elif !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC +# define USE_ALIGNED_ALLOC 1 # elif defined HAVE_ALIGNED_ALLOC # define USE_ALIGNED_ALLOC 1 # elif defined HAVE_POSIX_MEMALIGN diff --git a/src/gmalloc.c b/src/gmalloc.c index 4feff83..ca86276 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -65,13 +65,7 @@ extern void *__default_morecore (ptrdiff_t); however, will use the system malloc, realloc.... In other source files, malloc, realloc... are renamed hybrid_malloc, hybrid_realloc... via macros in conf_post.h. hybrid_malloc and - friends are wrapper functions defined later in this file. - aligned_alloc is defined as a macro only in alloc.c. - - As of this writing (August 2014), Cygwin is the only platform on - which HYBRID_MACRO is defined. Any other platform that wants to - define it will have to define the macros DUMPED and - ALLOCATED_BEFORE_DUMPING, defined below for Cygwin. */ + friends are wrapper functions defined later in this file. */ #undef malloc #undef realloc #undef calloc diff --git a/src/lisp.h b/src/lisp.h index 4f4ec2c..cafcfde 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3772,6 +3772,7 @@ INLINE void (check_cons_list) (void) { lisp_h_check_cons_list (); } #if !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC && !defined SYSTEM_MALLOC /* Defined in gmalloc.c. */ extern size_t __malloc_extra_blocks; +extern void *aligned_alloc (size_t, size_t); #endif extern void malloc_enable_thread (void); -- 2.5.0