Makefile: Add build time and compiler info string.
PATCH v3 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 | 22 ++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 53 insertions(+)
Makefile +22 -0
@@ -150,6 +150,15 @@ 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_TIME_STAMP=$(shell date) +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 +256,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 +411,12 @@ $(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,$@,$<) + $(warning 'BUILD_INFO=y' violates 'reproducible builds', for DEBUG ONLY.) +endif + $(build_dir)/%.dep: $(src_dir)/%.S $(call compile_as_dep,$@,$<)
@@ -551,3 +570,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 v3 1/1 Makefile: Add build time and compiler info string.
Quoted 26 lines · tekkamanninja at gmail.com
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 | 22 ++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 53 insertions(+)Makefile +0
-0
Makefile endif · line 158
Quoted 9 lines
Makefile +6
-0@@ -150,6 +150,15 @@ 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_TIME_STAMP=$(shell date)
Can you use this instead to get the time?
https://reproducible-builds.org/docs/source-date-epoch/
There is a Makefile section there you can copy.
Quoted 21 lines
Makefile +3
-0+OPENSBI_BUILD_COMPILER_VERSION=$(shell $(CC) -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$$//') +endif + # Setup list of objects.mk filesifdef PLATFORM
platform-object-mks=$(shell if [ -d $(platform_src_dir)/ ]; then find $(platform_src_dir) -iname "objects.mk" | sort -r; fi)Makefile +0
-0@@ -247,6 +256,10 @@ GENFLAGS += -I$(include_dir) ifneq ($(OPENSBI_VERSION_GIT),)GENFLAGS += -DOPENSBI_VERSION_GIT="\"$(OPENSBI_VERSION_GIT)\"" endif
Makefile +4
-0+ifeq ($(BUILD_INFO),y) +GENFLAGS += -DOPENSBI_BUILD_TIME_STAMP="\"$(OPENSBI_BUILD_TIME_STAMP)\"" +GENFLAGS += -DOPENSBI_BUILD_COMPILER_VERSION="\"$(OPENSBI_BUILD_COMPILER_VERSION)\"" +endifGENFLAGS += $(libsbiutils-genflags-y)
GENFLAGS += $(platform-genflags-y)
GENFLAGS += $(firmware-genflags-y)Makefile +0
-0@@ -398,6 +411,12 @@ $(build_dir)/%.dep: $(src_dir)/%.c$(build_dir)/%.o: $(src_dir)/%.c
$(call compile_cc,$@,$<)
Quoted 4 lines
+ifeq ($(BUILD_INFO),y)
+$(build_dir)/lib/sbi/sbi_init.o: $(libsbi_dir)/sbi_init.c FORCE
+ $(call compile_cc,$@,$<)
+ $(warning 'BUILD_INFO=y' violates 'reproducible builds', for DEBUG ONLY.)
You don't really need this warning either.
Otherwise looks good! Thanks for addressing the comments.
Alistair
Quoted 73 lines
Makefile +2
-0+endif +$(build_dir)/%.dep: $(src_dir)/%.S
$(call compile_as_dep,$@,$<)Makefile +0
-0@@ -551,3 +570,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
Makefile +3
-0+ +.PHONY: FORCE +FORCE:README.md +0
-0@@ -254,6 +254,28 @@ to produce broken binaries with missing relocations; it is therefore currentlyrecommended that this combination be avoided or *FW_PIC=n* be used to disable building OpenSBI as a position-independent binary.
README.md +22
-0+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
-----------------------README.md +0
-0@@ -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
-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 v3 1/1 Makefile: Add build time and compiler info string.
Hi Alistair
Great thanks for you review :-)
Alistair <[email protected]> ?2021?9?30??? ??8:43???
Quoted 40 lines · tekkamanninja at gmail.com
Quoted 26 lines
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 | 22 ++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 53 insertions(+)Makefile +0
-0Makefile endif · line 158
Quoted 9 lines
Makefile +6
-0@@ -150,6 +150,15 @@ 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_TIME_STAMP=$(shell date)Can you use this instead to get the time?
Quoted 3 lines
https://reproducible-builds.org/docs/source-date-epoch/
There is a
Makefilesection there you can copy.
Sure, will follow it in next version of this patch:-)
Quoted 22 lines
Quoted 22 lines
Makefile +3
-0+OPENSBI_BUILD_COMPILER_VERSION=$(shell $(CC) -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$$//') +endif + # Setup list of objects.mk filesifdef PLATFORM
platform-object-mks=$(shell if [ -d $(platform_src_dir)/ ]; then find $(platform_src_dir) -iname "objects.mk" | sort -r; fi)Makefile +0
-0@@ -247,6 +256,10 @@ GENFLAGS += -I$(include_dir) ifneq ($(OPENSBI_VERSION_GIT),)GENFLAGS += -DOPENSBI_VERSION_GIT="\"$(OPENSBI_VERSION_GIT)\"" endif
Makefile +4
-0+ifeq ($(BUILD_INFO),y) +GENFLAGS += -DOPENSBI_BUILD_TIME_STAMP="\"$(OPENSBI_BUILD_TIME_STAMP)\"" +GENFLAGS += -DOPENSBI_BUILD_COMPILER_VERSION="\"$(OPENSBI_BUILD_COMPILER_VERSION)\"" +endifGENFLAGS += $(libsbiutils-genflags-y)
GENFLAGS += $(platform-genflags-y)
GENFLAGS += $(firmware-genflags-y)Makefile +0
-0@@ -398,6 +411,12 @@ $(build_dir)/%.dep: $(src_dir)/%.c$(build_dir)/%.o: $(src_dir)/%.c
$(call compile_cc,$@,$<)
Quoted 6 lines
Quoted 4 lines
+ifeq ($(BUILD_INFO),y)
+$(build_dir)/lib/sbi/sbi_init.o: $(libsbi_dir)/sbi_init.c FORCE
+ $(call compile_cc,$@,$<)
+ $(warning 'BUILD_INFO=y' violates 'reproducible builds', for DEBUG ONLY.)You don't really need this warning either.
sure , will delete it
Quoted 78 lines
Otherwise looks good! Thanks for addressing the comments.
Alistair
Quoted 73 lines
Makefile +2
-0+endif +$(build_dir)/%.dep: $(src_dir)/%.S
$(call compile_as_dep,$@,$<)Makefile +0
-0@@ -551,3 +570,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
Makefile +3
-0+ +.PHONY: FORCE +FORCE:README.md +0
-0@@ -254,6 +254,28 @@ to produce broken binaries with missing relocations; it is therefore currentlyrecommended that this combination be avoided or *FW_PIC=n* be used to disable building OpenSBI as a position-independent binary.
README.md +22
-0+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
-----------------------README.md +0
-0@@ -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
PATCH v3 1/1 Makefile: Add build time and compiler info string.
In reply to [email protected]Quoted 15 lines · On Thu, Sep 30, 2021 at 2:06 AM <[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".
Quoted 7 lines
Signed-off-by Wei Fu <[email protected]>--- Makefile | 22 ++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 53 insertions(+)
It looks my comments to v1 still remains unchanged
Regards,
Bin
PATCH v3 1/1 Makefile: Add build time and compiler info string.
Hi Bin,
Bin Meng <[email protected]> ?2021?9?30??? ??9:09???
Quoted 25 lines · On Thu, Sep 30, 2021 at 2:06 AM <[email protected]> wrote:
Quoted 15 lines
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".Quoted 7 lines
Signed-off-by Wei Fu <[email protected]>--- Makefile | 22 ++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 53 insertions(+)
Quoted 1 line
It looks my comments to v1 still remains unchanged
Thanks for reminding me, will fix it :-)
Quoted 3 lines
Regards,
Bin
PATCH v3 1/1 Makefile: Add build time and compiler info string.
In reply to [email protected]? 2021-09-30???? 02:05 +0800?tekkamanninja at gmail.com???
Quoted 139 lines
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?????????? | 22 ++++++++++++++++++++++ ?README.md????????? | 23 +++++++++++++++++++++++ ?lib/sbi/sbi_init.c |? 8 ++++++++?3 files changed, 53 insertions(+)
Makefile +0
-0@@ -150,6 +150,15 @@ 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/nullQuoted 1 line
/dev/null2>&1 && echo y || echo n)?
Makefile +7
-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_TIME_STAMP=$(shell date) +OPENSBI_BUILD_COMPILER_VERSION=$(shell $(CC) -v 2>&1 | grep 'version ' | sed 's/[[:space:]]*$$//')
Makefile +2
-0+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)Makefile +0
-0@@ -247,6 +256,10 @@ GENFLAGS???+=??????-I$(include_dir) ?ifneq ($(OPENSBI_VERSION_GIT),)?GENFLAGS???????+=??????-
DOPENSBI_VERSION_GIT="\"$(OPENSBI_VERSION_GIT)\""
?endifMakefile +2
-0+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)Makefile +0
-0@@ -398,6 +411,12 @@ $(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,$@,$<)
+???????$(warning 'BUILD_INFO=y' violates 'reproducible builds', for DEBUG ONLY.)Makefile +2
-0+endif +?$(build_dir)/%.dep: $(src_dir)/%.S
????????$(call compile_as_dep,$@,$<)
?Makefile +0
-0@@ -551,3 +570,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
Makefile +3
-0+ +.PHONY: FORCE +FORCE:README.md +0
-0@@ -254,6 +254,28 @@ to produce broken binaries with missingrelocations; 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.
?README.md +4
-0+Building with timestamp and compiler info +------------------------ + +When doing development, we may want to know the build time andcompiler 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:
+```README.md +4
-0+make BUILD_INFO=y +``` + +But if you have used `BUILD_INFO=y`, and want to switch back to
BUILD_INFO=n,README.md +7
-0+you must do +``` +make clean +``` +before the next build. + +NOTE: Using `BUILD_INFO=y` will violate [reproducible builds]. Thisdefinition
+is ONLY for development and debug purpose, and should NOT be used in a productREADME.md +2
-0+which follows "reproducible builds". +?Contributing to OpenSBI
?-----------------------
?README.md +0
-0@@ -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 +0
-0@@ -48,6 +48,14 @@ static void sbi_boot_print_banner(struct sbi_scratch *scratch) ?????????????????? OPENSBI_VERSION_MINOR);?#endif
?
lib/sbi/sbi_init.c static void sbi_boot_print_banner(struct sbi_scratch *scratch) · line 53
Quoted 3 lines
lib/sbi/sbi_init.c +3
-0+#ifdef OPENSBI_BUILD_TIME_STAMP +???????sbi_printf("Build time: %s.\n", OPENSBI_BUILD_TIME_STAMP); +#endif
It is recommended to add a print commit id
Regards,
Xiang W
Quoted 13 lines
lib/sbi/sbi_init.c +3
-0+ +#ifdef OPENSBI_BUILD_COMPILER_VERSION +???????sbi_printf("Build compiler: %s.\n",
OPENSBI_BUILD_COMPILER_VERSION);lib/sbi/sbi_init.c +2
-0+#endif +????????sbi_printf(BANNER);
?}
?Signature · 1 line
2.25.4
PATCH v3 1/1 Makefile: Add build time and compiler info string.
Hi Xiang,
Xiang W <[email protected]> ?2021?9?30??? ??9:58???
Quoted 141 lines
? 2021-09-30???? 02:05 +0800?tekkamanninja at gmail.com???
Quoted 139 lines
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 | 22 ++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 53 insertions(+)Makefile +0
-0@@ -150,6 +150,15 @@ 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/nullQuoted 1 line
/dev/null2>&1 && echo y || echo n)Makefile +7
-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_TIME_STAMP=$(shell date) +OPENSBI_BUILD_COMPILER_VERSION=$(shell $(CC) -v 2>&1 | grep 'version ' | sed 's/[[:space:]]*$$//')
Makefile +2
-0+endif + # Setup list of objects.mk files ifdef PLATFORM platform-object-mks=$(shell if [ -d $(platform_src_dir)/ ]; thenfind $(platform_src_dir) -iname "objects.mk" | sort -r; fi)
Makefile +0
-0@@ -247,6 +256,10 @@ GENFLAGS += -I$(include_dir) ifneq ($(OPENSBI_VERSION_GIT),) GENFLAGS += -DOPENSBI_VERSION_GIT="\"$(OPENSBI_VERSION_GIT)\""
endifMakefile +2
-0+ifeq ($(BUILD_INFO),y) +GENFLAGS += -DOPENSBI_BUILD_TIME_STAMP="\"$(OPENSBI_BUILD_TIME_STAMP)\""
+GENFLAGS += -
DOPENSBI_BUILD_COMPILER_VERSION="\"$(OPENSBI_BUILD_COMPILER_VERSION)\
""Makefile +10
-0+endif GENFLAGS += $(libsbiutils-genflags-y) GENFLAGS += $(platform-genflags-y) GENFLAGS += $(firmware-genflags-y)@@ -398,6 +411,12 @@ $(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,$@,$<) + $(warning 'BUILD_INFO=y' violates 'reproducible builds', for DEBUG ONLY.) +endif + $(build_dir)/%.dep: $(src_dir)/%.S $(call compile_as_dep,$@,$<)@@ -551,3 +570,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 +0
-0@@ -254,6 +254,28 @@ to produce broken binaries with missingrelocations; 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.README.md +4
-0+Building with timestamp and compiler info +------------------------ + +When doing development, we may want to know the build time andcompiler 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:
+```README.md +4
-0+make BUILD_INFO=y +``` + +But if you have used `BUILD_INFO=y`, and want to switch back to
BUILD_INFO=n,README.md +7
-0+you must do +``` +make clean +``` +before the next build. + +NOTE: Using `BUILD_INFO=y` will violate [reproducible builds]. Thisdefinition
+is ONLY for development and debug purpose, and should NOT be used in a productREADME.md +2
-0+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 +0
-0@@ -48,6 +48,14 @@ static void sbi_boot_print_banner(struct sbi_scratch *scratch) OPENSBI_VERSION_MINOR);#endif
Quoted 4 lines
lib/sbi/sbi_init.c static void sbi_boot_print_banner(struct sbi_scratch *scratch) · line 53
Quoted 3 lines
lib/sbi/sbi_init.c +3
-0+#ifdef OPENSBI_BUILD_TIME_STAMP +sbi_printf ("Build time: %s.\n" ,OPENSBI_BUILD_TIME_STAMP ); +#endif It is recommended to add a print commit id
yes, we already have it above, please check "OPENSBI_VERSION_GIT"
Quoted 23 lines
Regards,
Xiang WQuoted 9 lines
lib/sbi/sbi_init.c +5
-0+ +#ifdef OPENSBI_BUILD_COMPILER_VERSION +sbi_printf ("Build compiler: %s.\n" ,OPENSBI_BUILD_COMPILER_VERSION ); +#endif +sbi_printf (BANNER );}
Quoted 4 lines
--
2.25.4--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi