grub2/0224-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch
Peter Jones 15a207211f Roll upstream's patches into one big patch here.
I don't really need to watch 150+ patches from upstream get applied.

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-07-31 10:57:52 -04:00

114 lines
3.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 26 Jun 2018 17:16:06 -0400
Subject: [PATCH] Make it so we can tell configure which cflags utils are built
with
This lets us have kernel.img be built with TARGET_CFLAGS but grub-mkimage and
friends built with HOST_CFLAGS. That in turn lets us build with an ARM compiler
that only has hard-float ABI versions of crt*.o and libgcc*, but still use soft
float for grub.efi.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
configure.ac | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
conf/Makefile.common | 15 ++++++++-------
2 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac
index 9ab683fefac..c0609d87702 100644
--- a/configure.ac
+++ b/configure.ac
@@ -850,11 +850,23 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p
TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
fi
+# Should grub utils get the host CFLAGS, or the target CFLAGS?
+AC_ARG_WITH([utils],
+ AS_HELP_STRING([--with-utils=host|target|build],
+ [choose which flags to build utilities with. (default=target)]),
+ [have_with_utils=y],
+ [have_with_utils=n])
+if test x"$have_with_utils" = xy ; then
+ with_utils="$withval"
+else
+ with_utils=target
+fi
+
# GRUB doesn't use float or doubles at all. Yet some toolchains may decide
# that floats are a good fit to run instead of what's written in the code.
# Given that floating point unit is disabled (if present to begin with)
# when GRUB is running which may result in various hard crashes.
-if test x"$platform" != xemu ; then
+if test x"$platform" != xemu -a x"$with_utils" == xtarget ; then
AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
grub_cv_target_cc_soft_float=no
if test "x$target_cpu" = xarm64; then
@@ -1939,6 +1951,40 @@ HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
+case "$with_utils" in
+ host)
+ UTILS_CFLAGS=$HOST_CFLAGS
+ UTILS_CPPFLAGS=$HOST_CPPFLAGS
+ UTILS_CCASFLAGS=$HOST_CCASFLAGS
+ UTILS_LDFLAGS=$HOST_LDFLAGS
+ BUILD_UTILS_LIBS=true
+ ;;
+ target)
+ UTILS_CFLAGS=$TARGET_CFLAGS
+ UTILS_CPPFLAGS=$TARGET_CPPFLAGS
+ UTILS_CCASFLAGS=$TARGET_CCASFLAGS
+ UTILS_LDFLAGS=$TARGET_LDFLAGS
+ BUILD_UTILS_LIBS=false
+ ;;
+ build)
+ UTILS_CFLAGS=$BUILD_CFLAGS
+ UTILS_CPPFLAGS=$BUILD_CPPFLAGS
+ UTILS_CCASFLAGS=$BUILD_CCASFLAGS
+ UTILS_LDFLAGS=$BUILD_LDFLAGS
+ BUILD_UTILS_LIBS=true
+ ;;
+ *)
+ AC_MSG_ERROR([--with-utils must be either host, target, or build])
+ ;;
+esac
+AC_MSG_NOTICE([Using $with_utils flags for utilities.])
+
+AC_SUBST(UTILS_CFLAGS)
+AC_SUBST(UTILS_CPPFLAGS)
+AC_SUBST(UTILS_CCASFLAGS)
+AC_SUBST(UTILS_LDFLAGS)
+AC_SUBST(BUILD_UTILS_LIBS)
+
GRUB_TARGET_CPU="${target_cpu}"
GRUB_PLATFORM="${platform}"
diff --git a/conf/Makefile.common b/conf/Makefile.common
index 1ecb921db65..657253d5e46 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -50,14 +50,15 @@ LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
-CFLAGS_PROGRAM =
-LDFLAGS_PROGRAM =
-CPPFLAGS_PROGRAM =
-CCASFLAGS_PROGRAM =
+CFLAGS_PROGRAM = $(UTILS_CFLAGS)
+LDFLAGS_PROGRAM = $(UTILS_LDFLAGS)
+CPPFLAGS_PROGRAM = $(UTILS_CPPFLAGS)
+CCASFLAGS_PROGRAM = $(UTILS_CCASFLAGS)
-CFLAGS_LIBRARY =
-CPPFLAGS_LIBRARY =
-CCASFLAGS_LIBRARY =
+CFLAGS_LIBRARY = $(UTILS_CFLAGS)
+LDFLAGS_LIBRARY = $(UTILS_LDFLAGS)
+CPPFLAGS_LIBRARY = $(UTILS_CPPFLAGS)
+CCASFLAGS_LIBRARY = $(UTILS_CCASFLAGS)
# Other variables