Bug 15897

Summary: OpenSBI: Recipe fails to build if zicsr and/or zifencei are in the path (RISC-V)
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Mark Hatle <mark.hatle>
Component: coreAssignee: Trevor Gamblin <tgamblin>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: meta.mr.watcher, meta.watcher, randy.macleod, tgamblin, tim.orling
Version: 5.3   
Target Milestone: 6.1 M2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Mark Hatle 2025-06-09 16:09:21 UTC
The recipe ignores the passed in -march= and other parameters, instead it discovers it's own settings for the compiler.  (I believe this is because, like u-boot and the kenrel, OpenSBI is really building baremetal software.)

In the configuration/compile step, in the Makefile there is a specific check to see if the _zicsr and _zifencei are supported by the compiler in -march=.

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)

The compilation command in the check always fails, the difference is if it fails saying that it can't link or that there is an error with the cflags (march=) passed to the compiler.   The grep statement is too broad, in that it will scan the entire error message including any paths, if the paths have zicsr and/or zifencei then the condition is triggered and the system doesn't believe it needs to specify those options in -march=.

Later during compilation, when the instructions are used a failure will occur as they are not in the 'imafd' configuation in the current gcc.

I suspect the Yocto Project fix is to either hard code the value to 'y' (unconditionally), or work with the upstream project to make the test better and somehow ignore the current path.
Comment 1 Tim Orling 2025-06-12 14:35:46 UTC
Need to identify someone to help with RISC-V issues.
Comment 2 Randy MacLeod 2026-03-13 14:43:43 UTC
Medium+ bugs should have a 6.1-M* milestone so pick M2.
Comment 3 Trevor Gamblin 2026-09-09 18:45:48 UTC
Pretty sure this just needs a little rework to the relevant Makefile lines (a couple of other spots have the same pattern). I should have a patch soon.
Comment 4 Trevor Gamblin 2026-09-10 15:41:12 UTC
Patches on the mailing list: https://lore.kernel.org/openembedded-core/20260910150843.1531415-1-tgamblin@baylibre.com/T/#t

One needed to patch OpenSBI itself, the other to remove the TUNE_RISCV_PKGARCH restriction.