Fixed spurious CI failure caused by multiple writers to .o files
GCC is a bit frustrating here, it really wants to generate every file in a single command, which _is_ more efficient if our build system could leverage this. But -fcallgraph-info is a rather novel flag, so we can't really rely on it for generally compiling and testing littlefs. The multi-file output gets in the way when we want an explicitly separate rule for callgraph-info generation. We can't generate the callgraph-info without generating the objects files. This becomes a surprsing issue when parallel building (make -j) is used! Suddenly we might end up with both the .o and .ci rules writing to .o files, which creates a really difficult to track down issue of corrupted .o files. The temporary solution is to use an order-only prerequisite. This still ends up building the .o files twice, but it's an acceptable tradeoff for not requiring the -fcallgraph-info for all builds.
This commit is contained in:
@@ -124,16 +124,8 @@ coverage:
|
|||||||
./scripts/coverage.py $(BUILDDIR)tests/*.toml.info -s $(COVERAGEFLAGS)
|
./scripts/coverage.py $(BUILDDIR)tests/*.toml.info -s $(COVERAGEFLAGS)
|
||||||
|
|
||||||
.PHONY: summary
|
.PHONY: summary
|
||||||
summary: $(OBJ) $(CGI)
|
summary: $(BUILDDIR)lfs.csv
|
||||||
$(strip \
|
./scripts/summary.py -Y $^ $(SUMMARYFLAGS)
|
||||||
./scripts/code.py $(OBJ) -q -o - $(CODEFLAGS) \
|
|
||||||
| ./scripts/data.py $(OBJ) -q -m - -o - $(DATAFLAGS) \
|
|
||||||
| ./scripts/stack.py $(CGI) -q -m - -o - $(STACKFLAGS) \
|
|
||||||
| ./scripts/structs.py $(OBJ) -q -m - -o - $(STRUCTFLAGS) \
|
|
||||||
$(if $(COVERAGE),\
|
|
||||||
| ./scripts/coverage.py $(BUILDDIR)tests/*.toml.info \
|
|
||||||
-q -m - -o - $(COVERAGEFLAGS)) \
|
|
||||||
| ./scripts/summary.py -Y $(SUMMARYFLAGS))
|
|
||||||
|
|
||||||
|
|
||||||
# rules
|
# rules
|
||||||
@@ -147,15 +139,13 @@ $(BUILDDIR)lfs.a: $(OBJ)
|
|||||||
$(AR) rcs $@ $^
|
$(AR) rcs $@ $^
|
||||||
|
|
||||||
$(BUILDDIR)lfs.csv: $(OBJ) $(CGI)
|
$(BUILDDIR)lfs.csv: $(OBJ) $(CGI)
|
||||||
$(strip \
|
./scripts/code.py $(OBJ) -q $(CODEFLAGS) -o $@
|
||||||
./scripts/code.py $(OBJ) -q -o - $(CODEFLAGS) \
|
./scripts/data.py $(OBJ) -q -m $@ $(DATAFLAGS) -o $@
|
||||||
| ./scripts/data.py $(OBJ) -q -m - -o - $(DATAFLAGS) \
|
./scripts/stack.py $(CGI) -q -m $@ $(STACKFLAGS) -o $@
|
||||||
| ./scripts/stack.py $(CGI) -q -m - -o - $(STACKFLAGS) \
|
./scripts/structs.py $(OBJ) -q -m $@ $(STRUCTSFLAGS) -o $@
|
||||||
| ./scripts/structs.py $(OBJ) -q -m - -o - $(STRUCTFLAGS) \
|
$(if $(COVERAGE),\
|
||||||
$(if $(COVERAGE),\
|
./scripts/coverage.py $(BUILDDIR)tests/*.toml.info \
|
||||||
| ./scripts/coverage.py $(BUILDDIR)tests/*.toml.info \
|
-q -m $@ $(COVERAGEFLAGS) -o $@)
|
||||||
-q -m - -o - $(COVERAGEFLAGS)) \
|
|
||||||
> $@)
|
|
||||||
|
|
||||||
$(BUILDDIR)%.o: %.c
|
$(BUILDDIR)%.o: %.c
|
||||||
$(CC) -c -MMD $(CFLAGS) $< -o $@
|
$(CC) -c -MMD $(CFLAGS) $< -o $@
|
||||||
@@ -163,8 +153,12 @@ $(BUILDDIR)%.o: %.c
|
|||||||
$(BUILDDIR)%.s: %.c
|
$(BUILDDIR)%.s: %.c
|
||||||
$(CC) -S $(CFLAGS) $< -o $@
|
$(CC) -S $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
$(BUILDDIR)%.ci: %.c
|
# gcc depends on the output file for intermediate file names, so
|
||||||
$(CC) -c -MMD -fcallgraph-info=su $(CFLAGS) $< -o $(@:.ci=.o)
|
# we can't omit to .o output. We also need to serialize with the
|
||||||
|
# normal .o rule because otherwise we can end up with multiprocess
|
||||||
|
# problems with two instances of gcc modifying the same .o
|
||||||
|
$(BUILDDIR)%.ci: %.c | $(BUILDDIR)%.o
|
||||||
|
$(CC) -c -MMD -fcallgraph-info=su $(CFLAGS) $< -o $|
|
||||||
|
|
||||||
# clean everything
|
# clean everything
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|||||||
Reference in New Issue
Block a user