diff mbox series

[v2,2/7] Makefile: sensible default value for OPENSBI_CC_XLEN.

Message ID 20251114203842.13396-3-b.freisen@gmx.net
State Accepted
Headers show
Series Add trap-based ISA extension emulation | expand

Commit Message

Benedikt Freisen Nov. 14, 2025, 8:38 p.m. UTC
If guessing the compiler's XLEN fails, use 64 rather than garbage.
The previous behavior could silently break e.g. OPENSBI_CC_SUPPORT_VECTOR
when cross-compiling with a system's native clang.

Signed-off-by: Benedikt Freisen <b.freisen@gmx.net>
---
 Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Anup Patel Dec. 15, 2025, 3:46 p.m. UTC | #1
On Sat, Nov 15, 2025 at 2:09 AM Benedikt Freisen <b.freisen@gmx.net> wrote:
>
> If guessing the compiler's XLEN fails, use 64 rather than garbage.
> The previous behavior could silently break e.g. OPENSBI_CC_SUPPORT_VECTOR
> when cross-compiling with a system's native clang.
>
> Signed-off-by: Benedikt Freisen <b.freisen@gmx.net>

LGTM.

Reviewed-by: Anup Patel <anup@brainfault.org>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  Makefile | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 398eabe..afcc544 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -151,6 +151,12 @@ endif
>
>  # Guess the compiler's XLEN
>  OPENSBI_CC_XLEN := $(shell TMP=`$(CC) $(CLANG_TARGET) -dumpmachine | sed 's/riscv\([0-9][0-9]\).*/\1/'`; echo $${TMP})
> +# If guessing XLEN fails, default to 64
> +ifneq ($(OPENSBI_CC_XLEN),32)
> +  ifneq ($(OPENSBI_CC_XLEN),64)
> +    OPENSBI_CC_XLEN = 64
> +  endif
> +endif
>
>  # Guess the compiler's ABI and ISA
>  ifneq ($(CC_IS_CLANG),y)
> --
> 2.51.1
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 398eabe..afcc544 100644
--- a/Makefile
+++ b/Makefile
@@ -151,6 +151,12 @@  endif
 
 # Guess the compiler's XLEN
 OPENSBI_CC_XLEN := $(shell TMP=`$(CC) $(CLANG_TARGET) -dumpmachine | sed 's/riscv\([0-9][0-9]\).*/\1/'`; echo $${TMP})
+# If guessing XLEN fails, default to 64
+ifneq ($(OPENSBI_CC_XLEN),32)
+  ifneq ($(OPENSBI_CC_XLEN),64)
+    OPENSBI_CC_XLEN = 64
+  endif
+endif
 
 # Guess the compiler's ABI and ISA
 ifneq ($(CC_IS_CLANG),y)