diff options
-rw-r--r-- | meta/recipes-bsp/opensbi/opensbi/0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch | 49 | ||||
-rw-r--r-- | meta/recipes-bsp/opensbi/opensbi_1.6.bb | 8 |
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 @@ | |||
1 | From f4c440219f42d74bd3d6688132ea876f3f51e601 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Wed, 14 May 2025 19:50:24 -0700 | ||
4 | Subject: [PATCH] Makefile: Add flag for reprodubility compiler flags | ||
5 | |||
6 | Provides mechanism to remove absolute paths from binaries using | ||
7 | -ffile-prefix-map | ||
8 | |||
9 | It will help distros (e.g. yocto based ones ) which want to ship | ||
10 | the .elf files but need to scrub absolute paths in objects | ||
11 | |||
12 | Upstream-Status: Submitted [https://lists.infradead.org/pipermail/opensbi/2025-May/008458.html] | ||
13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
14 | --- | ||
15 | Makefile | 7 +++++++ | ||
16 | 1 file changed, 7 insertions(+) | ||
17 | |||
18 | diff --git a/Makefile b/Makefile | ||
19 | index 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 | |||
9 | inherit deploy | 9 | inherit deploy |
10 | 10 | ||
11 | SRCREV = "bd613dd92113f683052acfb23d9dc8ba60029e0a" | 11 | SRCREV = "bd613dd92113f683052acfb23d9dc8ba60029e0a" |
12 | SRC_URI = "git://github.com/riscv/opensbi.git;branch=master;protocol=https" | 12 | SRC_URI = "git://github.com/riscv/opensbi.git;branch=master;protocol=https \ |
13 | 13 | file://0001-Makefile-Add-flag-for-reprodubility-compiler-flags.patch \ | |
14 | " | ||
14 | S = "${WORKDIR}/git" | 15 | S = "${WORKDIR}/git" |
15 | 16 | ||
16 | TARGET_DBGSRC_DIR = "/share/opensbi/*/generic/firmware/" | 17 | TARGET_DBGSRC_DIR = "/share/opensbi/*/generic/firmware/" |
@@ -18,7 +19,8 @@ TARGET_DBGSRC_DIR = "/share/opensbi/*/generic/firmware/" | |||
18 | TARGET_CC_ARCH += "${LDFLAGS}" | 19 | TARGET_CC_ARCH += "${LDFLAGS}" |
19 | 20 | ||
20 | RISCV_SBI_FW_TEXT_START ??= "0x80000000" | 21 | RISCV_SBI_FW_TEXT_START ??= "0x80000000" |
21 | EXTRA_OEMAKE += "PLATFORM=${RISCV_SBI_PLAT} I=${D} FW_TEXT_START=${RISCV_SBI_FW_TEXT_START}" | 22 | EXTRA_OEMAKE += "REPRODUCIBLE=y CROSS_COMPILE=${HOST_PREFIX} ELFFLAGS="${LDFLAGS}" PLATFORM=${RISCV_SBI_PLAT} I=${D} FW_TEXT_START=${RISCV_SBI_FW_TEXT_START}" |
23 | EXTRA_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 |
23 | EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_image(d)}" | 25 | EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_image(d)}" |
24 | EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_fdt(d)}" | 26 | EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_fdt(d)}" |