From 8d563110da7380c7232ffdcf409cff5c8c1541da Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 27 Jul 2018 12:52:55 -0400 Subject: [PATCH] --with-utils=host Signed-off-by: Peter Jones --- ...n-tell-configure-which-cflags-utils-.patch | 121 ++++++++++++++++++ ...xes-to-make-armv7hl-build-as-arm-efi.patch | 28 ---- grub.macros | 46 +++++-- grub.patches | 2 +- grub2.spec | 6 +- 5 files changed, 159 insertions(+), 44 deletions(-) create mode 100644 0354-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch delete mode 100644 0354-Minor-fixes-to-make-armv7hl-build-as-arm-efi.patch diff --git a/0354-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch b/0354-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch new file mode 100644 index 00000000..7210db3d --- /dev/null +++ b/0354-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch @@ -0,0 +1,121 @@ +0rom 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 25 Jul 2018 13:46:13 -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 +--- + configure.ac | 48 ++++++++++++++++++++++++++++++++++++++++++-- + conf/Makefile.common | 15 +++++++------- + 2 files changed, 54 insertions(+), 9 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 5f47a9265f3..caa00b90d90 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -307,7 +307,7 @@ fi + + AC_SUBST(bootdirname) + AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname", +- [Default boot directory name]") ++ [Default boot directory name]) + + AC_ARG_WITH([grubdir], + AS_HELP_STRING([--with-grubdir=DIR], +@@ -850,11 +850,22 @@ 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? ++with_utils=target ++AC_ARG_WITH([utils], ++ AS_HELP_STRING([--with-utils=host|target|build], ++ [choose which flags to build utilities with. [[target]]]), ++ [have_with_utils=y], ++ [have_with_utils=n]) ++if test x"$have_with_utils" = xy ; then ++ with_utils="$withval" ++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 +1950,39 @@ 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_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 c75848f5c06..c4d72cd96e1 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 + diff --git a/0354-Minor-fixes-to-make-armv7hl-build-as-arm-efi.patch b/0354-Minor-fixes-to-make-armv7hl-build-as-arm-efi.patch deleted file mode 100644 index 7cc754b0..00000000 --- a/0354-Minor-fixes-to-make-armv7hl-build-as-arm-efi.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 26 Jun 2018 17:16:06 -0400 -Subject: [PATCH] Minor fixes to make armv7hl build as arm-efi - -- /remove/ the code to use use softfloat unconditionally on arm - (I can't get our arm bins to build with it for whatever reason...) -- Fix one type error -- build the secure boot loader code on arm - -Signed-off-by: Peter Jones ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 5f47a9265f3..b3af931e958 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -854,7 +854,7 @@ fi - # 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$target_cpu" != xarm ; 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 diff --git a/grub.macros b/grub.macros index f0b2768c..375b61e9 100644 --- a/grub.macros +++ b/grub.macros @@ -26,19 +26,27 @@ -e 's/-mregparm=3/-mregparm=4/g' \\\ -e 's/-fexceptions//g' \\\ -e 's/-fasynchronous-unwind-tables//g' \\\ - -e 's/-mfloat-abi=hard/-mfloat-abi=soft/g' \\\ -e 's/^/ -fno-strict-aliasing /' \\\ %{nil} -%global efi_cflags \\\ - %{expand:%%(echo %{optflags} | %{cflags_sed})} +%global host_cflags %{expand:%%(echo %{optflags} | %{cflags_sed})} +%global target_cflags %{expand:%%(echo %{optflags} | %{cflags_sed})} -%global legacy_cflags \\\ - %{expand:%%(echo %{optflags} | \\\ +%global legacy_target_cflags \\\ + %{expand:%%(echo %{target_cflags} | \\\ %{cflags_sed} \\\ -e 's/-m64//g' \\\ -e 's/-mcpu=power[[:alnum:]]\\+/-mcpu=power6/g' \\\ )} +%global legacy_host_cflags \\\ + %{expand:%%(echo %{host_cflags} | \\\ + %{cflags_sed} \\\ + -e 's/-m64//g' \\\ + -e 's/-mcpu=power[[:alnum:]]\\+/-mcpu=power6/g' \\\ + )} + +%global efi_host_cflags %{expand:%%(echo %{host_cflags})} +%global efi_target_cflags %{expand:%%(echo %{target_cflags})} %global with_efi_arch 0 %global with_alt_efi_arch 0 @@ -119,8 +127,10 @@ %global alt_grub_target_name i386-efi %global alt_platform efi %global alt_package_arch efi-ia32 -%global alt_efi_cflags \\\ - %{expand:%%(echo %{optflags} | \\\ + +%global alt_efi_host_cflags %{expand:%%(echo %{efi_host_cflags})} +%global alt_efi_target_cflags \\\ + %{expand:%%(echo %{target_cflags} | \\\ %{cflags_sed} \\\ -e 's/-m64//g' \\\ )} @@ -138,6 +148,13 @@ %global target_cpu_name arm %global grub_target_name arm-efi %global package_arch efi-arm +%global efi_target_cflags \\\ + %{expand:%%(echo %{optflags} | \\\ + %{cflags_sed} \\\ + -e 's/-march=armv7-a[[:alnum:]+-]*/&+nofp/g' \\\ + -e 's/-mfpu=[[:alnum:]-]\\+//g' \\\ + -e 's/-mfloat-abi=[[:alpha:]]\\+/-mfloat-abi=soft/g' \\\ + )} %endif %global _target_platform %{target_cpu_name}-%{_vendor}-%{_target_os}%{?_gnu} @@ -297,10 +314,13 @@ git config --unset user.name \ %define do_efi_configure() \ %configure \\\ %{cc_equals} \\\ - CFLAGS="%{2} -I$(pwd)" \\\ - CPPFLAGS="${CPPFLAGS} -I$(pwd)" \\\ + HOST_CFLAGS="%{3} -I$(pwd)" \\\ + HOST_CPPFLAGS="${CPPFLAGS} -I$(pwd)" \\\ + TARGET_CFLAGS="%{2} -I$(pwd)" \\\ + TARGET_CPPFLAGS="${CPPFLAGS} -I$(pwd)" \\\ TARGET_LDFLAGS=-static \\\ --with-platform=efi \\\ + --with-utils=host \\\ --target=%{1} \\\ --with-grubdir=%{name} \\\ --program-transform-name=s,grub,%{name}, \\\ @@ -360,7 +380,7 @@ GRUB_MODULES+=%{efi_modules} \ %define do_primary_efi_build() \ cd grub-%{1}-%{tarversion} \ -%{expand:%%do_efi_configure %%{4} %%{5}} \ +%{expand:%%do_efi_configure %%{4} %%{5} %%{6}} \ %do_efi_build_all \ %{expand:%%do_efi_build_images %{grub_target_name} %{2} %{3} ./ } \ cd .. \ @@ -368,7 +388,7 @@ cd .. \ %define do_alt_efi_build() \ cd grub-%{1}-%{tarversion} \ -%{expand:%%do_efi_configure %%{4} %%{5}} \ +%{expand:%%do_efi_configure %%{4} %%{5} %%{6}} \ %do_efi_build_modules \ %{expand:%%do_efi_link_utils %{grubefiarch}} \ %{expand:%%do_efi_build_images %{alt_grub_target_name} %{2} %{3} ../grub-%{grubefiarch}-%{tarversion}/ } \ @@ -379,9 +399,11 @@ cd .. \ cd grub-%{1}-%{tarversion} \ %configure \\\ %{cc_equals} \\\ - CFLAGS="%{legacy_cflags} -I$(pwd)" \\\ + HOST_CFLAGS="%{legacy_host_cflags} -I$(pwd)" \\\ + TARGET_CFLAGS="%{legacy_target_cflags} -I$(pwd)" \\\ TARGET_LDFLAGS=-static \\\ --with-platform=%{platform} \\\ + --with-utils=host \\\ --target=%{_target_platform} \\\ --with-grubdir=%{name} \\\ --program-transform-name=s,grub,%{name}, \\\ diff --git a/grub.patches b/grub.patches index 320fe934..d18c553c 100644 --- a/grub.patches +++ b/grub.patches @@ -351,7 +351,7 @@ Patch0350: 0350-Make-grub-set-password-be-named-like-all-the-other-g.patch Patch0351: 0351-docs-Add-grub-boot-indeterminate.service-example.patch Patch0352: 0352-00_menu_auto_hide-Use-a-timeout-of-60s-for-menu_show.patch Patch0353: 0353-00_menu_auto_hide-Reduce-number-of-save_env-calls.patch -Patch0354: 0354-Minor-fixes-to-make-armv7hl-build-as-arm-efi.patch +Patch0354: 0354-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch Patch0355: 0355-30_uefi-firmware-fix-use-with-sys-firmware-efi-efiva.patch Patch0356: 0356-gentpl-add-disable-support.patch Patch0357: 0357-gentpl-add-pc-firmware-type.patch diff --git a/grub2.spec b/grub2.spec index 013d3e37..9625e7e0 100644 --- a/grub2.spec +++ b/grub2.spec @@ -48,7 +48,7 @@ BuildRequires: pesign >= 0.99-8 BuildRequires: ccache %endif -ExcludeArch: s390 s390x %{arm} +ExcludeArch: s390 s390x Obsoletes: %{name} <= %{evr} %if 0%{with_legacy_arch} @@ -152,10 +152,10 @@ cp %{SOURCE4} grub-%{grublegacyarch}-%{tarversion}/unifont.pcf.gz %build %if 0%{with_efi_arch} -%{expand:%do_primary_efi_build %%{grubefiarch} %%{grubefiname} %%{grubeficdname} %%{_target_platform} %%{efi_cflags}} +%{expand:%do_primary_efi_build %%{grubefiarch} %%{grubefiname} %%{grubeficdname} %%{_target_platform} %%{efi_target_cflags} %%{efi_host_cflags}} %endif %if 0%{with_alt_efi_arch} -%{expand:%do_alt_efi_build %%{grubaltefiarch} %%{grubaltefiname} %%{grubalteficdname} %%{_alt_target_platform} %%{alt_efi_cflags}} +%{expand:%do_alt_efi_build %%{grubaltefiarch} %%{grubaltefiname} %%{grubalteficdname} %%{_alt_target_platform} %%{alt_efi_target_cflags} %%{alt_efi_host_cflags}} %endif %if 0%{with_legacy_arch} %{expand:%do_legacy_build %%{grublegacyarch}}