nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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