Re: [PATCH] libtracefs: improve reproducibility
Steven Rostedt <[email protected]> Wed, 2 Apr 2025 21:45:57 -0400
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 24 Mar 2025 16:59:11 -0700 Oleh Matiusha <[email protected]> wrote: > Currently, the files generated by flex & bison are present among sources > to ease builds for people lacking these tools. However, make rules for them > are also present in Makefile, and while fetching source code, targets might > or might not be created with timestamps older than their prerequisites. > This means in build environments with flex and/or bison available, the > decision whether headers will be regenerated from sqlhist.l and sqlhist.y > is random. Since more fresh versions of these tools make different outputs, > this breaks build determinism, which is essential for people wanting their > builds to be reproducible. Assuming those who have their own flex & bison > want headers to be generated by fresh versions, I modified Makefile to check > for them and add corresponding targets to .PHONY to force re-generation, > retaining fallback option in case of their absence. > Thanks, it is annoying even if it tries to build them because of the way git handles timestamps. I think I rather just have the make targets for them be generated by a new main target. Something like this: diff --git a/Makefile b/Makefile index bd5c76bcd4f0..6e8022609ee7 100644 --- a/Makefile +++ b/Makefile @@ -400,6 +400,9 @@ sqlhist: samples/sqlhist samples: libtracefs.a force $(Q)$(call descend,$(src)/samples,all) +sqlhist_remake: + $(Q)$(call descend,$(src)/src,sqlhist_remake) + clean: clean_meson $(Q)$(call descend_clean,utest) $(Q)$(call descend_clean,src) diff --git a/src/Makefile b/src/Makefile index be81059ce10a..d981d802f8b1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -46,18 +46,20 @@ $(LIBTRACEFS_SHARED_SO): $(LIBTRACEFS_SHARED_VERSION) libtracefs.so: $(LIBTRACEFS_SHARED_SO) # bison will create both sqlhist.tab.c and sqlhist.tab.h -sqlhist.tab.h: -sqlhist.tab.c: sqlhist.y sqlhist.tab.h - bison --debug -v --report-file=bison.report -d -o $@ $< +sqlhist.tab_gen.h: +sqlhist.tab_gen.c: sqlhist.y sqlhist.tab.h + bison --debug -v --report-file=bison.report -d -o $(subst _gen,,$@) $< -sqlhist-lex.c: sqlhist.l sqlhist.tab.c - flex -o $@ $< +sqlhist-lex_gen.c: sqlhist.l sqlhist.tab.c + flex -o $(subst _gen,,$@) $< $(bdir)/%.o: %.c $(Q)$(call do_fpic_compile) tracefs-sqlhist.o: sqlhist.tab.h +sqlhist_remake: sqlhist.tab_gen.c sqlhist-lex_gen.c + $(OBJS): | $(bdir) clean: @@ -67,4 +69,4 @@ clean: $(bdir)/tracefs-sqlhist.o tracefs-sqlhist.o: sqlhist.tab.h -.PHONY: $(LIBTRACEFS_SHARED_SO) $(LIBTRACEFS_STATIC) +.PHONY: $(LIBTRACEFS_SHARED_SO) $(LIBTRACEFS_STATIC) sqlhist.tab_gen.c sqlhist-lex_gen.c Then we don't need to worry about these being built when they are not needed to be built. If the source files change, then you need to do: make sqlhist_remake to build it again. Thoughts, -- Steve