diff mbox series

[v2] opensbi: Pass CROSS_COMPILE and REPRODUCIBLE flags

Message ID 20250515083422.113413-1-raj.khem@gmail.com
State New
Headers show
Series [v2] opensbi: Pass CROSS_COMPILE and REPRODUCIBLE flags | expand

Commit Message

Khem Raj May 15, 2025, 8:34 a.m. UTC
When using clang pass LLVM=y to makefile so it can select needed bits
using clang

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
v2: HOST_PREFIX instead of HOST_SYS is needed

 ...lag-for-reprodubility-compiler-flags.patch | 49 +++++++++++++++++++
 meta/recipes-bsp/opensbi/opensbi_1.6.bb       |  8 +--
 2 files changed, 54 insertions(+), 3 deletions(-)
 create mode 100644 meta/recipes-bsp/opensbi/opensbi/0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch

Comments

Richard Purdie May 15, 2025, 12:22 p.m. UTC | #1
On Thu, 2025-05-15 at 01:34 -0700, Khem Raj via lists.openembedded.org wrote:
> When using clang pass LLVM=y to makefile so it can select needed bits
> using clang
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
> v2: HOST_PREFIX instead of HOST_SYS is needed
> 
>  ...lag-for-reprodubility-compiler-flags.patch | 49 +++++++++++++++++++
>  meta/recipes-bsp/opensbi/opensbi_1.6.bb       |  8 +--
>  2 files changed, 54 insertions(+), 3 deletions(-)
>  create mode 100644 meta/recipes-bsp/opensbi/opensbi/0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch

This breaks the builds:

https://autobuilder.yoctoproject.org/valkyrie/#/builders/45/builds/77

Cheers,

Richard
Khem Raj May 15, 2025, 1:35 p.m. UTC | #2
Perhaps you did not use v2 ?

On Thu, May 15, 2025 at 5:22 AM Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Thu, 2025-05-15 at 01:34 -0700, Khem Raj via lists.openembedded.org
> wrote:
> > When using clang pass LLVM=y to makefile so it can select needed bits
> > using clang
> >
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > ---
> > v2: HOST_PREFIX instead of HOST_SYS is needed
> >
> >  ...lag-for-reprodubility-compiler-flags.patch | 49 +++++++++++++++++++
> >  meta/recipes-bsp/opensbi/opensbi_1.6.bb       |  8 +--
> >  2 files changed, 54 insertions(+), 3 deletions(-)
> >  create mode 100644
> meta/recipes-bsp/opensbi/opensbi/0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch
>
> This breaks the builds:
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/45/builds/77
>
> Cheers,
>
> Richard
>
Richard Purdie May 15, 2025, 1:52 p.m. UTC | #3
On Thu, 2025-05-15 at 06:35 -0700, Khem Raj wrote:
> Perhaps you did not use v2 ? 

Perhaps I did?

I used the version which is still in master-next and looks like the v2.

Cheers,

Richard
diff mbox series

Patch

diff --git a/meta/recipes-bsp/opensbi/opensbi/0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch b/meta/recipes-bsp/opensbi/opensbi/0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch
new file mode 100644
index 00000000000..e650476f50f
--- /dev/null
+++ b/meta/recipes-bsp/opensbi/opensbi/0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch
@@ -0,0 +1,49 @@ 
+From f4c440219f42d74bd3d6688132ea876f3f51e601 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 14 May 2025 19:50:24 -0700
+Subject: [PATCH] Makefile: Add flag for reprodubility compiler flags
+
+Provides mechanism to remove absolute paths from binaries using
+-ffile-prefix-map
+
+It will help distros (e.g. yocto based ones ) which want to ship
+the .elf files but need to scrub absolute paths in objects
+
+Upstream-Status: Submitted [https://lists.infradead.org/pipermail/opensbi/2025-May/008458.html]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ Makefile | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index e90836c7..22d4ecff 100644
+--- a/Makefile
++++ b/Makefile
+@@ -174,6 +174,11 @@ else
+ USE_LD_FLAG	=	-fuse-ld=bfd
+ endif
+ 
++REPRODUCIBLE ?= n
++ifeq ($(REPRODUCIBLE),y)
++REPRODUCIBLE_FLAGS		+=	-ffile-prefix-map=$(src_dir)=
++endif
++
+ # Check whether the linker supports creating PIEs
+ OPENSBI_LD_PIE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) $(USE_LD_FLAG) -fPIE -nostdlib -Wl,-pie -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo y || echo n)
+ 
+@@ -362,6 +367,7 @@ GENFLAGS	+=	$(firmware-genflags-y)
+ 
+ CFLAGS		=	-g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections
+ CFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls
++CFLAGS		+=	$(REPRODUCIBLE_FLAGS)
+ # Optionally supported flags
+ ifeq ($(CC_SUPPORT_VECTOR),y)
+ CFLAGS		+=	-DOPENSBI_CC_SUPPORT_VECTOR
+@@ -387,6 +393,7 @@ CPPFLAGS	+=	$(firmware-cppflags-y)
+ ASFLAGS		=	-g -Wall -nostdlib
+ ASFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls
+ ASFLAGS		+=	-fPIE
++ASFLAGS		+=	$(REPRODUCIBLE_FLAGS)
+ # Optionally supported flags
+ ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
+ ASFLAGS		+=	-mno-save-restore
diff --git a/meta/recipes-bsp/opensbi/opensbi_1.6.bb b/meta/recipes-bsp/opensbi/opensbi_1.6.bb
index ed1a70d01a1..bfbd56b74e3 100644
--- a/meta/recipes-bsp/opensbi/opensbi_1.6.bb
+++ b/meta/recipes-bsp/opensbi/opensbi_1.6.bb
@@ -9,8 +9,9 @@  require opensbi-payloads.inc
 inherit deploy
 
 SRCREV = "bd613dd92113f683052acfb23d9dc8ba60029e0a"
-SRC_URI = "git://github.com/riscv/opensbi.git;branch=master;protocol=https"
-
+SRC_URI = "git://github.com/riscv/opensbi.git;branch=master;protocol=https \
+           file://0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch \
+"
 S = "${WORKDIR}/git"
 
 TARGET_DBGSRC_DIR = "/share/opensbi/*/generic/firmware/"
@@ -18,7 +19,8 @@  TARGET_DBGSRC_DIR = "/share/opensbi/*/generic/firmware/"
 TARGET_CC_ARCH += "${LDFLAGS}"
 
 RISCV_SBI_FW_TEXT_START ??= "0x80000000"
-EXTRA_OEMAKE += "PLATFORM=${RISCV_SBI_PLAT} I=${D} FW_TEXT_START=${RISCV_SBI_FW_TEXT_START}"
+EXTRA_OEMAKE += "REPRODUCIBLE=y CROSS_COMPILE=${HOST_PREFIX} PLATFORM=${RISCV_SBI_PLAT} I=${D} FW_TEXT_START=${RISCV_SBI_FW_TEXT_START}"
+EXTRA_OEMAKE:append:toolchain-clang = " LLVM=y"
 # If RISCV_SBI_PAYLOAD is set then include it as a payload
 EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_image(d)}"
 EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_fdt(d)}"