mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-05 23:22:46 +00:00
Tweaked generation of .cgi files, error code for recursion in stack.py
GCC is a bit annoying here, it can't generate .cgi files without generating the related .o files, though I suppose the alternative risks duplicating a large amount of compilation work (littlefs is really a small project). Previously we rebuilt the .o files anytime we needed .cgi files (callgraph info used for stack.py). This changes it so we always built .cgi files as a side-effect of compilation. This is similar to the .d file generation, though may be annoying if the system cc doesn't support --callgraph-info.
This commit is contained in:
19
Makefile
19
Makefile
@@ -60,7 +60,6 @@ override TESTFLAGS += -b
|
|||||||
override TESTFLAGS += $(filter -j%,$(MAKEFLAGS))
|
override TESTFLAGS += $(filter -j%,$(MAKEFLAGS))
|
||||||
ifdef VERBOSE
|
ifdef VERBOSE
|
||||||
override TESTFLAGS += -v
|
override TESTFLAGS += -v
|
||||||
override CALLSFLAGS += -v
|
|
||||||
override CODEFLAGS += -v
|
override CODEFLAGS += -v
|
||||||
override DATAFLAGS += -v
|
override DATAFLAGS += -v
|
||||||
override STACKFLAGS += -v
|
override STACKFLAGS += -v
|
||||||
@@ -77,7 +76,6 @@ override TESTFLAGS += --coverage
|
|||||||
endif
|
endif
|
||||||
ifdef BUILDDIR
|
ifdef BUILDDIR
|
||||||
override TESTFLAGS += --build-dir="$(BUILDDIR:/=)"
|
override TESTFLAGS += --build-dir="$(BUILDDIR:/=)"
|
||||||
override CALLSFLAGS += --build-dir="$(BUILDDIR:/=)"
|
|
||||||
override CODEFLAGS += --build-dir="$(BUILDDIR:/=)"
|
override CODEFLAGS += --build-dir="$(BUILDDIR:/=)"
|
||||||
override DATAFLAGS += --build-dir="$(BUILDDIR:/=)"
|
override DATAFLAGS += --build-dir="$(BUILDDIR:/=)"
|
||||||
override STACKFLAGS += --build-dir="$(BUILDDIR:/=)"
|
override STACKFLAGS += --build-dir="$(BUILDDIR:/=)"
|
||||||
@@ -108,10 +106,6 @@ size: $(OBJ)
|
|||||||
tags:
|
tags:
|
||||||
$(CTAGS) --totals --c-types=+p $(shell find -H -name '*.h') $(SRC)
|
$(CTAGS) --totals --c-types=+p $(shell find -H -name '*.h') $(SRC)
|
||||||
|
|
||||||
.PHONY: calls
|
|
||||||
calls: $(CGI)
|
|
||||||
./scripts/calls.py $^ $(CALLSFLAGS)
|
|
||||||
|
|
||||||
.PHONY: test_runner
|
.PHONY: test_runner
|
||||||
test_runner: $(BUILDDIR)runners/test_runner
|
test_runner: $(BUILDDIR)runners/test_runner
|
||||||
|
|
||||||
@@ -172,19 +166,14 @@ $(BUILDDIR)lfs.csv: $(OBJ) $(CGI)
|
|||||||
$(BUILDDIR)runners/test_runner: $(TEST_TAOBJ)
|
$(BUILDDIR)runners/test_runner: $(TEST_TAOBJ)
|
||||||
$(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
|
$(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
|
||||||
|
|
||||||
$(BUILDDIR)%.o: %.c
|
# our main build rule generates .o, .d, and .ci files, the latter
|
||||||
$(CC) -c -MMD $(CFLAGS) $< -o $@
|
# used for stack analysis
|
||||||
|
$(BUILDDIR)%.o $(BUILDDIR)%.ci: %.c
|
||||||
|
$(CC) -c -MMD -fcallgraph-info=su $(CFLAGS) $< -o $(BUILDDIR)$*.o
|
||||||
|
|
||||||
$(BUILDDIR)%.s: %.c
|
$(BUILDDIR)%.s: %.c
|
||||||
$(CC) -S $(CFLAGS) $< -o $@
|
$(CC) -S $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
# gcc depends on the output file for intermediate file names, so
|
|
||||||
# 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 $|
|
|
||||||
|
|
||||||
$(BUILDDIR)%.a.c: %.c
|
$(BUILDDIR)%.a.c: %.c
|
||||||
./scripts/explode_asserts.py $< -o $@
|
./scripts/explode_asserts.py $< -o $@
|
||||||
|
|
||||||
|
|||||||
@@ -384,6 +384,11 @@ def main(**args):
|
|||||||
print_entries(by='name')
|
print_entries(by='name')
|
||||||
print_totals()
|
print_totals()
|
||||||
|
|
||||||
|
# catch recursion
|
||||||
|
if args.get('error_on_recursion') and any(
|
||||||
|
m.isinf(limit) for _, _, _, limit, _ in results):
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import argparse
|
import argparse
|
||||||
@@ -424,6 +429,8 @@ if __name__ == "__main__":
|
|||||||
help="Show file-level calls.")
|
help="Show file-level calls.")
|
||||||
parser.add_argument('-Y', '--summary', action='store_true',
|
parser.add_argument('-Y', '--summary', action='store_true',
|
||||||
help="Only show the total stack size.")
|
help="Only show the total stack size.")
|
||||||
|
parser.add_argument('-e', '--error-on-recursion', action='store_true',
|
||||||
|
help="Error if any functions are recursive.")
|
||||||
parser.add_argument('--build-dir',
|
parser.add_argument('--build-dir',
|
||||||
help="Specify the relative build directory. Used to map object files \
|
help="Specify the relative build directory. Used to map object files \
|
||||||
to the correct source files.")
|
to the correct source files.")
|
||||||
|
|||||||
Reference in New Issue
Block a user