Skip to content

Commit 6d23a9c

Browse files
krajavpatel
authored andcommitted
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 Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Khem Raj <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
1 parent 66ab965 commit 6d23a9c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ else
180180
USE_LD_FLAG = -fuse-ld=bfd
181181
endif
182182
183+
REPRODUCIBLE ?= n
184+
ifeq ($(REPRODUCIBLE),y)
185+
REPRODUCIBLE_FLAGS += -ffile-prefix-map=$(src_dir)=
186+
endif
187+
183188
# Check whether the linker supports creating PIEs
184189
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)
185190
@@ -369,6 +374,7 @@ GENFLAGS += $(firmware-genflags-y)
369374
CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections
370375
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
371376
CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
377+
CFLAGS += $(REPRODUCIBLE_FLAGS)
372378
# Optionally supported flags
373379
ifeq ($(CC_SUPPORT_VECTOR),y)
374380
CFLAGS += -DOPENSBI_CC_SUPPORT_VECTOR
@@ -394,6 +400,7 @@ CPPFLAGS += $(firmware-cppflags-y)
394400
ASFLAGS = -g -Wall -nostdlib
395401
ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
396402
ASFLAGS += -fPIE
403+
ASFLAGS += $(REPRODUCIBLE_FLAGS)
397404
# Optionally supported flags
398405
ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
399406
ASFLAGS += -mno-save-restore

0 commit comments

Comments
 (0)