[PATCH v2 0/3] Makefile: fix support checks that use grep
Anup Patel
anup at brainfault.org
Mon Sep 28 01:35:24 PDT 2026
On Thu, Sep 24, 2026 at 2:52 AM Trevor Gamblin <tgamblin at baylibre.com> wrote:
>
> When building OpenSBI in environments where extensions from the ISA are
> used to generate build paths (e.g. Yocto Project), the Makefile checks
> which use grep to look for patterns can incorrectly match against the
> build paths, rather than the command's exit status. This means a
> workaround is needed to handle checking for extensions like zicsr and
> zifencei. Instead, make the following variable assignments use the same
> exit status pattern as OPENSBI_LD_PIE:
>
> CC_SUPPORT_ZICSR_ZIFENCEI
> CC_SUPPORT_STRICT_ALIGN
> CC_SUPPORT_SAVE_RESTORE
>
> Tested by building a full image in Yocto including OpenSBI and booting
> it in QEMU.
>
> Note that only the first patch (for CC_SUPPORT_ZICSR_ZIFENCEI) is needed
> to fix the Yocto QEMU case, but I've submitted the remaining two for
> consistency. Also since submitting the first version of this series two
> additional uses of grep have appeared in the Makefile, but I've opted
> not to change them since they don't appear to result in the same issue
> observed in Yocto.
>
> See also: https://bugzilla.yoctoproject.org/show_bug.cgi?id=15897
>
> As an example, in my Yocto build environment, values like CC for OpenSBI
> are set like:
>
> |export CC="riscv64-poky-linux-gcc -march=rv64imafdc_zicsr_zifencei -mabi=lp64d -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/tgamblin/workspace/ypbuilds/poky-qemuriscv64/build/tmp/work/riscv64imafdc_zicsr_zifencei-poky-linux/opensbi/1.9/recipe-sysroot"
>
> and the build error:
>
> | /tmp/ccnpajj3.s: Assembler messages:
> | /home/tgamblin/workspace/ypbuilds/poky-qemuriscv64/build/tmp/work/riscv64imafdc_zicsr_zifencei-poky-linux/opensbi/1.9/sources/opensbi-1.9/lib/sbi/sbi_tlb.c:176:
> | Error: unrecognized opcode `fence.i', extension `zifencei' required
>
> Checking the exit status directly avoids a positive match as happens
> with grep.
>
> Signed-off-by: Trevor Gamblin <tgamblin at baylibre.com>
>
> ---
> Changes in v2:
> - Rebased onto latest master, removed old CC (their changes merged
> already), no functional changes
> - Link to v1: https://patch.msgid.link/20260910-makefile_extension_grep-v1-0-b3ae0d456a6e@baylibre.com
>
> ---
> Trevor Gamblin (3):
> Makefile: don't grep when setting CC_SUPPORT_ZICSR_ZIFENCEI
> Makefile: don't grep when setting CC_SUPPORT_STRICT_ALIGN
> Makefile: don't grep when setting CC_SUPPORT_SAVE_RESTORE
LGTM. You may also want to update CC_SUPPORT_VECTOR and
CC_SUPPORT_WTHREAD_SAFETY_POINTER in top-level Makefile.
Reviewed-by: Anup Patel <anup at brainfault.org>
Applied this series to the riscv/opensbi repo.
Thanks,
Anup
>
> Makefile | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> ---
> base-commit: 5a175017261af97e9122fcb9d9012481cdb5aa41
> change-id: 20260909-makefile_extension_grep-4f9fcea894cd
>
> Best regards,
> --
> Trevor Gamblin <tgamblin at baylibre.com>
>
More information about the opensbi
mailing list