I'm learning GN and my sample project has a static library (libhello.a) that depends on a single c++ file (libhello.cc).
ninja --version gives me 1.9.0, so I'm on the newest released version with sub-second timestamp accuracy.
The generated ninja script for this target looks like this:
defines =
include_dirs = -I../../../libhello/include
cflags = -ffunction-sections -fdata-sections -Wall -Wextra -pedantic -O0 -g
cflags_cc = -std=c++14
target_out_dir = obj/libhello
target_output_name = libhello
build obj/libhello/libhello.hello.o: cxx ../../../libhello/hello.cc
build obj/libhello/libhello.a: alink obj/libhello/libhello.hello.o
arflags =
output_extension = .a
output_dir =
My "alink" tool is simple, doesn't use response files, just
rule alink
command = rm -f ${out} && ar rcs ${out} ${in}
description = ar ${target_output_name}${output_extension}
When I run my build on mac ("ninja -C out/tmp/debug"), all of my targets build as expected, and I see my files. libhello.hello.o and libhello.a have the exact same timestamp though. When I run again, ninja sees all of my static library targets as dirty and re-archives them, then re-links everything downstream of them. This wasn't necessary; everything was already built and I haven't touched any files since the last run.
Instead, if I build once and then run "ninja -d explain", I see the following:
/Users/nicholsonc/src/gntest: ./b -- -d explain
ninja: Entering directory `/Users/nicholsonc/src/gntest/out/tmp/debug'
ninja explain: output obj/libhello/libhello.a older than most recent input obj/libhello/libhello.hello.o (1568060338000000000 vs 1568060338064635267)
ninja explain: obj/libhello/libhello.a is dirty
libhello.a looks like it has an extremely suspicious timestamp to me, the final 9 digits are all zeroes. I suspect that its actual timestamp is a hair above that of libhello.hello.o, and something's truncating it down, which moves the timestamp to before the .o file.
I see this phenomenon across all of my static library targets, not just this one. The .a files have truncated timestamp files, and the .o files have high-precision ones.
Am I doing something wrong here? This is low enough in the implementation guts of ninja and maybe GN that I'm not sure exactly what the next step is, other than recompiling the ninja code and adding some printf debug statements that spit out the timestamps.
Thanks in advance for any advice,
Charles