]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
gnulib: Provide abort() implementation for gnulib
authorDarren Kenny <darren.kenny@oracle.com>
Fri, 21 Oct 2022 13:32:59 +0000 (13:32 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 27 Oct 2022 14:14:14 +0000 (16:14 +0200)
The recent gnulib updates require an implementation of abort(), but the
current macro provided by changeset:

  cd37d3d3916c gnulib: Drop no-abort.patch

to config.h.in does not work with the clang compiler since it doesn't
provide a __builtin_trap() implementation, so this element of the
changeset needs to be reverted, and replaced.

After some discussion with Vladimir 'phcoder' Serbinenko and Daniel Kiper
it was suggested to bring back in the change from the changeset:

  db7337a3d353 * grub-core/gnulib/regcomp.c (regerror): ...

Which implements abort() as an inline call to grub_abort(), but since
that was made static by changeset:

  a8f15bceeafe * grub-core/kern/misc.c (grub_abort): Make static

it is also necessary to revert the specific part that makes it a static
function too.

Another implementation of abort() was found in grub-core/kern/compiler-rt.c
which needs to also be removed to be consistent.

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
config.h.in
grub-core/kern/compiler-rt.c
grub-core/kern/misc.c
grub-core/lib/posix_wrap/stdlib.h
include/grub/misc.h

index 01dcbbfc82f0c19ce202eadaae328bb7d2904a80..4d1e50eba79cef6086cea000ed51bb4302bfddd6 100644 (file)
@@ -137,16 +137,6 @@ typedef __UINT_FAST32_TYPE__ uint_fast32_t;
     void *                                                             \
     reallocarray (void *ptr, unsigned int nmemb, unsigned int size);
 #    define _GL_INLINE_HEADER_END   _Pragma ("GCC diagnostic pop")
-
-/*
- * We don't have an abort() for gnulib to call in regexp.  Because gnulib is
- * built as a separate object that is then linked with, it doesn't have any
- * of our headers or functions around to use - so we unfortunately can't
- * print anything.  Builds of emu include the system's stdlib, which includes
- * a prototype for abort(), so leave this as a macro that doesn't take
- * arguments.
- */
-#    define abort __builtin_trap
 #  endif /* !_GL_INLINE_HEADER_BEGIN */
 
 /* gnulib doesn't build cleanly with older compilers. */
index 8948fdf772781e5d100666bb568fd66fe7f792a8..eda689a0cf67238ce849773084bec0c9985429d1 100644 (file)
@@ -194,16 +194,6 @@ __ctzsi2 (grub_uint32_t x)
 
 #endif
 
-
-#if defined (__clang__) && !defined(GRUB_EMBED_DECOMPRESSOR)
-/* clang emits references to abort().  */
-void __attribute__ ((noreturn))
-abort (void)
-{
-  grub_fatal ("compiler abort");
-}
-#endif
-
 #if (defined (__MINGW32__) || defined (__CYGWIN__))
 void __register_frame_info (void)
 {
index 6c0221cc336d15e238b597ca809165e9038b72cb..dfae4f9d7897a71dc4434f5988a80bd38d50645f 100644 (file)
@@ -1249,7 +1249,7 @@ grub_printf_fmt_check (const char *fmt, const char *fmt_expected)
 
 
 /* Abort GRUB. This function does not return.  */
-static void __attribute__ ((noreturn))
+void __attribute__ ((noreturn))
 grub_abort (void)
 {
   grub_printf ("\nAborted.");
index 148e9d94bde0a15cfa3c29691f07a5e5f527234d..f5279756abef05da72a36f20a8b977eaba9fa52b 100644 (file)
@@ -58,4 +58,10 @@ abs (int c)
   return (c >= 0) ? c : -c;
 }
 
+static inline void __attribute__ ((noreturn))
+abort (void)
+{
+  grub_abort ();
+}
+
 #endif
index 892ac6a42dda107a027bc9b2b082a104f3212114..ddac3aae8bcc8a7e11bb0d0d13ab1f534585ad7b 100644 (file)
@@ -385,6 +385,7 @@ char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...)
      __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT;
 char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) WARN_UNUSED_RESULT;
 void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn));
+void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn));
 grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
                                          grub_uint64_t d,
                                          grub_uint64_t *r);
@@ -454,10 +455,6 @@ void EXPORT_FUNC(grub_reboot) (void) __attribute__ ((noreturn));
 void grub_reboot (void) __attribute__ ((noreturn));
 #endif
 
-#if defined (__clang__) && !defined (GRUB_UTIL)
-void __attribute__ ((noreturn)) EXPORT_FUNC (abort) (void);
-#endif
-
 #ifdef GRUB_MACHINE_PCBIOS
 /* Halt the system, using APM if possible. If NO_APM is true, don't
  * use APM even if it is available.  */