[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
12/14: gnu: grub: Add support for Loongson-based machines.
From: |
Mark H. Weaver |
Subject: |
12/14: gnu: grub: Add support for Loongson-based machines. |
Date: |
Wed, 30 Sep 2015 22:13:23 +0000 |
mhw pushed a commit to branch wip-loongson2f
in repository guix.
commit 73801915c11afe5f8e9848bd23b54552f8e408c4
Author: Mark H Weaver <address@hidden>
Date: Tue Sep 22 20:58:26 2015 -0400
gnu: grub: Add support for Loongson-based machines.
* gnu/packages/patches/grub-mips-abi-check.patch,
gnu/packages/patches/grub-mips-endian-check.patch: New files.
* gnu-system.am (dist_patch_DATA): Add them.
* gnu/packages/grub.scm (grub)[source]: Add patches.
[arguments]: Disable tests on MIPS.
[native-inputs]: Remove qemu and xorriso (for tests) on MIPS.
---
gnu-system.am | 2 +
gnu/packages/grub.scm | 22 +++++-
gnu/packages/patches/grub-mips-abi-check.patch | 64 ++++++++++++++++
gnu/packages/patches/grub-mips-endian-check.patch | 84 +++++++++++++++++++++
4 files changed, 168 insertions(+), 4 deletions(-)
diff --git a/gnu-system.am b/gnu-system.am
index d61c526..8866af6 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -479,6 +479,8 @@ dist_patch_DATA =
\
gnu/packages/patches/gobject-introspection-cc.patch \
gnu/packages/patches/gobject-introspection-girepository.patch \
gnu/packages/patches/grep-CVE-2015-1345.patch \
+ gnu/packages/patches/grub-mips-abi-check.patch \
+ gnu/packages/patches/grub-mips-endian-check.patch \
gnu/packages/patches/gsl-poly-test-fix-pt1.patch \
gnu/packages/patches/gsl-poly-test-fix-pt2.patch \
gnu/packages/patches/guile-1.8-cpp-4.5.patch \
diff --git a/gnu/packages/grub.scm b/gnu/packages/grub.scm
index 7d3b032..c8b131c 100644
--- a/gnu/packages/grub.scm
+++ b/gnu/packages/grub.scm
@@ -86,10 +86,18 @@
(file-name (string-append name "-" version "-checkout"))
(sha256
(base32
- "14xsqx3b8rqr0i2xn5vrf8mnxlajw8msi1r6h2vgpl2j0zgjc1m0"))))
+ "14xsqx3b8rqr0i2xn5vrf8mnxlajw8msi1r6h2vgpl2j0zgjc1m0"))
+ (patches (map search-patch '("grub-mips-endian-check.patch"
+ "grub-mips-abi-check.patch")))))
(build-system gnu-build-system)
(arguments
- '(#:configure-flags '("--disable-werror")
+ `(,@(if (string-prefix? "mips" (or (%current-target-system)
+ (%current-system)))
+ ;; XXX Disable tests on MIPS, to work around the fact that our
+ ;; QEMU package is currently broken on MIPS.
+ '(#:tests? #f)
+ '())
+ #:configure-flags '("--disable-werror")
#:phases (modify-phases %standard-phases
(add-after
'unpack 'patch-stuff
@@ -130,8 +138,14 @@
;; Dependencies for the test suite. The "real" QEMU is needed here,
;; because several targets are used.
- ("qemu" ,qemu-for-tests)
- ("xorriso" ,xorriso)))
+ ;;
+ ;; XXX Don't add these on MIPS, since our QEMU package is currently
+ ;; broken on MIPS.
+ ,@(if (not (string-prefix? "mips" (or (%current-target-system)
+ (%current-system))))
+ '(("qemu" ,qemu-for-tests)
+ ("xorriso" ,xorriso))
+ '())))
(home-page "http://www.gnu.org/software/grub/")
(synopsis "GRand Unified Boot loader")
(description
diff --git a/gnu/packages/patches/grub-mips-abi-check.patch
b/gnu/packages/patches/grub-mips-abi-check.patch
new file mode 100644
index 0000000..99306e4
--- /dev/null
+++ b/gnu/packages/patches/grub-mips-abi-check.patch
@@ -0,0 +1,64 @@
+From b609d424889ffdb3cc9191384296980e02514abb Mon Sep 17 00:00:00 2001
+From: Andrei Borzenkov <address@hidden>
+Date: Sun, 20 Sep 2015 07:42:12 +0300
+Subject: [PATCH 2/2] configure: try to force o32 ABI on MIPS
+
+GRUB expects o32 ABI, in particular used assembly is valid only in this mode.
+Some systems (e.g. GNU Guix) default to using newer n64 or n32 ABI. Try to
+find suitable options to force o32.
+
+For GCC this is simply -mabi=32. While clang supports this option as well,
+o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target
+only, so use "-target mips/mipsel -mabi=32".
+
+Reported-By: Mark H Weaver <address@hidden>
+Also-By: Mark H Weaver <address@hidden>
+---
+ configure.ac | 31 +++++++++++++++++++++++++++++++
+ 1 file changed, 31 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index baf8525..d9d4222 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -634,6 +634,37 @@ int main (void);
+ TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
+ fi
+
++if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
++ AC_CACHE_CHECK([for options to force MIPS o32 ABI],
grub_cv_target_cc_mips_o32_abi, [
++ grub_cv_target_cc_mips_o32_abi=no
++ for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
++ if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
++ break
++ fi
++ CFLAGS="$TARGET_CFLAGS $arg -Werror"
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
++#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
++#error not o32 ABI
++#endif
++asm (".globl start; start:");
++asm (".globl _start; _start:");
++asm (".globl __start; __start:");
++void __main (void);
++void __main (void) {}
++int main (void);
++]], [[]])],
++ [grub_cv_target_cc_mips_o32_abi="$arg"], [])
++ done
++ ])
++
++ if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
++ AC_MSG_ERROR([could not force MIPS o32 ABI])
++ fi
++
++ TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
++ TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
++fi
++
+ AC_CACHE_CHECK([for options to compile assembly],
[grub_cv_cc_target_asm_compile], [
+ test_program=
+ case "x$target_cpu-$platform" in
+--
+1.9.1
+
diff --git a/gnu/packages/patches/grub-mips-endian-check.patch
b/gnu/packages/patches/grub-mips-endian-check.patch
new file mode 100644
index 0000000..16b7fa0
--- /dev/null
+++ b/gnu/packages/patches/grub-mips-endian-check.patch
@@ -0,0 +1,84 @@
+From 4a3d2cfc3a1f8d0325b3964b836b5fe584784bb8 Mon Sep 17 00:00:00 2001
+From: Andrei Borzenkov <address@hidden>
+Date: Sun, 20 Sep 2015 07:42:12 +0300
+Subject: [PATCH 1/2] configure: try to find options to force endian on MIPS
+
+---
+ configure.ac | 45 +++++++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 41 insertions(+), 4 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index c864311..baf8525 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -562,12 +562,12 @@ AC_COMPILE_IFELSE(
+ ]])],
+ [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
+
+-if test x$target_cpu = xpowerpc; then
++if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
+ AC_CACHE_CHECK([for options to get big-endian compilation],
grub_cv_target_cc_big_endian, [
+ grub_cv_target_cc_big_endian=no
+- for cand in "-target powerpc -Wl,-EB" "-target powerpc" \
+- "-target powerpc-linux-gnu -Wl,-EB" "-target powerpc-linux-gnu"
\
+- "-mbig-endian"; do
++ for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
++ "-target $target_cpu-linux-gnu -Wl,-EB" "-target
$target_cpu-linux-gnu" \
++ "-EB" "-mbig-endian"; do
+ if test x"$grub_cv_target_cc_big_endian" != xno ; then
+ break
+ fi
+@@ -577,6 +577,8 @@ if test x$target_cpu = xpowerpc; then
+ #error still little endian
+ #endif
+ asm (".globl start; start:");
++asm (".globl _start; _start:");
++asm (".globl __start; __start:");
+ void __main (void);
+ void __main (void) {}
+ int main (void);
+@@ -595,6 +597,41 @@ int main (void);
+ TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
+ TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
+ TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
++elif test x$target_cpu = xmipsel; then
++ AC_CACHE_CHECK([for options to get little-endian compilation],
grub_cv_target_cc_little_endian, [
++ grub_cv_target_cc_little_endian=no
++ for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
++ "-target $target_cpu-linux-gnu -Wl,-EL" "-target
$target_cpu-linux-gnu" \
++ "-EL"; do
++ if test x"$grub_cv_target_cc_little_endian" != xno ; then
++ break
++ fi
++ CFLAGS="$TARGET_CFLAGS $cand -Werror"
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
++#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) &&
(__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
++#error still big endian
++#endif
++asm (".globl start; start:");
++asm (".globl _start; _start:");
++asm (".globl __start; __start:");
++void __main (void);
++void __main (void) {}
++int main (void);
++]], [[]])],
++ [grub_cv_target_cc_little_endian="$cand"], [])
++ done
++ ])
++
++ if test x"$grub_cv_target_cc_little_endian" = xno ; then
++ AC_MSG_ERROR([could not force little-endian])
++ fi
++
++ skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed
'address@hidden,-EL@@')"
++
++ TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
++ TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
++ TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
++ TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
+ fi
+
+ AC_CACHE_CHECK([for options to compile assembly],
[grub_cv_cc_target_asm_compile], [
+--
+1.9.1
+
- branch wip-loongson2f created (now 8692ab8), Mark H. Weaver, 2015/10/08
- 01/14: system: grub: On MIPS, the linux image name is vmlinuz, not bzImage., Mark H. Weaver, 2015/10/08
- 12/14: gnu: grub: Add support for Loongson-based machines.,
Mark H. Weaver <=
- 04/14: gnu: linux-libre: Add 'supported-systems' field: Intel only for now., Mark H. Weaver, 2015/10/08
- 13/14: NON_INTEL_ONLY: services: xorg: Remove xf86-video-intel., Mark H. Weaver, 2015/10/08
- 05/14: gnu: linux-libre: Add case for ARCH=mips., Mark H. Weaver, 2015/10/08
- 06/14: gnu: linux-libre: On MIPS, the linux image name is vmlinuz, not bzImage., Mark H. Weaver, 2015/10/08
- 03/14: linux-initrd: Use pata_acpi, pata_atiixp, and isci modules only on Intel., Mark H. Weaver, 2015/10/08
- 09/14: gnu: grub: Use modify-phases and other minor cleanups., Mark H. Weaver, 2015/10/08
- 08/14: gnu: Add linux-libre-loongson2f., Mark H. Weaver, 2015/10/08
- 07/14: doc: Add texinfo to the requirements when building from git., Mark H. Weaver, 2015/10/08
- 02/14: system: grub: Adjust eye-candy to work on non-Intel systems., Mark H. Weaver, 2015/10/08
- 14/14: TEMPORARY_HACK: gnu: gst-plugins-base: Disable tests on MIPS and ARM., Mark H. Weaver, 2015/10/08