blob: 9e3b776abd92473abc9269d72aaba45e25e740ac [file] [log] [blame]
From 03db25282159437ae3fbd0e1dab9043922de1eaf Mon Sep 17 00:00:00 2001
From: Oleksandr Tymoshenko <ovt@google.com>
Date: Wed, 10 Feb 2021 22:59:41 +0000
Subject: [PATCH 6/8] grub-lakitu: fix clang build
- Hack _data value for a backtrace code, it's not used so no functional impact
- Remove gcc-specific -fno-trampolines
- Rewrite hack with a nested function
- Fix -isystem check, clang ships with some headers, but not all, so
test was false positive
- Remove duplicate clang-specific definition of abort() function
---
conf/Makefile.common | 2 +-
configure.ac | 5 +++--
grub-core/kern/arm64/backtrace.c | 2 +-
grub-core/kern/compiler-rt.c | 9 ---------
grub-core/kern/i386/backtrace.c | 2 +-
5 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/conf/Makefile.common b/conf/Makefile.common
index 9fe5863b2..d870c9c62 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -69,7 +69,7 @@ starfielddir = $(pkgdatadir)/themes/starfield
systemdunitdir = ${prefix}/lib/systemd/system
systemd_logind_service_ddir = $(systemdunitdir)/systemd-logind.service.d
-CFLAGS_GNULIB = -Wno-undef -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Werror=trampolines -fno-trampolines
+CFLAGS_GNULIB = -Wno-undef -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Werror=trampolines
CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib
CFLAGS_POSIX = -fno-builtin
diff --git a/configure.ac b/configure.ac
index 7b11fae0c..c9df9f702 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1548,6 +1548,7 @@ AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
CPPFLAGS="$TARGET_CPPFLAGS -nostdlib -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
#include <stddef.h>
+#include <stdio.h>
int va_arg_func (int fixed, va_list args);]], [[]])],
[grub_cv_cc_isystem=yes],
[grub_cv_cc_isystem=no])
@@ -2073,8 +2074,8 @@ if test x"$enable_wextra" != xno ; then
HOST_CFLAGS="$HOST_CFLAGS -Wextra"
fi
-TARGET_CFLAGS="$TARGET_CFLAGS -Werror=trampolines -fno-trampolines"
-HOST_CFLAGS="$HOST_CFLAGS -Werror=trampolines -fno-trampolines"
+TARGET_CFLAGS="$TARGET_CFLAGS -Werror=trampolines"
+HOST_CFLAGS="$HOST_CFLAGS -Werror=trampolines"
TARGET_CPP="$TARGET_CC -E"
TARGET_CCAS=$TARGET_CC
diff --git a/grub-core/kern/arm64/backtrace.c b/grub-core/kern/arm64/backtrace.c
index 019c6fdfe..9d3d8d50d 100644
--- a/grub-core/kern/arm64/backtrace.c
+++ b/grub-core/kern/arm64/backtrace.c
@@ -78,7 +78,7 @@ asm ("\t.global \"_text\"\n"
"\t.quad .text\n"
"\t.global \"_data\"\n"
"_data:\n"
- "\t.quad .data\n"
+ "\t.quad 0\n"
);
extern grub_uint64_t _text;
diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c
index 2057c2e0c..9e191b221 100644
--- a/grub-core/kern/compiler-rt.c
+++ b/grub-core/kern/compiler-rt.c
@@ -195,15 +195,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)
{
diff --git a/grub-core/kern/i386/backtrace.c b/grub-core/kern/i386/backtrace.c
index 2413f9a57..99ca5322a 100644
--- a/grub-core/kern/i386/backtrace.c
+++ b/grub-core/kern/i386/backtrace.c
@@ -78,7 +78,7 @@ asm ("\t.global \"_text\"\n"
"\t.quad .text\n"
"\t.global \"_data\"\n"
"_data:\n"
- "\t.quad .data\n"
+ "\t.quad 0\n"
);
#elif defined(__i386__)
asm ("\t.global \"_text\"\n"
--
2.31.1.295.g9ea45b61b8-goog