[PATCH 0/3] Makefile: fix support checks that use grep
Trevor Gamblin
tgamblin at baylibre.com
Thu Sep 10 07:43:20 PDT 2026
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. If taking those, then there's at least one other patch on
the mailing list that may also need rework (submitter CC'd):
|[PATCH v2 14/14] Makefile: enable Thread Safety Analysis
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>
---
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
Makefile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
base-commit: 3593a5facc4c6938b90429a6973ba9ee21fc5899
change-id: 20260909-makefile_extension_grep-4f9fcea894cd
Best regards,
--
Trevor Gamblin <tgamblin at baylibre.com>
More information about the opensbi
mailing list