From f82e4ea3dc389eb502911e29ad8a98d20b7a40a529879001648facb8c698d404 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Thu, 6 Feb 2014 08:17:06 +0000 Subject: [PATCH] Accepting request 220920 from Base:System - Enable grub2 for PowerPC LE (ppc64le) - Add ppc64le to exclusive arches - Don't require gcc-32bit (PowerLE don't have 32bit toolchain) - added patches: * grub2-powerpc-libgcc.patch Provide 32bit libgcc functions for PowerLE * grub2-ppc64le-core-bigendian.patch Build grub kernel and images as BE on ppc64le (BL is BE there) * grub2-ppc64le-platform.patch Enable ppc64le platform (forwarded request 220504 from k0da) OBS-URL: https://build.opensuse.org/request/show/220920 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=83 --- grub2-powerpc-libgcc.patch | 301 +++++++++++++++++++++++++++++ grub2-ppc64le-core-bigendian.patch | 31 +++ grub2-ppc64le-platform.patch | 13 ++ grub2.changes | 17 ++ grub2.spec | 18 +- 5 files changed, 376 insertions(+), 4 deletions(-) create mode 100644 grub2-powerpc-libgcc.patch create mode 100644 grub2-ppc64le-core-bigendian.patch create mode 100644 grub2-ppc64le-platform.patch diff --git a/grub2-powerpc-libgcc.patch b/grub2-powerpc-libgcc.patch new file mode 100644 index 0000000..5dc409f --- /dev/null +++ b/grub2-powerpc-libgcc.patch @@ -0,0 +1,301 @@ +Index: grub-2.02~beta2/configure.ac +=================================================================== +--- grub-2.02~beta2.orig/configure.ac ++++ grub-2.02~beta2/configure.ac +@@ -1014,7 +1014,7 @@ else + CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" + fi + CPPFLAGS="$TARGET_CPPFLAGS" +-if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then ++if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test x$target_cpu = xpowerpc || test "x$grub_cv_cc_target_clang" = xyes ; then + TARGET_LIBGCC= + else + TARGET_LIBGCC=-lgcc +Index: grub-2.02~beta2/grub-core/kern/powerpc/crtsavres.S +=================================================================== +--- /dev/null ++++ grub-2.02~beta2/grub-core/kern/powerpc/crtsavres.S +@@ -0,0 +1,125 @@ ++/* ++ * Special support for eabi and SVR4 ++ * ++ * Copyright (C) 1995, 1996, 1998, 2000, 2001 Free Software Foundation, Inc. ++ * Written By Michael Meissner ++ * 64-bit support written by David Edelsohn ++ * ++ * This file is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License as published by the ++ * Free Software Foundation; either version 2, or (at your option) any ++ * later version. ++ * ++ * In addition to the permissions in the GNU General Public License, the ++ * Free Software Foundation gives you unlimited permission to link the ++ * compiled version of this file with other programs, and to distribute ++ * those programs without any restriction coming from the use of this ++ * file. (The General Public License restrictions do apply in other ++ * respects; for example, they cover modification of the file, and ++ * distribution when not linked into another program.) ++ * ++ * This file is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; see the file COPYING. If not, write to ++ * the Free Software Foundation, 51 Franklin Street, Fifth Floor, ++ * Boston, MA 02110-1301, USA. ++ * ++ * As a special exception, if you link this library with files ++ * compiled with GCC to produce an executable, this does not cause ++ * the resulting executable to be covered by the GNU General Public License. ++ * This exception does not however invalidate any other reasons why ++ * the executable file might be covered by the GNU General Public License. ++ */ ++ ++/* Do any initializations needed for the eabi environment */ ++ ++ .file "crtsavres.S" ++ .section ".text" ++ ++/* On PowerPC64 Linux, these functions are provided by the linker. */ ++#ifndef __powerpc64__ ++ ++#define FUNC_START(name) \ ++ .type name,@function; \ ++ .globl name; \ ++name: ++ ++/* Routines for saving integer registers, called by the compiler. */ ++/* Called with r11 pointing to the stack header word of the caller of the */ ++/* function, just beyond the end of the integer save area. */ ++ ++FUNC_START(_savegpr_14) stw 14,-72(11) /* save gp registers */ ++FUNC_START(_savegpr_15) stw 15,-68(11) ++FUNC_START(_savegpr_16) stw 16,-64(11) ++FUNC_START(_savegpr_17) stw 17,-60(11) ++FUNC_START(_savegpr_18) stw 18,-56(11) ++FUNC_START(_savegpr_19) stw 19,-52(11) ++FUNC_START(_savegpr_20) stw 20,-48(11) ++FUNC_START(_savegpr_21) stw 21,-44(11) ++FUNC_START(_savegpr_22) stw 22,-40(11) ++FUNC_START(_savegpr_23) stw 23,-36(11) ++FUNC_START(_savegpr_24) stw 24,-32(11) ++FUNC_START(_savegpr_25) stw 25,-28(11) ++FUNC_START(_savegpr_26) stw 26,-24(11) ++FUNC_START(_savegpr_27) stw 27,-20(11) ++FUNC_START(_savegpr_28) stw 28,-16(11) ++FUNC_START(_savegpr_29) stw 29,-12(11) ++FUNC_START(_savegpr_30) stw 30,-8(11) ++FUNC_START(_savegpr_31) stw 31,-4(11) ++ blr ++ ++/* Routines for restoring integer registers, called by the compiler. */ ++/* Called with r11 pointing to the stack header word of the caller of the */ ++/* function, just beyond the end of the integer restore area. */ ++ ++FUNC_START(_restgpr_14) lwz 14,-72(11) /* restore gp registers */ ++FUNC_START(_restgpr_15) lwz 15,-68(11) ++FUNC_START(_restgpr_16) lwz 16,-64(11) ++FUNC_START(_restgpr_17) lwz 17,-60(11) ++FUNC_START(_restgpr_18) lwz 18,-56(11) ++FUNC_START(_restgpr_19) lwz 19,-52(11) ++FUNC_START(_restgpr_20) lwz 20,-48(11) ++FUNC_START(_restgpr_21) lwz 21,-44(11) ++FUNC_START(_restgpr_22) lwz 22,-40(11) ++FUNC_START(_restgpr_23) lwz 23,-36(11) ++FUNC_START(_restgpr_24) lwz 24,-32(11) ++FUNC_START(_restgpr_25) lwz 25,-28(11) ++FUNC_START(_restgpr_26) lwz 26,-24(11) ++FUNC_START(_restgpr_27) lwz 27,-20(11) ++FUNC_START(_restgpr_28) lwz 28,-16(11) ++FUNC_START(_restgpr_29) lwz 29,-12(11) ++FUNC_START(_restgpr_30) lwz 30,-8(11) ++FUNC_START(_restgpr_31) lwz 31,-4(11) ++ blr ++ ++/* Routines for restoring integer registers, called by the compiler. */ ++/* Called with r11 pointing to the stack header word of the caller of the */ ++/* function, just beyond the end of the integer restore area. */ ++ ++FUNC_START(_restgpr_14_x) lwz 14,-72(11) /* restore gp registers */ ++FUNC_START(_restgpr_15_x) lwz 15,-68(11) ++FUNC_START(_restgpr_16_x) lwz 16,-64(11) ++FUNC_START(_restgpr_17_x) lwz 17,-60(11) ++FUNC_START(_restgpr_18_x) lwz 18,-56(11) ++FUNC_START(_restgpr_19_x) lwz 19,-52(11) ++FUNC_START(_restgpr_20_x) lwz 20,-48(11) ++FUNC_START(_restgpr_21_x) lwz 21,-44(11) ++FUNC_START(_restgpr_22_x) lwz 22,-40(11) ++FUNC_START(_restgpr_23_x) lwz 23,-36(11) ++FUNC_START(_restgpr_24_x) lwz 24,-32(11) ++FUNC_START(_restgpr_25_x) lwz 25,-28(11) ++FUNC_START(_restgpr_26_x) lwz 26,-24(11) ++FUNC_START(_restgpr_27_x) lwz 27,-20(11) ++FUNC_START(_restgpr_28_x) lwz 28,-16(11) ++FUNC_START(_restgpr_29_x) lwz 29,-12(11) ++FUNC_START(_restgpr_30_x) lwz 30,-8(11) ++FUNC_START(_restgpr_31_x) lwz 0,4(11) ++ lwz 31,-4(11) ++ mtlr 0 ++ mr 1,11 ++ blr ++#endif +Index: grub-2.02~beta2/grub-core/Makefile.core.def +=================================================================== +--- grub-2.02~beta2.orig/grub-core/Makefile.core.def ++++ grub-2.02~beta2/grub-core/Makefile.core.def +@@ -250,6 +250,8 @@ kernel = { + extra_dist = video/sis315_init.c; + mips_loongson = commands/keylayouts.c; + ++ powerpc_ieee1275 = kern/powerpc/crtsavres.S; ++ powerpc_ieee1275 = disk/ieee1275/libgcc.c; + powerpc_ieee1275 = kern/powerpc/cache.S; + powerpc_ieee1275 = kern/powerpc/dl.c; + +Index: grub-2.02~beta2/grub-core/disk/ieee1275/libgcc.c +=================================================================== +--- /dev/null ++++ grub-2.02~beta2/grub-core/disk/ieee1275/libgcc.c +@@ -0,0 +1,106 @@ ++ ++typedef int int32 __attribute__ ((mode (SI))); ++typedef unsigned int uint32 __attribute__ ((mode (SI))); ++typedef int int64 __attribute__ ((mode (DI))); ++typedef unsigned uint64 __attribute__ ((mode (DI))); ++ ++typedef union { ++ int64 ll; ++ struct { ++ int32 low, high; ++ } u; ++} DWunion; ++extern int64 __ashldi3 (int64, int32); ++int64 __ashldi3(int64 x, int32 count) ++{ ++ if (!count) ++ return x; ++ ++ const DWunion uu = {.ll = x}; ++ const int32 bm = 4 * sizeof (int64) - count; /* 8 * size (int64) / 2 */ ++ DWunion w; ++ ++ if (bm <= 0) ++ { ++ w.u.low = 0; ++ w.u.high = (uint32) uu.u.low << -bm; ++ } ++ else ++ { ++ const uint32 carries = (uint32) uu.u.low >> bm; ++ ++ w.u.low = (uint32) uu.u.low << count; ++ w.u.high = ((uint32) uu.u.high << count) | carries; ++ } ++ ++ return w.ll; ++} ++extern int64 __lshrdi3 (int64 , int32); ++int64 __lshrdi3(int64 x, int32 count) ++{ ++ if (!count) ++ return x; ++ ++ const DWunion uu = {.ll = x}; ++ const int32 bm = 4 * sizeof (int64) - count; ++ DWunion w; ++ ++ if (bm <= 0) ++ { ++ w.u.high = 0; ++ w.u.low = (uint32) uu.u.high >> -bm; ++ } ++ else ++ { ++ const uint32 carries = (uint32) uu.u.high << bm; ++ ++ w.u.high = (uint32) uu.u.high >> count; ++ w.u.low = ((uint32) uu.u.low >> count) | carries; ++ } ++ ++ return w.ll; ++} ++ ++extern int64 __ashrdi3 (int64, int32); ++int64 __ashrdi3(int64 x, int32 count) ++{ ++ if (!count) ++ return x; ++ ++ const DWunion uu = {.ll = x}; ++ const int32 bm = 4 * sizeof (int64) - count; /* 8 * size (int64) / 2 */ ++ DWunion w; ++ ++ if (bm <= 0) ++ { ++ w.u.high = ++ uu.u.high >> 31; ++ w.u.low = uu.u.high >> -bm; ++ } ++ else ++ { ++ const uint32 carries = (uint32) uu.u.high << bm; ++ ++ w.u.high = (uint32) uu.u.high >> count; ++ w.u.low = ((uint32) uu.u.low >> count) | carries; ++ } ++ ++ return w.ll; ++} ++extern int64 __ucmpdi2 (int64, int64); ++int64 __ucmpdi2(int64 a, int64 b) ++{ ++ const DWunion au = {.ll = a}; ++ const DWunion bu = {.ll = b}; ++ ++ if ((unsigned int) au.u.high < (unsigned int) bu.u.high) ++ return 0; ++ else if ((unsigned int) au.u.high > (unsigned int) bu.u.high) ++ return 2; ++ if ((unsigned int) au.u.low < (unsigned int) bu.u.low) ++ return 0; ++ else if ((unsigned int) au.u.low > (unsigned int) bu.u.low) ++ return 2; ++ return 1; ++} ++ +Index: grub-2.02~beta2/include/grub/libgcc.h +=================================================================== +--- grub-2.02~beta2.orig/include/grub/libgcc.h ++++ grub-2.02~beta2/include/grub/libgcc.h +@@ -24,16 +24,16 @@ + + /* On x86 these functions aren't really needed. Save some space. */ + #if !defined (__i386__) && !defined (__x86_64__) +-# ifdef HAVE___ASHLDI3 ++# if defined (HAVE___ASHLDI3) || defined (__powerpc__) + void EXPORT_FUNC (__ashldi3) (void); + # endif +-# ifdef HAVE___ASHRDI3 ++# if defined (HAVE___ASHRDI3) || defined (__powerpc__) + void EXPORT_FUNC (__ashrdi3) (void); + # endif +-# ifdef HAVE___LSHRDI3 ++# if defined (HAVE___LSHRDI3) || defined (__powerpc__) + void EXPORT_FUNC (__lshrdi3) (void); + # endif +-# ifdef HAVE___UCMPDI2 ++# if defined (HAVE___UCMPDI2) || defined (__powerpc__) + void EXPORT_FUNC (__ucmpdi2) (void); + # endif + # ifdef HAVE___BSWAPSI2 +@@ -50,7 +50,7 @@ void EXPORT_FUNC (__ctzsi2) (void); + # endif + #endif + +-#ifdef HAVE__RESTGPR_14_X ++#if defined (HAVE__RESTGPR_14_X) || defined (__powerpc__) + void EXPORT_FUNC (_restgpr_14_x) (void); + void EXPORT_FUNC (_restgpr_15_x) (void); + void EXPORT_FUNC (_restgpr_16_x) (void); diff --git a/grub2-ppc64le-core-bigendian.patch b/grub2-ppc64le-core-bigendian.patch new file mode 100644 index 0000000..9c22165 --- /dev/null +++ b/grub2-ppc64le-core-bigendian.patch @@ -0,0 +1,31 @@ +Index: grub-2.02~beta2/conf/Makefile.common +=================================================================== +--- grub-2.02~beta2.orig/conf/Makefile.common ++++ grub-2.02~beta2/conf/Makefile.common +@@ -41,20 +41,20 @@ BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT) + + LDADD_KERNEL = $(TARGET_LIBGCC) + +-CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding ++CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding -mbig-endian + LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) +-CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 ++CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 -mbig-endian + CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) + STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version + +-CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding ++CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding -mbig-endian + LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d +-CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) ++CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -mbig-endian + CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) + +-CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin ++CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin -mbig-endian + LDFLAGS_IMAGE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S +-CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) ++CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -mbig-endian + CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) + + CFLAGS_PROGRAM = diff --git a/grub2-ppc64le-platform.patch b/grub2-ppc64le-platform.patch new file mode 100644 index 0000000..e0d1b0f --- /dev/null +++ b/grub2-ppc64le-platform.patch @@ -0,0 +1,13 @@ +Index: grub-2.02~beta2/configure.ac +=================================================================== +--- grub-2.02~beta2.orig/configure.ac ++++ grub-2.02~beta2/configure.ac +@@ -137,6 +137,7 @@ case "$target_cpu"-"$platform" in + x86_64-xen) ;; + x86_64-*) target_cpu=i386 ;; + powerpc64-ieee1275) target_cpu=powerpc ;; ++ powerpc64le-ieee1275) target_cpu=powerpc ;; + esac + + # Check if the platform is supported, make final adjustments. + diff --git a/grub2.changes b/grub2.changes index 1f8041b..fdf1383 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,3 +1,20 @@ +------------------------------------------------------------------- +Fri Jan 31 14:42:26 UTC 2014 - dvaleev@suse.com + +- Enable grub2 for PowerPC LE (ppc64le) +- Add ppc64le to exclusive arches +- Don't require gcc-32bit (PowerLE don't have 32bit toolchain) + +- added patches: + * grub2-powerpc-libgcc.patch + Provide 32bit libgcc functions for PowerLE + + * grub2-ppc64le-core-bigendian.patch + Build grub kernel and images as BE on ppc64le (BL is BE there) + + * grub2-ppc64le-platform.patch + Enable ppc64le platform + ------------------------------------------------------------------- Fri Jan 24 13:48:13 CET 2014 - jjolly@suse.com diff --git a/grub2.spec b/grub2.spec index 0cfc721..636f401 100644 --- a/grub2.spec +++ b/grub2.spec @@ -60,7 +60,7 @@ BuildRequires: pesign-obs-integration # Modules code is dynamically loaded and collected from a _fixed_ path. %define _libdir %{_exec_prefix}/lib -%ifarch ppc ppc64 +%ifarch ppc ppc64 ppc64le %define grubcpu powerpc %define platform ieee1275 %endif @@ -143,6 +143,9 @@ Patch102: 0003-cmdline-add-envvar-loader_cmdline_append.patch Patch103: 0004-btrfs-export-subvolume-envvars.patch Patch110: 0001-script-provide-overridable-root-by-subvol.patch Patch111: 0002-script-create-menus-for-btrfs-snapshot.patch +Patch200: grub2-ppc64le-platform.patch +Patch201: grub2-powerpc-libgcc.patch +Patch202: grub2-ppc64le-core-bigendian.patch Requires: gettext-runtime %if 0%{?suse_version} >= 1140 Requires: os-prober @@ -158,7 +161,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build %if 0%{?only_x86_64:1} ExclusiveArch: x86_64 %else -ExclusiveArch: %{ix86} x86_64 ppc ppc64 s390x +ExclusiveArch: %{ix86} x86_64 ppc ppc64 ppc64le s390x %endif %description @@ -272,6 +275,12 @@ mv po/grub.pot po/%{name}.pot %patch103 -p1 %patch110 -p1 %patch111 -p1 +%patch200 -p1 +%patch201 -p1 +#We want to override endianess on Power LE only +%ifarch ppc64le +%patch202 -p1 +%endif # Generate po/LINGUAS for message catalogs ... ./linguas.sh @@ -449,6 +458,7 @@ rm $RPM_BUILD_ROOT%{_datadir}/%{name}/*.h # Defaults install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/default/grub install -m 755 -D %{SOURCE6} $RPM_BUILD_ROOT%{_sbindir}/grub2-once + %find_lang %{name} %fdupes %buildroot%{_bindir} @@ -672,11 +682,11 @@ fi %files %{grubarch} %defattr(-,root,root,-) %dir %{_libdir}/%{name}/%{grubarch} -%ifarch ppc ppc64 +%ifarch ppc ppc64 ppc64le %{_libdir}/%{name}/%{grubarch}/%{name}.chrp %{_libdir}/%{name}/%{grubarch}/bootinfo.txt %endif -%ifnarch ppc ppc64 s390x +%ifnarch ppc ppc64 ppc64le s390x %{_libdir}/%{name}/%{grubarch}/*.image %endif %{_libdir}/%{name}/%{grubarch}/*.img