From 97e217b0ff998c1bc11455ca2409abd3549ed5b6 Mon Sep 17 00:00:00 2001 From: Alan Carvalho de Assis Date: Fri, 22 Mar 2024 13:02:59 -0300 Subject: [PATCH] libc/uname: Add option to disable uname timestamp Don't include the build timestamp into final binary when the symbol CONFIG_LIBC_UNAME_DISABLE_TIMESTAMP is defined. Signed-off-by: Alan C. Assis --- libs/libc/misc/Kconfig | 9 +++++++++ libs/libc/misc/Make.defs | 2 ++ libs/libc/misc/lib_utsname.c | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/libc/misc/Kconfig b/libs/libc/misc/Kconfig index f94e97f7769..6227d520fb0 100644 --- a/libs/libc/misc/Kconfig +++ b/libs/libc/misc/Kconfig @@ -81,6 +81,15 @@ config LIBC_FTOK_VFS_PATH ---help--- The relative path to where ftok will exist in the root namespace. +config LIBC_UNAME_DISABLE_TIMESTAMP + bool "Disable uname timestamp support" + default n + ---help--- + Currently uname command will print the timestamp + when the binary was built, and it generates an issue + because two identical built binaries will have differents + hashes/CRC. + choice prompt "Select memfd implementation" diff --git a/libs/libc/misc/Make.defs b/libs/libc/misc/Make.defs index a9e6e97ede1..c3d19570f7f 100644 --- a/libs/libc/misc/Make.defs +++ b/libs/libc/misc/Make.defs @@ -79,7 +79,9 @@ endif # To ensure uname information is newest, # add lib_utsname.o to phony target for force rebuild +#if !defined(CONFIG_LIBC_UNAME_DISABLE_TIMESTAMP) .PHONY: lib_utsname$(OBJEXT) +#endif # Add the misc directory to the build diff --git a/libs/libc/misc/lib_utsname.c b/libs/libc/misc/lib_utsname.c index 6bfe7961862..2ae7064f327 100644 --- a/libs/libc/misc/lib_utsname.c +++ b/libs/libc/misc/lib_utsname.c @@ -93,7 +93,8 @@ int uname(FAR struct utsname *name) strlcpy(name->release, CONFIG_VERSION_STRING, sizeof(name->release)); -#if defined(__DATE__) && defined(__TIME__) +#if defined(__DATE__) && defined(__TIME__) && \ + !defined(CONFIG_LIBC_UNAME_DISABLE_TIMESTAMP) snprintf(name->version, VERSION_NAMELEN, "%s %s %s", CONFIG_VERSION_BUILD, __DATE__, __TIME__); #else