uboot中使用 __DATE__ __TIME__ 等时间宏

error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]

这是因为uboot打开了 -Werror=date-time 宏:

# Prohibit date/time macros, which would make the build non-deterministic
KBUILD_CFLAGS   += $(call cc-option,-Werror=date-time)

详见:

[PATCH 7/7] Makefile: Build with -Werror=date-time if the compilersupports it

如果想在uboot中使用构建时间的话,网上大多数的方法是将 KBUILD_CFLAGS += $(call cc-option,-Werror=date-time)删除,但其实uboot在构建时已经在include/generated/timestamp_autogenerated.h中记录了这些信息了,更好的方式是通过引用该文件的宏来代替 __DATE__ __TIME__ __TIMESTAMP__

注意:include/generated/timestamp_autogenerated.h文件是编译时生成文件,只有在编译过一次后才会生成。

参考链接:

https://blog.csdn.net/feiyangyangfei/article/details/79957551

posted @ 2023-05-12 16:27  江子无怒  阅读(0)  评论(0)    收藏  举报  来源