Makefile: Add build time and compiler info string
PATCH v4 1/1 Makefile: Add build time and compiler info string
From: Wei Fu <[email protected]>
When we are doing opensbi development, we want to know the build time and compiler info for debug purpose.
To enable this message, please add "BUILD_INFO=y", like:
``` make BUILD_INFO=y ```
NOTE: BUILD_INFO=y will violate "reproducible builds".
So it's ONLY for development and debug purpose, and should NOT be used in a product which follows "reproducible builds".
--- Makefile | 31 +++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 62 insertions(+)
Makefile +31 -0
@@ -150,6 +150,25 @@ 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) +# Build Info: +# OPENSBI_BUILD_TIME_STAMP -- the compilation time stamp +# OPENSBI_BUILD_COMPILER_VERSION -- the compiler version info +BUILD_INFO ?= n +ifeq ($(BUILD_INFO),y) +OPENSBI_BUILD_DATE_FMT = +%Y-%m-%d-%H-%M-%S %Z +ifdef SOURCE_DATE_EPOCH + OPENSBI_BUILD_TIME_STAMP ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" \ + "$(OPENSBI_BUILD_DATE_FMT)" 2>/dev/null || \ + date -u -r "$(SOURCE_DATE_EPOCH)" \ + "$(OPENSBI_BUILD_DATE_FMT)" 2>/dev/null || \ + date -u "$(OPENSBI_BUILD_DATE_FMT)") +else + OPENSBI_BUILD_TIME_STAMP ?= $(shell date "$(OPENSBI_BUILD_DATE_FMT)") +endif +OPENSBI_BUILD_COMPILER_VERSION=$(shell $(CC) -v 2>&1 | grep ' version ' | \ + sed 's/[[:space:]]*$$//') +endif + # Setup list of objects.mk files ifdef PLATFORM platform-object-mks=$(shell if [ -d $(platform_src_dir)/ ]; then find $(platform_src_dir) -iname "objects.mk" | sort -r; fi)
@@ -247,6 +266,10 @@ GENFLAGS += -I$(include_dir) ifneq ($(OPENSBI_VERSION_GIT),) GENFLAGS += -DOPENSBI_VERSION_GIT="\"$(OPENSBI_VERSION_GIT)\"" endif +ifeq ($(BUILD_INFO),y) +GENFLAGS += -DOPENSBI_BUILD_TIME_STAMP="\"$(OPENSBI_BUILD_TIME_STAMP)\"" +GENFLAGS += -DOPENSBI_BUILD_COMPILER_VERSION="\"$(OPENSBI_BUILD_COMPILER_VERSION)\"" +endif GENFLAGS += $(libsbiutils-genflags-y) GENFLAGS += $(platform-genflags-y) GENFLAGS += $(firmware-genflags-y)
@@ -398,6 +421,11 @@ $(build_dir)/%.dep: $(src_dir)/%.c $(build_dir)/%.o: $(src_dir)/%.c $(call compile_cc,$@,$<) +ifeq ($(BUILD_INFO),y) +$(build_dir)/lib/sbi/sbi_init.o: $(libsbi_dir)/sbi_init.c FORCE + $(call compile_cc,$@,$<) +endif + $(build_dir)/%.dep: $(src_dir)/%.S $(call compile_as_dep,$@,$<)
@@ -551,3 +579,6 @@ ifeq ($(install_root_dir),$(install_root_dir_default)/usr) $(if $(V), @echo " RM $(install_root_dir_default)") $(CMD_PREFIX)rm -rf $(install_root_dir_default) endif + +.PHONY: FORCE +FORCE:
README.md +23 -0
@@ -254,6 +254,28 @@ to produce broken binaries with missing relocations; it is therefore currently recommended that this combination be avoided or *FW_PIC=n* be used to disable building OpenSBI as a position-independent binary. +Building with timestamp and compiler info +----------------------------------------- + +When doing development, we may want to know the build time and compiler info +for debug purpose. OpenSBI can also be built with timestamp and compiler info. +To build with those info and print it out@boot time, we can just simply add +`BUILD_INFO=y`, like: +``` +make BUILD_INFO=y +``` + +But if you have used `BUILD_INFO=y`, and want to switch back to `BUILD_INFO=n`, +you must do +``` +make clean +``` +before the next build. + +NOTE: Using `BUILD_INFO=y` will violate [reproducible builds]. This definition +is ONLY for development and debug purpose, and should NOT be used in a product +which follows "reproducible builds". + Contributing to OpenSBI -----------------------
@@ -336,3 +358,4 @@ make I=<install_directory> install_docs [Doxygen manual]: http://www.doxygen.nl/manual/index.html [Kendryte standalone SDK]: https://github.com/kendryte/kendryte-standalone-sdk [third party notices]: ThirdPartyNotices.md +[reproducible builds]: https://reproducible-builds.org
lib/sbi/sbi_init.c +8 -0
@@ -48,6 +48,14 @@ static void sbi_boot_print_banner(struct sbi_scratch *scratch) OPENSBI_VERSION_MINOR);#endif +#ifdef OPENSBI_BUILD_TIME_STAMP +sbi_printf ("Build time: %s\n" ,OPENSBI_BUILD_TIME_STAMP ); +#endif + +#ifdef OPENSBI_BUILD_COMPILER_VERSION +sbi_printf ("Build compiler: %s\n" ,OPENSBI_BUILD_COMPILER_VERSION ); +#endif +sbi_printf (BANNER ); }
Signature · 1 line
2.25.4
PATCH v4 1/1 Makefile: Add build time and compiler info string
Quoted 11 lines · On Thu, Sep 30, 2021 at 3:41 PM <[email protected]> wrote:
From: Wei Fu <[email protected]>
When we are doing opensbi development, we want to know the build time and compiler info for debug purpose.
To enable this message, please add "BUILD_INFO=y", like:``` make BUILD_INFO=y ```
Quoted 5 lines
NOTE:
BUILD_INFO=ywill violate "reproducible builds".
So it's ONLY for development and debug purpose, and should NOT be used in a product which follows "reproducible builds".Signed-off-by Wei Fu <[email protected]>
Looks good to me.
I will let Alistair and others provide the reviews.
Thanks,
Anup
Quoted 131 lines
--- Makefile | 31 +++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 62 insertions(+)Makefile +31
-0@@ -150,6 +150,25 @@ 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) +# Build Info: +# OPENSBI_BUILD_TIME_STAMP -- the compilation time stamp +# OPENSBI_BUILD_COMPILER_VERSION -- the compiler version info +BUILD_INFO ?= n +ifeq ($(BUILD_INFO),y) +OPENSBI_BUILD_DATE_FMT = +%Y-%m-%d-%H-%M-%S %Z +ifdef SOURCE_DATE_EPOCH + OPENSBI_BUILD_TIME_STAMP ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" \ + "$(OPENSBI_BUILD_DATE_FMT)" 2>/dev/null || \ + date -u -r "$(SOURCE_DATE_EPOCH)" \ + "$(OPENSBI_BUILD_DATE_FMT)" 2>/dev/null || \ + date -u "$(OPENSBI_BUILD_DATE_FMT)") +else + OPENSBI_BUILD_TIME_STAMP ?= $(shell date "$(OPENSBI_BUILD_DATE_FMT)") +endif +OPENSBI_BUILD_COMPILER_VERSION=$(shell $(CC) -v 2>&1 | grep ' version ' | \ + sed 's/[[:space:]]*$$//') +endif + # Setup list of objects.mk files ifdef PLATFORM platform-object-mks=$(shell if [ -d $(platform_src_dir)/ ]; then find $(platform_src_dir) -iname "objects.mk" | sort -r; fi)@@ -247,6 +266,10 @@ GENFLAGS += -I$(include_dir) ifneq ($(OPENSBI_VERSION_GIT),) GENFLAGS += -DOPENSBI_VERSION_GIT="\"$(OPENSBI_VERSION_GIT)\"" endif +ifeq ($(BUILD_INFO),y) +GENFLAGS += -DOPENSBI_BUILD_TIME_STAMP="\"$(OPENSBI_BUILD_TIME_STAMP)\"" +GENFLAGS += -DOPENSBI_BUILD_COMPILER_VERSION="\"$(OPENSBI_BUILD_COMPILER_VERSION)\"" +endif GENFLAGS += $(libsbiutils-genflags-y) GENFLAGS += $(platform-genflags-y) GENFLAGS += $(firmware-genflags-y)@@ -398,6 +421,11 @@ $(build_dir)/%.dep: $(src_dir)/%.c $(build_dir)/%.o: $(src_dir)/%.c $(call compile_cc,$@,$<) +ifeq ($(BUILD_INFO),y) +$(build_dir)/lib/sbi/sbi_init.o: $(libsbi_dir)/sbi_init.c FORCE + $(call compile_cc,$@,$<) +endif + $(build_dir)/%.dep: $(src_dir)/%.S $(call compile_as_dep,$@,$<)@@ -551,3 +579,6 @@ ifeq ($(install_root_dir),$(install_root_dir_default)/usr) $(if $(V), @echo " RM $(install_root_dir_default)") $(CMD_PREFIX)rm -rf $(install_root_dir_default) endif + +.PHONY: FORCE +FORCE:README.md +23
-0@@ -254,6 +254,28 @@ to produce broken binaries with missing relocations; it is therefore currently recommended that this combination be avoided or *FW_PIC=n* be used to disable building OpenSBI as a position-independent binary. +Building with timestamp and compiler info +----------------------------------------- + +When doing development, we may want to know the build time and compiler info +for debug purpose. OpenSBI can also be built with timestamp and compiler info. +To build with those info and print it out at boot time, we can just simply add +`BUILD_INFO=y`, like: +``` +make BUILD_INFO=y +``` + +But if you have used `BUILD_INFO=y`, and want to switch back to `BUILD_INFO=n`, +you must do +``` +make clean +``` +before the next build. + +NOTE: Using `BUILD_INFO=y` will violate [reproducible builds]. This definition +is ONLY for development and debug purpose, and should NOT be used in a product +which follows "reproducible builds". + Contributing to OpenSBI -----------------------@@ -336,3 +358,4 @@ make I=<install_directory> install_docs [Doxygen manual]: http://www.doxygen.nl/manual/index.html [Kendryte standalone SDK]: https://github.com/kendryte/kendryte-standalone-sdk [third party notices]: ThirdPartyNotices.md +[reproducible builds]: https://reproducible-builds.orglib/sbi/sbi_init.c +8
-1@@ -48,6 +48,14 @@ static void sbi_boot_print_banner(struct sbi_scratch *scratch) OPENSBI_VERSION_MINOR);#endif +#ifdef OPENSBI_BUILD_TIME_STAMP +sbi_printf ("Build time: %s\n" ,OPENSBI_BUILD_TIME_STAMP ); +#endif + +#ifdef OPENSBI_BUILD_COMPILER_VERSION +sbi_printf ("Build compiler: %s\n" ,OPENSBI_BUILD_COMPILER_VERSION ); +#endif +sbi_printf (BANNER ); } --2.25.4
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v4 1/1 Makefile: Add build time and compiler info string
In reply to [email protected]Hi Wei,
Quoted 27 lines · On Thu, Sep 30, 2021 at 6:12 PM <[email protected]> wrote:
From: Wei Fu <[email protected]>
When we are doing opensbi development, we want to know the build time and compiler info for debug purpose.
To enable this message, please add "BUILD_INFO=y", like:``` make BUILD_INFO=y ```NOTE:
BUILD_INFO=ywill violate "reproducible builds".
So it's ONLY for development and debug purpose, and should NOT be used in a product which follows "reproducible builds".Signed-off-by Wei Fu <[email protected]>--- Makefile | 31 +++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 62 insertions(+)Makefile +0
-0
Makefile endif · line 158
Quoted 9 lines
Makefile +6
-0@@ -150,6 +150,25 @@ 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) +# Build Info: +# OPENSBI_BUILD_TIME_STAMP -- the compilation time stamp +# OPENSBI_BUILD_COMPILER_VERSION -- the compiler version info +BUILD_INFO ?= n +ifeq ($(BUILD_INFO),y) +OPENSBI_BUILD_DATE_FMT = +%Y-%m-%d-%H-%M-%S %Z
This hour/minute/second format seems uncommon. Also for %Z it is ambiguous and not better than %z, e.g.: CST could mean different time zones.
I would vote for: +%Y-%m-%d %H:%M:%S %z
Makefile endif · line 159
Quoted 1 line
Makefile +1
-0+ifdef SOURCE_DATE_EPOCH
With this approach, I don't think we need this BUILD_INFO=y thing, as this macro can be set by distributions to produce a reproducible build.
Quoted 92 lines
Makefile +24
-0+ OPENSBI_BUILD_TIME_STAMP ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" \ + "$(OPENSBI_BUILD_DATE_FMT)" 2>/dev/null || \ + date -u -r "$(SOURCE_DATE_EPOCH)" \ + "$(OPENSBI_BUILD_DATE_FMT)" 2>/dev/null || \ + date -u "$(OPENSBI_BUILD_DATE_FMT)") +else + OPENSBI_BUILD_TIME_STAMP ?= $(shell date "$(OPENSBI_BUILD_DATE_FMT)") +endif +OPENSBI_BUILD_COMPILER_VERSION=$(shell $(CC) -v 2>&1 | grep ' version ' | \ + sed 's/[[:space:]]*$$//') +endif + # Setup list of objects.mk files ifdef PLATFORM platform-object-mks=$(shell if [ -d $(platform_src_dir)/ ]; then find $(platform_src_dir) -iname "objects.mk" | sort -r; fi)@@ -247,6 +266,10 @@ GENFLAGS += -I$(include_dir) ifneq ($(OPENSBI_VERSION_GIT),) GENFLAGS += -DOPENSBI_VERSION_GIT="\"$(OPENSBI_VERSION_GIT)\"" endif +ifeq ($(BUILD_INFO),y) +GENFLAGS += -DOPENSBI_BUILD_TIME_STAMP="\"$(OPENSBI_BUILD_TIME_STAMP)\"" +GENFLAGS += -DOPENSBI_BUILD_COMPILER_VERSION="\"$(OPENSBI_BUILD_COMPILER_VERSION)\"" +endif GENFLAGS += $(libsbiutils-genflags-y) GENFLAGS += $(platform-genflags-y) GENFLAGS += $(firmware-genflags-y)@@ -398,6 +421,11 @@ $(build_dir)/%.dep: $(src_dir)/%.c $(build_dir)/%.o: $(src_dir)/%.c $(call compile_cc,$@,$<) +ifeq ($(BUILD_INFO),y) +$(build_dir)/lib/sbi/sbi_init.o: $(libsbi_dir)/sbi_init.c FORCE + $(call compile_cc,$@,$<) +endif + $(build_dir)/%.dep: $(src_dir)/%.S $(call compile_as_dep,$@,$<)@@ -551,3 +579,6 @@ ifeq ($(install_root_dir),$(install_root_dir_default)/usr) $(if $(V), @echo " RM $(install_root_dir_default)") $(CMD_PREFIX)rm -rf $(install_root_dir_default) endif + +.PHONY: FORCE +FORCE:README.md +23
-0@@ -254,6 +254,28 @@ to produce broken binaries with missing relocations; it is therefore currently recommended that this combination be avoided or *FW_PIC=n* be used to disable building OpenSBI as a position-independent binary. +Building with timestamp and compiler info +----------------------------------------- + +When doing development, we may want to know the build time and compiler info +for debug purpose. OpenSBI can also be built with timestamp and compiler info. +To build with those info and print it out at boot time, we can just simply add +`BUILD_INFO=y`, like: +``` +make BUILD_INFO=y +``` + +But if you have used `BUILD_INFO=y`, and want to switch back to `BUILD_INFO=n`, +you must do +``` +make clean +``` +before the next build. + +NOTE: Using `BUILD_INFO=y` will violate [reproducible builds]. This definition +is ONLY for development and debug purpose, and should NOT be used in a product +which follows "reproducible builds". + Contributing to OpenSBI -----------------------@@ -336,3 +358,4 @@ make I=<install_directory> install_docs [Doxygen manual]: http://www.doxygen.nl/manual/index.html [Kendryte standalone SDK]: https://github.com/kendryte/kendryte-standalone-sdk [third party notices]: ThirdPartyNotices.md +[reproducible builds]: https://reproducible-builds.orglib/sbi/sbi_init.c +1
-0@@ -48,6 +48,14 @@ static void sbi_boot_print_banner(struct sbi_scratch *scratch) OPENSBI_VERSION_MINOR);#endif +#ifdef OPENSBI_BUILD_TIME_STAMP
lib/sbi/sbi_init.c static void sbi_boot_print_banner(struct sbi_scratch *scratch) · line 61
Quoted 10 lines
lib/sbi/sbi_init.c +7
-0+sbi_printf ("Build time: %s\n" ,OPENSBI_BUILD_TIME_STAMP ); +#endif + +#ifdef OPENSBI_BUILD_COMPILER_VERSION +sbi_printf ("Build compiler: %s\n" ,OPENSBI_BUILD_COMPILER_VERSION ); +#endif +sbi_printf (BANNER ); }
Regards,
Bin
PATCH v4 1/1 Makefile: Add build time and compiler info string
Quoted 34 lines · Bin Meng
Hi Wei,
Quoted 30 lines · On Thu, Sep 30, 2021 at 6:12 PM <[email protected]> wrote:
From: Wei Fu <[email protected]>
When we are doing opensbi development, we want to know the build time and compiler info for debug purpose.
To enable this message, please add "BUILD_INFO=y", like:``` make BUILD_INFO=y ```NOTE:
BUILD_INFO=ywill violate "reproducible builds".
So it's ONLY for development and debug purpose, and should NOT be used in a product which follows "reproducible builds".Signed-off-by Wei Fu <[email protected]>---
Makefile | 31 +++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 62 insertions(+)Makefile +0
-0@@ -150,6 +150,25 @@ 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)
Quoted 10 lines
Makefile endif · line 158
Quoted 6 lines
Makefile +6
-0+# Build Info: +# OPENSBI_BUILD_TIME_STAMP -- the compilation time stamp +# OPENSBI_BUILD_COMPILER_VERSION -- the compiler version info +BUILD_INFO ?= n +ifeq ($(BUILD_INFO),y) +OPENSBI_BUILD_DATE_FMT = +%Y-%m-%d-%H-%M-%S %ZThis hour/minute/second format seems uncommon. Also for %Z it is ambiguous and not better than %z, e.g.: CST could mean different time zones.
-u is passed to date so it will always be UTC.
Jess
PATCH v4 1/1 Makefile: Add build time and compiler info string
Quoted 47 lines · Jessica Clarke
Quoted 34 lines · Bin Meng
Hi Wei,
Quoted 30 lines · On Thu, Sep 30, 2021 at 6:12 PM <[email protected]> wrote:
From: Wei Fu <[email protected]>
When we are doing opensbi development, we want to know the build time and compiler info for debug purpose.
To enable this message, please add "BUILD_INFO=y", like:``` make BUILD_INFO=y ```NOTE:
BUILD_INFO=ywill violate "reproducible builds".
So it's ONLY for development and debug purpose, and should NOT be used in a product which follows "reproducible builds".Signed-off-by Wei Fu <[email protected]>---
Makefile | 31 +++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 62 insertions(+)Makefile +0
-0@@ -150,6 +150,25 @@ 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)Quoted 10 lines
Makefile endif · line 158
Quoted 6 lines
Makefile +6
-0+# Build Info: +# OPENSBI_BUILD_TIME_STAMP -- the compilation time stamp +# OPENSBI_BUILD_COMPILER_VERSION -- the compiler version info +BUILD_INFO ?= n +ifeq ($(BUILD_INFO),y) +OPENSBI_BUILD_DATE_FMT = +%Y-%m-%d-%H-%M-%S %ZThis hour/minute/second format seems uncommon. Also for %Z it is ambiguous and not better than %z, e.g.: CST could mean different time zones.
Quoted 1 line
-u is passed to date so it will always be UTC.
... but only for the SOURCE_DATE_EPOCH case. So yeah, %z sounds better.
Jess
PATCH v4 1/1 Makefile: Add build time and compiler info string
Hi, Bin, Jessica
Quoted 49 lines · Jessica Clarke
Quoted 47 lines · Jessica Clarke
Quoted 44 lines · Bin Meng
Hi Wei,
Quoted 27 lines · On Thu, Sep 30, 2021 at 6:12 PM <[email protected]> wrote:
From: Wei Fu <[email protected]>
When we are doing opensbi development, we want to know the build time and compiler info for debug purpose.
To enable this message, please add "BUILD_INFO=y", like:``` make BUILD_INFO=y ```NOTE:
BUILD_INFO=ywill violate "reproducible builds".
So it's ONLY for development and debug purpose, and should NOT be used in a product which follows "reproducible builds".Signed-off-by Wei Fu <[email protected]>---
Makefile | 31 +++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 62 insertions(+)Makefile +0
-0Makefile endif · line 158
Quoted 9 lines
Makefile +6
-0@@ -150,6 +150,25 @@ 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) +# Build Info: +# OPENSBI_BUILD_TIME_STAMP -- the compilation time stamp +# OPENSBI_BUILD_COMPILER_VERSION -- the compiler version info +BUILD_INFO ?= n +ifeq ($(BUILD_INFO),y) +OPENSBI_BUILD_DATE_FMT = +%Y-%m-%d-%H-%M-%S %ZThis hour/minute/second format seems uncommon. Also for %Z it is ambiguous and not better than %z, e.g.: CST could mean different time zones.
Quoted 3 lines
Quoted 1 line
-u is passed to date so it will always be UTC.
... but only for the
SOURCE_DATE_EPOCHcase. So yeah, %z sounds better.
yes, I have tried it
OPENSBI_BUILD_DATE_FMT = +%Y-%m-%d %H:%M:%S %z
is better
will do.
Quoted 3 lines
Jess
PATCH v4 1/1 Makefile: Add build time and compiler info string
In reply to [email protected]Hi Wei Fu,
Quoted 11 lines · On Thu, Sep 30, 2021 at 3:41 PM <[email protected]> wrote:
From: Wei Fu <[email protected]>
When we are doing opensbi development, we want to know the build time and compiler info for debug purpose.
To enable this message, please add "BUILD_INFO=y", like:``` make BUILD_INFO=y ```
Quoted 5 lines
NOTE:
BUILD_INFO=ywill violate "reproducible builds".
So it's ONLY for development and debug purpose, and should NOT be used in a product which follows "reproducible builds".Signed-off-by Wei Fu <[email protected]>
I guess there is only one last comment to be addressed.
I can address it at the time of merging this patch ? OR
you can send V5 ?
Regards,
Anup
Quoted 131 lines
--- Makefile | 31 +++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 62 insertions(+)Makefile +31
-0@@ -150,6 +150,25 @@ 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) +# Build Info: +# OPENSBI_BUILD_TIME_STAMP -- the compilation time stamp +# OPENSBI_BUILD_COMPILER_VERSION -- the compiler version info +BUILD_INFO ?= n +ifeq ($(BUILD_INFO),y) +OPENSBI_BUILD_DATE_FMT = +%Y-%m-%d-%H-%M-%S %Z +ifdef SOURCE_DATE_EPOCH + OPENSBI_BUILD_TIME_STAMP ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" \ + "$(OPENSBI_BUILD_DATE_FMT)" 2>/dev/null || \ + date -u -r "$(SOURCE_DATE_EPOCH)" \ + "$(OPENSBI_BUILD_DATE_FMT)" 2>/dev/null || \ + date -u "$(OPENSBI_BUILD_DATE_FMT)") +else + OPENSBI_BUILD_TIME_STAMP ?= $(shell date "$(OPENSBI_BUILD_DATE_FMT)") +endif +OPENSBI_BUILD_COMPILER_VERSION=$(shell $(CC) -v 2>&1 | grep ' version ' | \ + sed 's/[[:space:]]*$$//') +endif + # Setup list of objects.mk files ifdef PLATFORM platform-object-mks=$(shell if [ -d $(platform_src_dir)/ ]; then find $(platform_src_dir) -iname "objects.mk" | sort -r; fi)@@ -247,6 +266,10 @@ GENFLAGS += -I$(include_dir) ifneq ($(OPENSBI_VERSION_GIT),) GENFLAGS += -DOPENSBI_VERSION_GIT="\"$(OPENSBI_VERSION_GIT)\"" endif +ifeq ($(BUILD_INFO),y) +GENFLAGS += -DOPENSBI_BUILD_TIME_STAMP="\"$(OPENSBI_BUILD_TIME_STAMP)\"" +GENFLAGS += -DOPENSBI_BUILD_COMPILER_VERSION="\"$(OPENSBI_BUILD_COMPILER_VERSION)\"" +endif GENFLAGS += $(libsbiutils-genflags-y) GENFLAGS += $(platform-genflags-y) GENFLAGS += $(firmware-genflags-y)@@ -398,6 +421,11 @@ $(build_dir)/%.dep: $(src_dir)/%.c $(build_dir)/%.o: $(src_dir)/%.c $(call compile_cc,$@,$<) +ifeq ($(BUILD_INFO),y) +$(build_dir)/lib/sbi/sbi_init.o: $(libsbi_dir)/sbi_init.c FORCE + $(call compile_cc,$@,$<) +endif + $(build_dir)/%.dep: $(src_dir)/%.S $(call compile_as_dep,$@,$<)@@ -551,3 +579,6 @@ ifeq ($(install_root_dir),$(install_root_dir_default)/usr) $(if $(V), @echo " RM $(install_root_dir_default)") $(CMD_PREFIX)rm -rf $(install_root_dir_default) endif + +.PHONY: FORCE +FORCE:README.md +23
-0@@ -254,6 +254,28 @@ to produce broken binaries with missing relocations; it is therefore currently recommended that this combination be avoided or *FW_PIC=n* be used to disable building OpenSBI as a position-independent binary. +Building with timestamp and compiler info +----------------------------------------- + +When doing development, we may want to know the build time and compiler info +for debug purpose. OpenSBI can also be built with timestamp and compiler info. +To build with those info and print it out at boot time, we can just simply add +`BUILD_INFO=y`, like: +``` +make BUILD_INFO=y +``` + +But if you have used `BUILD_INFO=y`, and want to switch back to `BUILD_INFO=n`, +you must do +``` +make clean +``` +before the next build. + +NOTE: Using `BUILD_INFO=y` will violate [reproducible builds]. This definition +is ONLY for development and debug purpose, and should NOT be used in a product +which follows "reproducible builds". + Contributing to OpenSBI -----------------------@@ -336,3 +358,4 @@ make I=<install_directory> install_docs [Doxygen manual]: http://www.doxygen.nl/manual/index.html [Kendryte standalone SDK]: https://github.com/kendryte/kendryte-standalone-sdk [third party notices]: ThirdPartyNotices.md +[reproducible builds]: https://reproducible-builds.orglib/sbi/sbi_init.c +8
-1@@ -48,6 +48,14 @@ static void sbi_boot_print_banner(struct sbi_scratch *scratch) OPENSBI_VERSION_MINOR);#endif +#ifdef OPENSBI_BUILD_TIME_STAMP +sbi_printf ("Build time: %s\n" ,OPENSBI_BUILD_TIME_STAMP ); +#endif + +#ifdef OPENSBI_BUILD_COMPILER_VERSION +sbi_printf ("Build compiler: %s\n" ,OPENSBI_BUILD_COMPILER_VERSION ); +#endif +sbi_printf (BANNER ); } --2.25.4
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi