From 0b187fd2bfb797e113626df1b3740edbda8b698a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 20 Nov 2016 16:57:17 -0800 Subject: [PATCH] Make CANNOT_DUMP work better on GNU/Linux Clean up some of the bitrot affecting the CANNOT_DUMP code. This lets the build succeed again, and fixes the testing framework so that most test cases now pass. About twenty test cases still fail, though, and we still have Bug#24974. * configure.ac (CANNOT_DUMP): Now empty if CANNOT_DUMP. (SYSTEM_MALLOC): Now true if CANNOT_DUMP. There should no longer be any point to messing with a private memory allocator unless Emacs is dumping. * src/alloc.c (alloc_unexec_pre, alloc_unexec_post, check_pure_size): * src/image.c (reset_image_types): * src/lastfile.c (my_endbss, _my_endbss, my_endbss_static): Do not define if CANNOT_DUMP. * src/emacs.c (might_dump) [CANNOT_DUMP]: Now always false and local. (daemon_pipe) [!WINDOWSNT]: Now static. * test/Makefile.in (mostlyclean): Remove *.tmp files. (make-test-deps.mk): Elide CANNOT_DUMP chatter. --- configure.ac | 2 ++ src/alloc.c | 22 ++++++++++++++-------- src/emacs.c | 10 +++++++--- src/image.c | 3 +++ src/lastfile.c | 4 ++++ test/Makefile.in | 7 +++++-- 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index c9759e18a02..2d116de3b6b 100644 --- a/configure.ac +++ b/configure.ac @@ -1366,6 +1366,7 @@ case "$opsys" in UNEXEC_OBJ=unexsol.o ;; esac +test "$CANNOT_DUMP" = "yes" && UNEXEC_OBJ= LD_SWITCH_SYSTEM= case "$opsys" in @@ -2154,6 +2155,7 @@ doug_lea_malloc=$emacs_cv_var_doug_lea_malloc hybrid_malloc= system_malloc=yes +test "$CANNOT_DUMP" = yes || case "$opsys" in ## darwin ld insists on the use of malloc routines in the System framework. darwin | mingw32 | nacl | sol2-10) ;; diff --git a/src/alloc.c b/src/alloc.c index 90c6f9441fa..175dcab2487 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -173,31 +173,34 @@ voidfuncptr __MALLOC_HOOK_VOLATILE __malloc_initialize_hook EXTERNALLY_VISIBLE #endif +#if defined DOUG_LEA_MALLOC || !defined CANNOT_DUMP + /* Allocator-related actions to do just before and after unexec. */ void alloc_unexec_pre (void) { -#ifdef DOUG_LEA_MALLOC +# ifdef DOUG_LEA_MALLOC malloc_state_ptr = malloc_get_state (); if (!malloc_state_ptr) fatal ("malloc_get_state: %s", strerror (errno)); -#endif -#ifdef HYBRID_MALLOC +# endif +# ifdef HYBRID_MALLOC bss_sbrk_did_unexec = true; -#endif +# endif } void alloc_unexec_post (void) { -#ifdef DOUG_LEA_MALLOC +# ifdef DOUG_LEA_MALLOC free (malloc_state_ptr); -#endif -#ifdef HYBRID_MALLOC +# endif +# ifdef HYBRID_MALLOC bss_sbrk_did_unexec = false; -#endif +# endif } +#endif /* Mark, unmark, query mark bit of a Lisp string. S must be a pointer to a struct Lisp_String. */ @@ -5216,6 +5219,8 @@ pure_alloc (size_t size, int type) } +#ifndef CANNOT_DUMP + /* Print a warning if PURESIZE is too small. */ void @@ -5226,6 +5231,7 @@ check_pure_size (void) " bytes needed)"), pure_bytes_used + pure_bytes_used_before_overflow); } +#endif /* Find the byte sequence {DATA[0], ..., DATA[NBYTES-1], '\0'} from diff --git a/src/emacs.c b/src/emacs.c index efd4fa329df..ac9b6495337 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -130,11 +130,15 @@ Lisp_Object Vlibrary_cache; on subsequent starts. */ bool initialized; +#ifdef CANNOT_DUMP +enum { might_dump = false }; +#else /* Set to true if this instance of Emacs might dump. */ -#ifndef DOUG_LEA_MALLOC +# ifndef DOUG_LEA_MALLOC static -#endif +# endif bool might_dump; +#endif #ifdef DARWIN_OS extern void unexec_init_emacs_zone (void); @@ -196,7 +200,7 @@ int daemon_type; #ifndef WINDOWSNT /* Pipe used to send exit notification to the background daemon parent at startup. On Windows, we use a kernel event instead. */ -int daemon_pipe[2]; +static int daemon_pipe[2]; #else HANDLE w32_daemon_event; #endif diff --git a/src/image.c b/src/image.c index d82fedb8dea..5614f39e15b 100644 --- a/src/image.c +++ b/src/image.c @@ -9776,6 +9776,8 @@ lookup_image_type (Lisp_Object type) return NULL; } +#if !defined CANNOT_DUMP && defined HAVE_WINDOW_SYSTEM + /* Reset image_types before dumping. Called from Fdump_emacs. */ @@ -9789,6 +9791,7 @@ reset_image_types (void) image_types = next; } } +#endif void syms_of_image (void) diff --git a/src/lastfile.c b/src/lastfile.c index 9d70b001d11..27602bd6a44 100644 --- a/src/lastfile.c +++ b/src/lastfile.c @@ -43,6 +43,8 @@ along with GNU Emacs. If not, see . */ char my_edata[] = "End of Emacs initialized data"; #endif +#ifndef CANNOT_DUMP + /* Help unexec locate the end of the .bss area used by Emacs (which isn't always a separate section in NT executables). */ char my_endbss[1]; @@ -52,3 +54,5 @@ char my_endbss[1]; of the bss area used by Emacs. */ static char _my_endbss[1]; char * my_endbss_static = _my_endbss; + +#endif diff --git a/test/Makefile.in b/test/Makefile.in index 33e625fc996..f2f27634c24 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -190,6 +190,7 @@ check-doit: ${LOGFILES} mostlyclean: -@for f in ${LOGFILES}; do test ! -f $$f || mv $$f $$f~; done + rm -f *.tmp clean: -rm -f ${LOGFILES} ${LOGSAVEFILES} @@ -206,5 +207,7 @@ maintainer-clean: distclean bootstrap-clean make-test-deps.mk: $(ELFILES) make-test-deps.emacs-lisp $(EMACS) --batch -l $(srcdir)/make-test-deps.emacs-lisp \ --eval "(make-test-deps \"$(srcdir)\")" \ - 2> $@ -# Makefile ends here. + 2> $@.tmp + # Hack to elide any CANNOT_DUMP=yes chatter. + sed '/\.log: /!d' $@.tmp >$@ + rm -f $@.tmp -- 2.39.5