[PATCH] uadk: Fix compilation issues when the __DATE__ and __TIME__ macros

From: lizhi <lizhi206@huawei.com> On some Ubuntu systems, the gcc compiler disables the DATE and TIME macros via the -Wdate-time flag during compilation. To ensure the compilation timestamp feature remains functional, this issue is addressed through the Makefile. Signed-off-by: Longfang Liu <liulongfang@huawei.com> --- uadk_tool/Makefile.am | 6 ++++++ uadk_tool/dfx/uadk_dfx.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/uadk_tool/Makefile.am b/uadk_tool/Makefile.am index 6fd9d95..9ae9fd7 100644 --- a/uadk_tool/Makefile.am +++ b/uadk_tool/Makefile.am @@ -1,10 +1,16 @@ ACLOCAL_AMFLAGS = -I m4 -I./include AUTOMAKE_OPTIONS = foreign subdir-objects + +# get UADK build time +BUILD_DATETIME := $(shell date -u +"%Y-%m-%d_%H:%M:%S") + AM_CFLAGS=-Wall -Werror -fno-strict-aliasing -I$(top_srcdir) -I$(top_srcdir)/benchmark/include \ -pthread AM_CFLAGS += -fPIC -fPIE -pie -fstack-protector-strong -D_FORTIFY_SOURCE=2 \ -O2 -ftrapv -Wl,-z,now -Wl,-s +AM_CFLAGS += -DUADK_BUILD_DATETIME=\"$(BUILD_DATETIME)\" + #AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS=uadk_tool diff --git a/uadk_tool/dfx/uadk_dfx.c b/uadk_tool/dfx/uadk_dfx.c index 9c54b7b..8afcb15 100644 --- a/uadk_tool/dfx/uadk_dfx.c +++ b/uadk_tool/dfx/uadk_dfx.c @@ -14,7 +14,11 @@ #include "include/wd.h" #include "uadk_dfx.h" -#define uadk_build_date() printf("built on: %s %s\n", __DATE__, __TIME__) +#ifndef UADK_BUILD_DATETIME +#define UADK_BUILD_DATETIME "unknown" +#endif + +#define uadk_build_date() printf("built on: %s\n", UADK_BUILD_DATETIME) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define PRIVILEGE_FLAG 0666 -- 2.33.0
participants (1)
-
Qi Tao