public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3220] Use __builtin_trap() for abort() if inhibit_libc
@ 2021-08-30  8:38 Sebastian Huber
  0 siblings, 0 replies; only message in thread
From: Sebastian Huber @ 2021-08-30  8:38 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:caf81d3b57501b1f58dcd9b1ef9d7b4bc76f4ab1

commit r12-3220-gcaf81d3b57501b1f58dcd9b1ef9d7b4bc76f4ab1
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date:   Tue Aug 17 09:53:43 2021 +0200

    Use __builtin_trap() for abort() if inhibit_libc
    
    abort() is used in gcc_assert() and gcc_unreachable() which is used by target
    libraries such as libgcov.a.  This patch changes the abort() definition under
    certain conditions.  If inhibit_libc is defined and abort is not already
    defined, then abort() is defined to __builtin_trap().
    
    The inhibit_libc define is usually defined if GCC is built for targets running
    in embedded systems which may optionally use a C standard library.  If
    inhibit_libc is defined, then there may be still a full featured abort()
    available.  abort() is a heavy weight function which depends on signals and
    file streams.  For statically linked applications, this means that a dependency
    on gcc_assert() pulls in the support for signals and file streams.  This could
    prevent using gcov to test low end targets for example.  Using __builtin_trap()
    avoids these dependencies if the target implements a "trap" instruction.  The
    application or operating system could use a trap handler to react to failed GCC
    runtime checks which caused a trap.
    
    gcc/
    
            * tsystem.h (abort): Define abort() if inhibit_libc is defined and it
            is not already defined.

Diff:
---
 gcc/tsystem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tsystem.h b/gcc/tsystem.h
index e1e6a96a4f4..5c72c69ff3e 100644
--- a/gcc/tsystem.h
+++ b/gcc/tsystem.h
@@ -59,7 +59,7 @@ extern int atexit (void (*)(void));
 #endif
 
 #ifndef abort
-extern void abort (void) __attribute__ ((__noreturn__));
+#define abort() __builtin_trap ()
 #endif
 
 #ifndef strlen


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-30  8:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30  8:38 [gcc r12-3220] Use __builtin_trap() for abort() if inhibit_libc Sebastian Huber

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).