Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 905785 - sys-boot/grub on VisionFive2 requires a newer configure.ac from upstream
Summary: sys-boot/grub on VisionFive2 requires a newer configure.ac from upstream
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: riscv Linux
: Normal normal (vote)
Assignee: Mike Gilbert
URL:
Whiteboard:
Keywords:
: 905948 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-05-05 20:04 UTC by scott
Modified: 2023-05-09 20:23 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
output of emerge --info (emerge.info,5.52 KB, application/x-info)
2023-05-05 20:04 UTC, scott
Details

Note You need to log in before you can comment on or make changes to this bug.
Description scott 2023-05-05 20:04:19 UTC
Created attachment 861208 [details]
output of emerge --info

Build fails due to unrecognized opcode 'fence.i':

riscv64-unknown-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/grub-core -I..  -Wall -W  -DGRUB_MACHINE_EFI=1 -DGRUB_MACHINE=RISCV64_EFI -nostdinc -isystem /usr/lib/gcc/riscv64-unknown-linux-gnu/13/include -I/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/include -I../include -DGRUB_FILE=\"kern/riscv/cache_flush.S\" -I. -I/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/grub-core -I.. -I/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06 -I/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/include -I../include -I/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/grub-core/lib/libgcrypt-grub/src/   -DGRUB_KERNEL=1  -D_FILE_OFFSET_BITS=64 -g  -march=rv64imac -mabi=lp64 -fno-PIE -fno-pie -DGRUB_FILE=\"kern/riscv/cache_flush.S\" -I. -I/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/grub-core -I.. -I/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06 -I/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/include -I../include -I/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/grub-core/lib/libgcrypt-grub/src/ -DASM_FILE=1     -c -o kern/riscv/kernel_exec-cache_flush.o `test -f 'kern/riscv/cache_flush.S' || echo '/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/grub-core/'`kern/riscv/cache_flush.S
/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/grub-core/kern/riscv/cache_flush.S: Assembler messages:
/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06/grub-core/kern/riscv/cache_flush.S:43: Error: unrecognized opcode `fence.i', extension `zifencei' required

This is because configure.ac asserts -march=rv64imac, intending to prevent use of float or doubles, but unfortunately 'rv64imac' lacks zifencei:

   if test "x$target_cpu" = xriscv64; then
       CFLAGS="$TARGET_CFLAGS -march=rv64imac -mabi=lp64 -Werror"
       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                         [grub_cv_target_cc_soft_float="-march=rv64imac -mabi=lp64"], [])


This is fixed upstream (https://git.savannah.gnu.org/cgit/grub.git/tree/configure.ac):

    if test "x$target_cpu" = xriscv64; then
       CFLAGS="$TARGET_CFLAGS -march=rv64imac -mabi=lp64 -Werror"
       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                         [grub_cv_target_cc_soft_float="-march=rv64imac -mabi=lp64"], [])
       # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
       CFLAGS="$TARGET_CFLAGS -march=rv64imac_zicsr_zifencei -mabi=lp64 -Werror"
       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                         [grub_cv_target_cc_soft_float="-march=rv64imac_zicsr_zifencei -mabi=lp64"], [])
    fi

I got a clean compile by changing configure.ac to include that new CFLAGS stanza.
Comment 2 scott 2023-05-07 20:01:14 UTC
/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06 # cat > gentoo-bug-905785.patch
index 4f649ed..5c01af0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -870,11 +870,19 @@ if test x"$platform" != xemu ; then
        CFLAGS="$TARGET_CFLAGS -march=rv32imac -mabi=ilp32 -Werror"
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
 		         [grub_cv_target_cc_soft_float="-march=rv32imac -mabi=ilp32"], [])
+       # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
+       CFLAGS="$TARGET_CFLAGS -march=rv32imac_zicsr_zifencei -mabi=ilp32 -Werror"
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+		         [grub_cv_target_cc_soft_float="-march=rv32imac_zicsr_zifencei -mabi=ilp32"], [])
     fi
     if test "x$target_cpu" = xriscv64; then
        CFLAGS="$TARGET_CFLAGS -march=rv64imac -mabi=lp64 -Werror"
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
 		         [grub_cv_target_cc_soft_float="-march=rv64imac -mabi=lp64"], [])
+       # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
+       CFLAGS="$TARGET_CFLAGS -march=rv64imac_zicsr_zifencei -mabi=lp64 -Werror"
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+		         [grub_cv_target_cc_soft_float="-march=rv64imac_zicsr_zifencei -mabi=lp64"], [])
     fi
     if test "x$target_cpu" = xia64; then
        CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"

/var/tmp/portage/sys-boot/grub-2.06-r6/work/grub-2.06 # patch -p0 < gentoo-bug-905785.patch 
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|index 4f649ed..5c01af0 100644
|--- a/configure.ac
|+++ b/configure.ac
--------------------------
File to patch: configure.ac
patching file configure.ac

...

Success!

>>> Installing (1 of 1) sys-boot/grub-2.06-r6::gentoo
 * For information on how to configure GRUB2 please refer to the guide:
 *     https://wiki.gentoo.org/wiki/GRUB2_Quick_Start

>>> Completed (1 of 1) sys-boot/grub-2.06-r6::gentoo

 * Messages for package sys-boot/grub-2.06-r6:

 * For information on how to configure GRUB2 please refer to the guide:
 *     https://wiki.gentoo.org/wiki/GRUB2_Quick_Start

 * Regenerating GNU info directory index...
 * Processed 87 info files.
Comment 3 Mike Gilbert gentoo-dev 2023-05-09 20:11:30 UTC
*** Bug 905948 has been marked as a duplicate of this bug. ***
Comment 4 Larry the Git Cow gentoo-dev 2023-05-09 20:23:09 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=939f10540fec60b4b22708ebd89610d95ff2097d

commit 939f10540fec60b4b22708ebd89610d95ff2097d
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2023-05-09 20:22:13 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2023-05-09 20:22:13 +0000

    sys-boot/grub: backport build fix for RISCV
    
    Closes: https://bugs.gentoo.org/905785
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 sys-boot/grub/files/grub-2.06-riscv.patch | 49 +++++++++++++++++++++++++++++++
 sys-boot/grub/grub-2.06-r6.ebuild         |  1 +
 2 files changed, 50 insertions(+)