From 9baeed3514fe60189f3bf935c380da92659b7f59 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 29 Aug 2017 14:20:47 -0700 Subject: Improve stack-top heuristic This is needed for gcc -Os -flto on x86-64; otherwise, GC misses part of the stack when scanning for heap roots, causing Emacs to crash later (Bug#28213). The problem is that Emacs's hack for getting an address near the stack top does not work when link-time optimization moves stack variables around. * configure.ac (HAVE___BUILTIN_FRAME_ADDRESS): New macro. * lib-src/make-docfile.c (DEFUN_noinline): New constant. (write_globals, scan_c_stream): Support noinline. * src/alloc.c (NEAR_STACK_TOP): New macro. (SET_STACK_TOP_ADDRESS): Use it. (flush_stack_call_func, Fgarbage_collect): Now noinline. --- lib-src/make-docfile.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib-src') diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index ecd6447ab78..c48f202a511 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -592,7 +592,7 @@ struct global }; /* Bit values for FLAGS field from the above. Applied for DEFUNs only. */ -enum { DEFUN_noreturn = 1, DEFUN_const = 2 }; +enum { DEFUN_noreturn = 1, DEFUN_const = 2, DEFUN_noinline = 4 }; /* All the variable names we saw while scanning C sources in `-g' mode. */ @@ -742,6 +742,8 @@ write_globals (void) { if (globals[i].flags & DEFUN_noreturn) fputs ("_Noreturn ", stdout); + if (globals[i].flags & DEFUN_noinline) + fputs ("NO_INLINE ", stdout); printf ("EXFUN (%s, ", globals[i].name); if (globals[i].v.value == -1) @@ -1062,7 +1064,8 @@ scan_c_stream (FILE *infile) attributes: attribute1 attribute2 ...) (Lisp_Object arg...) - Now only 'noreturn' and 'const' attributes are used. */ + Now only ’const’, ’noinline’ and 'noreturn' attributes + are used. */ /* Advance to the end of docstring. */ c = getc (infile); @@ -1108,6 +1111,8 @@ scan_c_stream (FILE *infile) g->flags |= DEFUN_noreturn; if (strstr (input_buffer, "const")) g->flags |= DEFUN_const; + if (strstr (input_buffer, "noinline")) + g->flags |= DEFUN_noinline; } continue; } -- cgit v1.2.3