* [PATCH 0/3] Makefile: fix support checks that use grep
@ 2026-09-10 14:43 Trevor Gamblin
2026-09-10 14:43 ` [PATCH 1/3] Makefile: don't grep when setting CC_SUPPORT_ZICSR_ZIFENCEI Trevor Gamblin
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Trevor Gamblin @ 2026-09-10 14:43 UTC (permalink / raw)
To: opensbi; +Cc: carlos.lopezr4096, Trevor Gamblin
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@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@baylibre.com>
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] Makefile: don't grep when setting CC_SUPPORT_ZICSR_ZIFENCEI
2026-09-10 14:43 [PATCH 0/3] Makefile: fix support checks that use grep Trevor Gamblin
@ 2026-09-10 14:43 ` Trevor Gamblin
2026-09-10 14:43 ` [PATCH 2/3] Makefile: don't grep when setting CC_SUPPORT_STRICT_ALIGN Trevor Gamblin
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Trevor Gamblin @ 2026-09-10 14:43 UTC (permalink / raw)
To: opensbi; +Cc: carlos.lopezr4096, Trevor Gamblin
Check exit status from the compiler/linker check directly (similar to
OPENSBI_LD_PIE), rather than using grep to search for a pattern. This
avoids potential unrelated matches in the command.
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index aebaa98c..07ac7e30 100644
--- a/Makefile
+++ b/Makefile
@@ -204,7 +204,7 @@ CC_SUPPORT_SAVE_RESTORE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib
CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mstrict-align -x c /dev/null -o /dev/null 2>&1 | grep -e "-mstrict-align" -e "-mno-unaligned-access" >/dev/null && echo n || echo y)
# Check whether the assembler and the compiler support the Zicsr and Zifencei extensions
-CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep -e "zicsr" -e "zifencei" > /dev/null && echo n || echo y)
+CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo y || echo n)
# Check whether the assembler and the compiler support the Vector extension
CC_SUPPORT_VECTOR := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)gv -dM -E -x c /dev/null 2>&1 | grep -q riscv.*vector && echo y || echo n)
--
2.55.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] Makefile: don't grep when setting CC_SUPPORT_STRICT_ALIGN
2026-09-10 14:43 [PATCH 0/3] Makefile: fix support checks that use grep Trevor Gamblin
2026-09-10 14:43 ` [PATCH 1/3] Makefile: don't grep when setting CC_SUPPORT_ZICSR_ZIFENCEI Trevor Gamblin
@ 2026-09-10 14:43 ` Trevor Gamblin
2026-09-10 14:43 ` [PATCH 3/3] Makefile: don't grep when setting CC_SUPPORT_SAVE_RESTORE Trevor Gamblin
2026-09-21 13:50 ` [PATCH 0/3] Makefile: fix support checks that use grep Trevor Gamblin
3 siblings, 0 replies; 7+ messages in thread
From: Trevor Gamblin @ 2026-09-10 14:43 UTC (permalink / raw)
To: opensbi; +Cc: carlos.lopezr4096, Trevor Gamblin
Check exit status from the compiler/linker check directly (similar to
OPENSBI_LD_PIE), rather than using grep to search for a pattern. This
avoids potential unrelated matches in the command.
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 07ac7e30..a8ccfbab 100644
--- a/Makefile
+++ b/Makefile
@@ -201,7 +201,7 @@ OPENSBI_LD_EXCLUDE_LIBS := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) $(USE_LD_
CC_SUPPORT_SAVE_RESTORE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mno-save-restore -x c /dev/null -o /dev/null 2>&1 | grep -e "-save-restore" >/dev/null && echo n || echo y)
# Check whether the compiler supports -m(no-)strict-align
-CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mstrict-align -x c /dev/null -o /dev/null 2>&1 | grep -e "-mstrict-align" -e "-mno-unaligned-access" >/dev/null && echo n || echo y)
+CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mstrict-align -x c /dev/null -o /dev/null 2>&1 && echo y || echo n)
# Check whether the assembler and the compiler support the Zicsr and Zifencei extensions
CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo y || echo n)
--
2.55.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] Makefile: don't grep when setting CC_SUPPORT_SAVE_RESTORE
2026-09-10 14:43 [PATCH 0/3] Makefile: fix support checks that use grep Trevor Gamblin
2026-09-10 14:43 ` [PATCH 1/3] Makefile: don't grep when setting CC_SUPPORT_ZICSR_ZIFENCEI Trevor Gamblin
2026-09-10 14:43 ` [PATCH 2/3] Makefile: don't grep when setting CC_SUPPORT_STRICT_ALIGN Trevor Gamblin
@ 2026-09-10 14:43 ` Trevor Gamblin
2026-09-21 13:50 ` [PATCH 0/3] Makefile: fix support checks that use grep Trevor Gamblin
3 siblings, 0 replies; 7+ messages in thread
From: Trevor Gamblin @ 2026-09-10 14:43 UTC (permalink / raw)
To: opensbi; +Cc: carlos.lopezr4096, Trevor Gamblin
Check exit status from the compiler/linker check directly (similar to
OPENSBI_LD_PIE), rather than using grep to search for a pattern. This
avoids potential unrelated matches in the command.
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index a8ccfbab..ea05dfd1 100644
--- a/Makefile
+++ b/Makefile
@@ -198,7 +198,7 @@ OPENSBI_LD_PIE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) $(USE_LD_FLAG) -fP
OPENSBI_LD_EXCLUDE_LIBS := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) $(USE_LD_FLAG) "-Wl,--exclude-libs,ALL" -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo y || echo n)
# Check whether the compiler supports -m(no-)save-restore
-CC_SUPPORT_SAVE_RESTORE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mno-save-restore -x c /dev/null -o /dev/null 2>&1 | grep -e "-save-restore" >/dev/null && echo n || echo y)
+CC_SUPPORT_SAVE_RESTORE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mno-save-restore -x c /dev/null -o /dev/null 2>&1 && echo y || echo n)
# Check whether the compiler supports -m(no-)strict-align
CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mstrict-align -x c /dev/null -o /dev/null 2>&1 && echo y || echo n)
--
2.55.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] Makefile: fix support checks that use grep
2026-09-10 14:43 [PATCH 0/3] Makefile: fix support checks that use grep Trevor Gamblin
` (2 preceding siblings ...)
2026-09-10 14:43 ` [PATCH 3/3] Makefile: don't grep when setting CC_SUPPORT_SAVE_RESTORE Trevor Gamblin
@ 2026-09-21 13:50 ` Trevor Gamblin
2026-09-22 16:55 ` Anup Patel
3 siblings, 1 reply; 7+ messages in thread
From: Trevor Gamblin @ 2026-09-21 13:50 UTC (permalink / raw)
To: Trevor Gamblin, opensbi; +Cc: carlos.lopezr4096, opensbi
Hi all,
Checking in on this series. Do I need to make changes?
Thanks,
Trevor
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] Makefile: fix support checks that use grep
2026-09-21 13:50 ` [PATCH 0/3] Makefile: fix support checks that use grep Trevor Gamblin
@ 2026-09-22 16:55 ` Anup Patel
2026-09-23 19:33 ` Trevor Gamblin
0 siblings, 1 reply; 7+ messages in thread
From: Anup Patel @ 2026-09-22 16:55 UTC (permalink / raw)
To: Trevor Gamblin; +Cc: opensbi, carlos.lopezr4096, opensbi
On Mon, Sep 21, 2026 at 7:20 PM Trevor Gamblin <tgamblin@baylibre.com> wrote:
>
> Hi all,
>
> Checking in on this series. Do I need to make changes?
The Makefile has changed a bit in the latest OpenSBI.
Can you please rebase and send another version ?
Regards,
Anup
>
> Thanks,
> Trevor
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] Makefile: fix support checks that use grep
2026-09-22 16:55 ` Anup Patel
@ 2026-09-23 19:33 ` Trevor Gamblin
0 siblings, 0 replies; 7+ messages in thread
From: Trevor Gamblin @ 2026-09-23 19:33 UTC (permalink / raw)
To: Anup Patel, Trevor Gamblin; +Cc: opensbi, carlos.lopezr4096, opensbi
On Tue Sep 22, 2026 at 12:55 PM EDT, Anup Patel wrote:
> On Mon, Sep 21, 2026 at 7:20 PM Trevor Gamblin <tgamblin@baylibre.com> wrote:
>>
>> Hi all,
>>
>> Checking in on this series. Do I need to make changes?
>
> The Makefile has changed a bit in the latest OpenSBI.
> Can you please rebase and send another version ?
Sure, patches coming shortly.
Trevor
>
> Regards,
> Anup
>
>>
>> Thanks,
>> Trevor
>>
>> --
>> opensbi mailing list
>> opensbi@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/opensbi
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-23 19:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-10 14:43 [PATCH 0/3] Makefile: fix support checks that use grep Trevor Gamblin
2026-09-10 14:43 ` [PATCH 1/3] Makefile: don't grep when setting CC_SUPPORT_ZICSR_ZIFENCEI Trevor Gamblin
2026-09-10 14:43 ` [PATCH 2/3] Makefile: don't grep when setting CC_SUPPORT_STRICT_ALIGN Trevor Gamblin
2026-09-10 14:43 ` [PATCH 3/3] Makefile: don't grep when setting CC_SUPPORT_SAVE_RESTORE Trevor Gamblin
2026-09-21 13:50 ` [PATCH 0/3] Makefile: fix support checks that use grep Trevor Gamblin
2026-09-22 16:55 ` Anup Patel
2026-09-23 19:33 ` Trevor Gamblin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox