summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-bsp/opensbi/opensbi/0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch49
-rw-r--r--meta/recipes-bsp/opensbi/opensbi_1.6.bb8
2 files changed, 54 insertions, 3 deletions
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 0000000000..e650476f50
--- /dev/null
+++ b/meta/recipes-bsp/opensbi/opensbi/0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch
@@ -0,0 +1,49 @@
1From f4c440219f42d74bd3d6688132ea876f3f51e601 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 14 May 2025 19:50:24 -0700
4Subject: [PATCH] Makefile: Add flag for reprodubility compiler flags
5
6Provides mechanism to remove absolute paths from binaries using
7-ffile-prefix-map
8
9It will help distros (e.g. yocto based ones ) which want to ship
10the .elf files but need to scrub absolute paths in objects
11
12Upstream-Status: Submitted [https://lists.infradead.org/pipermail/opensbi/2025-May/008458.html]
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14---
15 Makefile | 7 +++++++
16 1 file changed, 7 insertions(+)
17
18diff --git a/Makefile b/Makefile
19index e90836c7..22d4ecff 100644
20--- a/Makefile
21+++ b/Makefile
22@@ -174,6 +174,11 @@ else
23 USE_LD_FLAG = -fuse-ld=bfd
24 endif
25
26+REPRODUCIBLE ?= n
27+ifeq ($(REPRODUCIBLE),y)
28+REPRODUCIBLE_FLAGS += -ffile-prefix-map=$(src_dir)=
29+endif
30+
31 # Check whether the linker supports creating PIEs
32 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)
33
34@@ -362,6 +367,7 @@ GENFLAGS += $(firmware-genflags-y)
35
36 CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections
37 CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
38+CFLAGS += $(REPRODUCIBLE_FLAGS)
39 # Optionally supported flags
40 ifeq ($(CC_SUPPORT_VECTOR),y)
41 CFLAGS += -DOPENSBI_CC_SUPPORT_VECTOR
42@@ -387,6 +393,7 @@ CPPFLAGS += $(firmware-cppflags-y)
43 ASFLAGS = -g -Wall -nostdlib
44 ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
45 ASFLAGS += -fPIE
46+ASFLAGS += $(REPRODUCIBLE_FLAGS)
47 # Optionally supported flags
48 ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
49 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 ed1a70d01a..c9dfcfbe4f 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
9inherit deploy 9inherit deploy
10 10
11SRCREV = "bd613dd92113f683052acfb23d9dc8ba60029e0a" 11SRCREV = "bd613dd92113f683052acfb23d9dc8ba60029e0a"
12SRC_URI = "git://github.com/riscv/opensbi.git;branch=master;protocol=https" 12SRC_URI = "git://github.com/riscv/opensbi.git;branch=master;protocol=https \
13 13 file://0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch \
14"
14S = "${WORKDIR}/git" 15S = "${WORKDIR}/git"
15 16
16TARGET_DBGSRC_DIR = "/share/opensbi/*/generic/firmware/" 17TARGET_DBGSRC_DIR = "/share/opensbi/*/generic/firmware/"
@@ -18,7 +19,8 @@ TARGET_DBGSRC_DIR = "/share/opensbi/*/generic/firmware/"
18TARGET_CC_ARCH += "${LDFLAGS}" 19TARGET_CC_ARCH += "${LDFLAGS}"
19 20
20RISCV_SBI_FW_TEXT_START ??= "0x80000000" 21RISCV_SBI_FW_TEXT_START ??= "0x80000000"
21EXTRA_OEMAKE += "PLATFORM=${RISCV_SBI_PLAT} I=${D} FW_TEXT_START=${RISCV_SBI_FW_TEXT_START}" 22EXTRA_OEMAKE += "REPRODUCIBLE=y CROSS_COMPILE=${HOST_PREFIX} ELFFLAGS="${LDFLAGS}" PLATFORM=${RISCV_SBI_PLAT} I=${D} FW_TEXT_START=${RISCV_SBI_FW_TEXT_START}"
23EXTRA_OEMAKE:append:toolchain-clang = " LLVM=y"
22# If RISCV_SBI_PAYLOAD is set then include it as a payload 24# If RISCV_SBI_PAYLOAD is set then include it as a payload
23EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_image(d)}" 25EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_image(d)}"
24EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_fdt(d)}" 26EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_fdt(d)}"