copy nsec of mtime in CopyStat #380

Closed
opened 2026-01-29 20:43:00 +00:00 by claunia · 4 comments
Owner

Originally created by @JackJey on GitHub (Mar 8, 2021).

when using brotli command in Makefile, it doesn't build incrementally but always re-compress full files again.
this is caused by compare time difference includes nsec of mtime, current brotli cli implementation doesn't copy nsec of mtime.

https://github.com/google/brotli/blob/master/c/tools/brotli.c#L661-L662

It's welcome to include nsec of mtime when copy file stat will solve incremental build by Make. it always compress when files are updated.

Originally created by @JackJey on GitHub (Mar 8, 2021). when using brotli command in Makefile, it doesn't build incrementally but always re-compress full files again. this is caused by compare time difference includes nsec of mtime, current brotli cli implementation doesn't copy nsec of mtime. https://github.com/google/brotli/blob/master/c/tools/brotli.c#L661-L662 It's welcome to include nsec of mtime when copy file stat will solve incremental build by Make. it always compress when files are updated.
Author
Owner

@eustas commented on GitHub (Mar 24, 2021):

Hmm. Let's take a look how this is done in other compressors, e.g. zlib...

@eustas commented on GitHub (Mar 24, 2021): Hmm. Let's take a look how this is done in other compressors, e.g. zlib...
Author
Owner

@pirxpilot commented on GitHub (May 1, 2022):

If you are here looking for help with your Makefiles this seems to do the trick:

%.br: %
    brotli --best --force --keep --output=$@ $<
    touch --reference $< $@

touch will update the timestamp from a source file and that will stop make from trying to re-brotlify the same file over and over again

And yeah - some other compressors have the same problem:

$ stat -c "%y %n" History.md*
2022-05-01 10:13:20.795119946 +0200 History.md
2022-05-01 10:13:20.000000000 +0200 History.md.br
2022-05-01 10:13:20.000000000 +0200 History.md.bz2
2022-05-01 10:13:20.795119946 +0200 History.md.gz
2022-05-01 10:13:20.000000000 +0200 History.md.lz
@pirxpilot commented on GitHub (May 1, 2022): If you are here looking for help with your Makefiles this seems to do the trick: ```Makefile %.br: % brotli --best --force --keep --output=$@ $< touch --reference $< $@ ``` `touch` will update the timestamp from a source file and that will stop `make` from trying to re-brotlify the same file over and over again And yeah - some other compressors have the same problem: ``` $ stat -c "%y %n" History.md* 2022-05-01 10:13:20.795119946 +0200 History.md 2022-05-01 10:13:20.000000000 +0200 History.md.br 2022-05-01 10:13:20.000000000 +0200 History.md.bz2 2022-05-01 10:13:20.795119946 +0200 History.md.gz 2022-05-01 10:13:20.000000000 +0200 History.md.lz ```
Author
Owner

@eustas commented on GitHub (May 1, 2022):

Will take a look soon. Thanks for the heads-up.

@eustas commented on GitHub (May 1, 2022): Will take a look soon. Thanks for the heads-up.
Author
Owner

@eustas commented on GitHub (Jan 3, 2023):

Should be somewhat addressed with #992

@eustas commented on GitHub (Jan 3, 2023): Should be somewhat addressed with #992
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#380