You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/03/23 03:42:27 UTC

(nuttx) branch master updated: libc/uname: Add option to disable uname timestamp

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 97e217b0ff libc/uname: Add option to disable uname timestamp
97e217b0ff is described below

commit 97e217b0ff998c1bc11455ca2409abd3549ed5b6
Author: Alan Carvalho de Assis <ac...@gmail.com>
AuthorDate: Fri Mar 22 13:02:59 2024 -0300

    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 <ac...@gmail.com>
---
 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 f94e97f776..6227d520fb 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 a9e6e97ede..c3d19570f7 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 6bfe796186..2ae7064f32 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