# Having to do this in a kernel build is simply annoying

So there are some macros, __DATE__ and __TIME__ that the gcc compiler knows about. And some people inject these into their kernel module builds, because, well, why not. The issue is that they can make “reproducible builds” harder. Well, no, they really don’t. That’s a side issue.
And of course, modern kernel builds use -Wall -Werror which converts warnings like
macro "__TIME__" might prevent reproducible builds [-Werror=date-time]
into real honest-to-goodness errors. Ok, they aren’t real errors. Its just a compiler being somewhat pissy with me. And I had to work around it. I could disable the -Wall -Werror, but that is not what I wanted to do.
So I hand-preprocessed the code. In the makefile include. Before starting the compile.
Because.

__D__=$(shell date +%x) __T__=$(shell date +%R)
target_prep: source.c
sed -i 's|__DATE__|"${__D__}"|g' source.c sed -i 's|__TIME__|"${__T__}"|g' source.c
touch target_prep


Which, I dunno … sorta … kinda … blows chunks … mebbe ? Working around an issue by not fixing what was broke, but instead introducing a new path so I don’t subvert the intentions of the kernel build system?

### 2 thoughts on “Having to do this in a kernel build is simply annoying”

1. Adding -D__DATE__=\${__D__}, etc. to CPPFLAGS works, too. Redefinition warnings, sure, but you can add -Wno-builtin-macro-redefined as well.

• I’d thought of that, but I am trying to avoid messing with the internals of the kernel build system (I could have also used a -Wno-error=date-time). For it is fragile and quick to anger.