Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: support PROFILING and TIMED like coq_makefile #777

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ compcert/test/
*.vos
*.vok
*.glob
*.timing
*.prof.json
*.prof.json.gz
*.v.d
.depend
.loadpath
Expand Down
36 changes: 34 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,37 @@ DEPFLAGS:=$(COQFLAGS)

COQFLAGS+=$(COQEXTRAFLAGS)

PROFILING?=

ifneq (,$(PROFILING))
# does this coq version dupport -profile ? (Coq >= 8.19)
ifeq (,$(shell "$(COQBIN)coqc" -profile /dev/null 2>&1))
PROFILE_FLAGS+=-profile $<.prof.json
PROFILE_ZIP = gzip -f $<.prof.json
else
endif
endif
PROFILE_FLAGS ?=
PROFILE_ZIP ?= true

TIMED?=

# Use command time on linux, gtime on Mac OS
TIMEFMT?="$(if $(findstring undefined, $(flavor 1)),$@,$(1)) (real: %e, user: %U, sys: %S, mem: %M ko)"
ifneq (,$(TIMED))
ifeq (0,$(shell command time -f "" true >/dev/null 2>/dev/null; echo $$?))
STDTIME?=command time -f $(TIMEFMT)
else
ifeq (0,$(shell gtime -f "" true >/dev/null 2>/dev/null; echo $$?))
STDTIME?=gtime -f $(TIMEFMT)
else
STDTIME?=command time
endif
endif
else
STDTIME?=command time -f $(TIMEFMT)
endif

# ##### Print configuration summary #####

$(info ===== CONFIGURATION SUMMARY =====)
Expand Down Expand Up @@ -696,15 +727,15 @@ IRIS_INSTALL_FILES=$(sort $(IRIS_INSTALL_FILES_SRC) $(IRIS_INSTALL_FILES_VO))

# This line sets COQF depending on the folder of the input file $<
# If the folder name contains compcert, $(COMPCERT_R_FLAGS) is added, otherwise not.
%.vo: COQF=$(if $(findstring $(COMPCERT_SRC_DIR), $(dir $<)), $(COMPCERT_R_FLAGS) $(COQEXTRAFLAGS), $(COQFLAGS))
%.vo: COQF=$(if $(findstring $(COMPCERT_SRC_DIR), $(dir $<)), $(COMPCERT_R_FLAGS) $(COQEXTRAFLAGS), $(COQFLAGS) $(PROFILE_FLAGS))

# If CompCert changes, all .vo files need to be recompiled
%.vo: $(COMPCERT_CONFIG)

%.vo: %.v
@echo COQC $*.v
ifneq (,$(TIMING))
@$(COQC) $(COQF) -time $*.v > $<.timing
@$(if $(TIMED),$(STDTIME)) $(COQC) $(COQF) -time $*.v > $<.timing
else ifeq ($(TIMINGS), true)
# bash -c "wc $*.v >>timings; date +'%s.%N before' >> timings; $(COQC) $(COQF) $*.v; date +'%s.%N after' >>timings" 2>>timings
@bash -c "/usr/bin/time --output=TIMINGS -a -f '%e real, %U user, %S sys %M mem, '\"$(shell wc $*.v)\" $(COQC) $(COQF) $*.v"
Expand All @@ -721,6 +752,7 @@ else
@$(COQC) $(COQF) $*.v
# @util/annotate $(COQC) $(COQF) $*.v
endif
@$(PROFILE_ZIP)


# ########## Targets ##########
Expand Down
Loading