forked from Mirrors/opensbi
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 <anup@brainfault.org> Signed-off-by: Khem Raj <raj.khem@gmail.com> Link: https://lore.kernel.org/r/20250515025931.3383142-1-raj.khem@gmail.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
7
Makefile
7
Makefile
@@ -180,6 +180,11 @@ else
|
|||||||
USE_LD_FLAG = -fuse-ld=bfd
|
USE_LD_FLAG = -fuse-ld=bfd
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
REPRODUCIBLE ?= n
|
||||||
|
ifeq ($(REPRODUCIBLE),y)
|
||||||
|
REPRODUCIBLE_FLAGS += -ffile-prefix-map=$(src_dir)=
|
||||||
|
endif
|
||||||
|
|
||||||
# Check whether the linker supports creating PIEs
|
# 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)
|
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)
|
||||||
|
|
||||||
@@ -369,6 +374,7 @@ GENFLAGS += $(firmware-genflags-y)
|
|||||||
CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections
|
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 += -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
||||||
CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
|
CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
|
||||||
|
CFLAGS += $(REPRODUCIBLE_FLAGS)
|
||||||
# Optionally supported flags
|
# Optionally supported flags
|
||||||
ifeq ($(CC_SUPPORT_VECTOR),y)
|
ifeq ($(CC_SUPPORT_VECTOR),y)
|
||||||
CFLAGS += -DOPENSBI_CC_SUPPORT_VECTOR
|
CFLAGS += -DOPENSBI_CC_SUPPORT_VECTOR
|
||||||
@@ -394,6 +400,7 @@ CPPFLAGS += $(firmware-cppflags-y)
|
|||||||
ASFLAGS = -g -Wall -nostdlib
|
ASFLAGS = -g -Wall -nostdlib
|
||||||
ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
||||||
ASFLAGS += -fPIE
|
ASFLAGS += -fPIE
|
||||||
|
ASFLAGS += $(REPRODUCIBLE_FLAGS)
|
||||||
# Optionally supported flags
|
# Optionally supported flags
|
||||||
ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
|
ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
|
||||||
ASFLAGS += -mno-save-restore
|
ASFLAGS += -mno-save-restore
|
||||||
|
Reference in New Issue
Block a user