Blame SOURCES/0219-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Peter Jones <pjones@redhat.com>
8631a2
Date: Tue, 26 Jun 2018 17:16:06 -0400
8631a2
Subject: [PATCH] Make it so we can tell configure which cflags utils are built
8631a2
 with
8631a2
8631a2
This lets us have kernel.img be built with TARGET_CFLAGS but grub-mkimage and
8631a2
friends built with HOST_CFLAGS.  That in turn lets us build with an ARM compiler
8631a2
that only has hard-float ABI versions of crt*.o and libgcc*, but still use soft
8631a2
float for grub.efi.
8631a2
8631a2
Signed-off-by: Peter Jones <pjones@redhat.com>
8631a2
---
8631a2
 configure.ac         | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
8631a2
 conf/Makefile.common | 23 ++++++++++++-----------
8631a2
 gentpl.py            |  8 ++++----
8631a2
 3 files changed, 64 insertions(+), 16 deletions(-)
8631a2
8631a2
diff --git a/configure.ac b/configure.ac
8631a2
index 9ab683fefac..819212095ff 100644
8631a2
--- a/configure.ac
8631a2
+++ b/configure.ac
8631a2
@@ -850,11 +850,23 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p
8631a2
   TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
8631a2
 fi
8631a2
 
8631a2
+# Should grub utils get the host CFLAGS, or the target CFLAGS?
8631a2
+AC_ARG_WITH([utils],
8631a2
+            AS_HELP_STRING([--with-utils=host|target|build],
8631a2
+                           [choose which flags to build utilities with. (default=target)]),
8631a2
+	    [have_with_utils=y],
8631a2
+	    [have_with_utils=n])
8631a2
+if test x"$have_with_utils" = xy ; then
8631a2
+  with_utils="$withval"
8631a2
+else
8631a2
+  with_utils=target
8631a2
+fi
8631a2
+
8631a2
 # GRUB doesn't use float or doubles at all. Yet some toolchains may decide
8631a2
 # that floats are a good fit to run instead of what's written in the code.
8631a2
 # Given that floating point unit is disabled (if present to begin with)
8631a2
 # when GRUB is running which may result in various hard crashes.
8631a2
-if test x"$platform" != xemu ; then
8631a2
+if test x"$platform" != xemu -a x"$with_utils" == xtarget ; then
8631a2
   AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
8631a2
     grub_cv_target_cc_soft_float=no
8631a2
     if test "x$target_cpu" = xarm64; then
8631a2
@@ -1939,6 +1951,41 @@ HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
8631a2
 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
8631a2
 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
8631a2
 
8631a2
+case "$with_utils" in
8631a2
+  host)
8631a2
+    UTILS_CFLAGS=$HOST_CFLAGS
8631a2
+    UTILS_CPPFLAGS=$HOST_CPPFLAGS
8631a2
+    UTILS_CCASFLAGS=$HOST_CCASFLAGS
8631a2
+    UTILS_LDFLAGS=$HOST_LDFLAGS
8631a2
+    ;;
8631a2
+  target)
8631a2
+    UTILS_CFLAGS=$TARGET_CFLAGS
8631a2
+    UTILS_CPPFLAGS=$TARGET_CPPFLAGS
8631a2
+    UTILS_CCASFLAGS=$TARGET_CCASFLAGS
8631a2
+    UTILS_LDFLAGS=$TARGET_LDFLAGS
8631a2
+    ;;
8631a2
+  build)
8631a2
+    UTILS_CFLAGS=$BUILD_CFLAGS
8631a2
+    UTILS_CPPFLAGS=$BUILD_CPPFLAGS
8631a2
+    UTILS_CCASFLAGS=$BUILD_CCASFLAGS
8631a2
+    UTILS_LDFLAGS=$BUILD_LDFLAGS
8631a2
+    ;;
8631a2
+  *)
8631a2
+    AC_MSG_ERROR([--with-utils must be either host, target, or build])
8631a2
+    ;;
8631a2
+esac
8631a2
+AC_MSG_NOTICE([Using $with_utils flags for utilities.])
8631a2
+
8631a2
+unset CFLAGS
8631a2
+unset CPPFLAGS
8631a2
+unset CCASFLAGS
8631a2
+unset LDFLAGS
8631a2
+
8631a2
+AC_SUBST(UTILS_CFLAGS)
8631a2
+AC_SUBST(UTILS_CPPFLAGS)
8631a2
+AC_SUBST(UTILS_CCASFLAGS)
8631a2
+AC_SUBST(UTILS_LDFLAGS)
8631a2
+
8631a2
 GRUB_TARGET_CPU="${target_cpu}"
8631a2
 GRUB_PLATFORM="${platform}"
8631a2
 
8631a2
diff --git a/conf/Makefile.common b/conf/Makefile.common
8631a2
index 1ecb921db65..b93879804c0 100644
8631a2
--- a/conf/Makefile.common
8631a2
+++ b/conf/Makefile.common
8631a2
@@ -40,24 +40,25 @@ CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
8631a2
 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
8631a2
 STRIPFLAGS_KERNEL = -R .eh_frame -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx -R .note.gnu.property -R .gnu.build.attributes
8631a2
 
8631a2
-CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
8631a2
-LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
8631a2
-CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
8631a2
-CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
8631a2
+CFLAGS_MODULE = $(TARGET_CFLAGS) $(CFLAGS_PLATFORM) -ffreestanding
8631a2
+LDFLAGS_MODULE = $(TARGET_LDFLAGS) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
8631a2
+CPPFLAGS_MODULE = $(TARGET_CPPFLAGS) $(CPPFLAGS_DEFAULT) $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
8631a2
+CCASFLAGS_MODULE = $(TARGET_CCASFLAGS) $(CCASFLAGS_DEFAULT) $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
8631a2
 
8631a2
 CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin
8631a2
 LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
8631a2
 CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
8631a2
 CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
8631a2
 
8631a2
-CFLAGS_PROGRAM =
8631a2
-LDFLAGS_PROGRAM =
8631a2
-CPPFLAGS_PROGRAM =
8631a2
-CCASFLAGS_PROGRAM =
8631a2
+CFLAGS_PROGRAM = $(UTILS_CFLAGS)
8631a2
+LDFLAGS_PROGRAM = $(UTILS_LDFLAGS)
8631a2
+CPPFLAGS_PROGRAM = $(UTILS_CPPFLAGS)
8631a2
+CCASFLAGS_PROGRAM = $(UTILS_CCASFLAGS)
8631a2
 
8631a2
-CFLAGS_LIBRARY =
8631a2
-CPPFLAGS_LIBRARY =
8631a2
-CCASFLAGS_LIBRARY =
8631a2
+CFLAGS_LIBRARY = $(UTILS_CFLAGS)
8631a2
+LDFLAGS_LIBRARY = $(UTILS_LDFLAGS)
8631a2
+CPPFLAGS_LIBRARY = $(UTILS_CPPFLAGS)
8631a2
+CCASFLAGS_LIBRARY = $(UTILS_CCASFLAGS)
8631a2
 
8631a2
 # Other variables
8631a2
 
8631a2
diff --git a/gentpl.py b/gentpl.py
8631a2
index 6409736e81c..1e4635f4426 100644
8631a2
--- a/gentpl.py
8631a2
+++ b/gentpl.py
8631a2
@@ -694,10 +694,10 @@ def module(defn, platform):
8631a2
     var_set(cname(defn) + "_SOURCES", platform_sources(defn, platform) + " ## platform sources")
8631a2
     var_set("nodist_" + cname(defn) + "_SOURCES", platform_nodist_sources(defn, platform) + " ## platform nodist sources")
8631a2
     var_set(cname(defn) + "_LDADD", platform_ldadd(defn, platform))
8631a2
-    var_set(cname(defn) + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_MODULE) " + platform_cflags(defn, platform))
8631a2
-    var_set(cname(defn) + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_MODULE) " + platform_ldflags(defn, platform))
8631a2
-    var_set(cname(defn) + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_MODULE) " + platform_cppflags(defn, platform))
8631a2
-    var_set(cname(defn) + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_MODULE) " + platform_ccasflags(defn, platform))
8631a2
+    var_set(cname(defn) + "_CFLAGS", "$(CFLAGS_MODULE) " + platform_cflags(defn, platform))
8631a2
+    var_set(cname(defn) + "_LDFLAGS", "$(LDFLAGS_MODULE) " + platform_ldflags(defn, platform))
8631a2
+    var_set(cname(defn) + "_CPPFLAGS", "$(CPPFLAGS_MODULE) " + platform_cppflags(defn, platform))
8631a2
+    var_set(cname(defn) + "_CCASFLAGS", "$(CCASFLAGS_MODULE) " + platform_ccasflags(defn, platform))
8631a2
     var_set(cname(defn) + "_DEPENDENCIES", "$(TARGET_OBJ2ELF) " + platform_dependencies(defn, platform))
8631a2
 
8631a2
     gvar_add("dist_noinst_DATA", extra_dist(defn))