]> git.hungrycats.org Git - bees/commitdiff
build: rebuild bees and its tests when localconf changes
authorZygo Blaxell <bees@furryterror.org>
Mon, 24 Aug 2026 20:42:54 +0000 (16:42 -0400)
committerZygo Blaxell <bees@furryterror.org>
Tue, 6 Oct 2026 05:51:40 +0000 (01:51 -0400)
Same fix as the lib commit "crucible: rebuild when localconf changes",
applied to src/Makefile and test/Makefile: ../localconf overrides CC,
CXX and CCFLAGS but was not a prerequisite of anything built with them,
so editing it recompiled nothing and left the tree able to link objects
from two compilers.

Both files gain BUILD_CONF and use it wherever ../makeflags appeared in a
prerequisite list, including the link rules in test/Makefile, and the
.dep rules that previously depended on neither file.

Assisted-by: Claude-Code:claude-opus-5
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/Makefile
test/Makefile

index 8862a32c2e6c48ae6fb5e8cb7384cd541436963b..e23e05bc5932c61a2acc93d62368883b667e8d35 100644 (file)
@@ -5,6 +5,16 @@ all: $(BEES)
 include ../makeflags
 -include ../localconf
 
+# Files that decide which compiler runs and with which flags.  Anything built
+# by that compiler is stale when they change, so they belong in prerequisite
+# lists -- objects record nothing about the toolchain that produced them, and
+# mixing two toolchains in one tree fails in ways that never mention compilers
+# (under -flto, "plugin needed to handle lto object").
+#
+# localconf is optional and has no rule to create it, so name it only when it
+# exists: an unconditional prerequisite would make it an error not to have one.
+BUILD_CONF = ../makeflags $(wildcard ../localconf)
+
 LIBS = -lcrucible -lpthread -latomic
 BEES_LDFLAGS = -L../lib $(LDFLAGS)
 
@@ -38,15 +48,19 @@ bees-usage.c: bees-usage.txt Makefile
        (echo 'const char *BEES_USAGE = '; sed -r 's/^(.*)$$/"\1\\n"/' < bees-usage.txt; echo ';') > bees-usage.new.c
        mv -f bees-usage.new.c bees-usage.c
 
-%.dep: %.cc Makefile
+# The generated dependencies name the compiler's own header paths, so they are
+# stale after a toolchain switch too.  These files are `include'd, not
+# `-include'd: a dep left pointing at headers the new compiler does not ship
+# would stop the build with "No rule to make target", not just miss a rebuild.
+%.dep: %.cc Makefile $(BUILD_CONF)
        $(CXX) $(BEES_CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $<
 
 include $(ALL_OBJS:%.o=%.dep)
 
-%.o: %.c ../makeflags
+%.o: %.c $(BUILD_CONF)
        $(CC) $(BEES_CFLAGS) -o $@ -c $<
 
-%.o: %.cc ../makeflags
+%.o: %.cc $(BUILD_CONF)
        $(CXX) $(BEES_CXXFLAGS) -o $@ -c $<
 
 $(BEES): $(BEES_OBJS) bees-version.o bees-usage.o ../lib/libcrucible.a
index 8a65142c7bb95594e228722a66d6190773d0e4e1..99899c23e05e6b0878b6a71d2b23ad5a0f1c1687 100644 (file)
@@ -29,21 +29,35 @@ FORCE:
 include ../makeflags
 -include ../localconf
 
+# Files that decide which compiler runs and with which flags.  Anything built
+# by that compiler is stale when they change, so they belong in prerequisite
+# lists -- objects record nothing about the toolchain that produced them, and
+# mixing two toolchains in one tree fails in ways that never mention compilers
+# (under -flto, "plugin needed to handle lto object").
+#
+# localconf is optional and has no rule to create it, so name it only when it
+# exists: an unconditional prerequisite would make it an error not to have one.
+BUILD_CONF = ../makeflags $(wildcard ../localconf)
+
 LIBS = -lcrucible -lpthread -latomic
 BEES_LDFLAGS = -L../lib $(LDFLAGS)
 
-%.dep: %.cc tests.h Makefile
+# The generated dependencies name the compiler's own header paths, so they are
+# stale after a toolchain switch too.  These files are `include'd, not
+# `-include'd: a dep left pointing at headers the new compiler does not ship
+# would stop the build with "No rule to make target", not just miss a rebuild.
+%.dep: %.cc tests.h Makefile $(BUILD_CONF)
        $(CXX) $(BEES_CXXFLAGS) -M -MF $@ -MT $(<:.cc=.o) $<
 
 include $(PROGRAMS:%=%.dep)
 
-$(PROGRAMS:%=%.o): %.o: %.cc ../makeflags Makefile
+$(PROGRAMS:%=%.o): %.o: %.cc $(BUILD_CONF) Makefile
        $(CXX) $(BEES_CXXFLAGS) -o $@ -c $<
 
-$(NORMAL_PROGRAMS): %: %.o ../makeflags Makefile ../lib/libcrucible.a
+$(NORMAL_PROGRAMS): %: %.o $(BUILD_CONF) Makefile ../lib/libcrucible.a
        $(CXX) $(BEES_CXXFLAGS) $(BEES_LDFLAGS) -o $@ $< $(LIBS)
 
-config-parse: config-parse.o ../src/bees-config.cc ../src/bees-trace.cc ../src/bees-log.cc ../src/bees-lib.cc ../makeflags Makefile ../lib/libcrucible.a
+config-parse: config-parse.o ../src/bees-config.cc ../src/bees-trace.cc ../src/bees-log.cc ../src/bees-lib.cc $(BUILD_CONF) Makefile ../lib/libcrucible.a
        $(CXX) $(BEES_CXXFLAGS) -ffunction-sections -fdata-sections $(BEES_LDFLAGS) -Wl,--gc-sections -o $@ config-parse.o ../src/bees-config.cc ../src/bees-trace.cc ../src/bees-log.cc ../src/bees-lib.cc $(LIBS)
 
 %.txt: % Makefile FORCE