Add profile guided optimisation to build configuration (profile/profiled)

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-11-30 14:59:24 +00:00
parent 6a065dd405
commit 033969bbe3
6 changed files with 45 additions and 18 deletions

View File

@ -1,21 +1,36 @@
.PHONY: all .PHONY: all
all: opt all: opt
.PHONY: opt
opt: opt:
$(MAKE) -C src opt $(MAKE) -C src opt
$(MAKE) -C Z80/src opt $(MAKE) -C Z80/src opt
$(MAKE) -C Z80/test opt $(MAKE) -C Z80/test opt
.PHONY: debug
debug: debug:
$(MAKE) -C src debug $(MAKE) -C src debug
$(MAKE) -C Z80/src debug $(MAKE) -C Z80/src debug
$(MAKE) -C Z80/test debug $(MAKE) -C Z80/test debug
.PHONY: coverage
coverage: coverage:
$(MAKE) -C src coverage $(MAKE) -C src coverage
$(MAKE) -C Z80/src coverage $(MAKE) -C Z80/src coverage
$(MAKE) -C Z80/test coverage $(MAKE) -C Z80/test coverage
.PHONY: profile
profile:
$(MAKE) -C src profile
$(MAKE) -C Z80/src profile
$(MAKE) -C Z80/test profile
.PHONY: profiled
profiled:
$(MAKE) -C src profiled
$(MAKE) -C Z80/src profiled
$(MAKE) -C Z80/test profiled
.PHONY: clean .PHONY: clean
clean: clean:
$(MAKE) -C src clean $(MAKE) -C src clean

View File

@ -4,4 +4,5 @@ CXXFLAGS = -I ../inc -I ../../inc
CXXFILES = Disassembler.cpp Profiler.cpp Z80.cpp CXXFILES = Disassembler.cpp Profiler.cpp Z80.cpp
include ../../compile.mk
include ../../lib_build.mk include ../../lib_build.mk

9
compile.mk Normal file
View File

@ -0,0 +1,9 @@
CXXFLAGS += -g -Wall -std=c++14 -pipe
#CXXFLAGS_OPT = -DNDEBUG -march=native -Ofast -flto
CXXFLAGS_OPT = -DNDEBUG -march=native -Ofast
CXXFLAGS_DEBUG = -D_DEBUG
CXXFLAGS_COVERAGE = $(CXXFLAGS_DEBUG) -fprofile-arcs -ftest-coverage
CXXFLAGS_PROFILE = $(CXXFLAGS_OPT) -fprofile-generate
CXXFLAGS_PROFILED = $(CXXFLAGS_OPT) -fprofile-use

View File

@ -1,5 +1,3 @@
CXXFLAGS += -g -Wall -std=c++14 -pipe
CXXOBJECTS = $(CXXFILES:.cpp=.o) CXXOBJECTS = $(CXXFILES:.cpp=.o)
SOURCES = $(CXXFILES) SOURCES = $(CXXFILES)
@ -7,22 +5,25 @@ OBJECTS = $(CXXOBJECTS)
PCH = stdafx.h.gch PCH = stdafx.h.gch
.PHONY: all
all: opt all: opt
.PHONY: opt opt: CXXFLAGS += $(CXXFLAGS_OPT)
opt: CXXFLAGS += -DNDEBUG -march=native -O3 -flto
opt: $(EXE) opt: $(EXE)
.PHONY: debug debug: CXXFLAGS += $(CXXFLAGS_DEBUG)
debug: CXXFLAGS += -D_DEBUG
debug: $(EXE) debug: $(EXE)
.PHONY: coverage coverage: CXXFLAGS += $(CXXFLAGS_COVERAGE)
coverage: CXXFLAGS += -D_DEBUG -fprofile-arcs -ftest-coverage
coverage: LDFLAGS += -lgcov coverage: LDFLAGS += -lgcov
coverage: $(EXE) coverage: $(EXE)
profile: CXXFLAGS += $(CXXFLAGS_PROFILE)
profile: LDFLAGS += -lgcov
profile: $(EXE)
profiled: CXXFLAGS += $(CXXFLAGS_PROFILED)
profiled: $(EXE)
$(PCH): stdafx.h $(PCH): stdafx.h
$(CXX) $(CXXFLAGS) -x c++-header $< $(CXX) $(CXXFLAGS) -x c++-header $<

View File

@ -1,5 +1,3 @@
CXXFLAGS += -g -Wall -std=c++14 -pipe
CXXOBJECTS = $(CXXFILES:.cpp=.o) CXXOBJECTS = $(CXXFILES:.cpp=.o)
SOURCES = $(CXXFILES) SOURCES = $(CXXFILES)
@ -7,21 +5,23 @@ OBJECTS = $(CXXOBJECTS)
PCH = stdafx.h.gch PCH = stdafx.h.gch
.PHONY: all
all: opt all: opt
.PHONY: opt opt: CXXFLAGS += $(CXXFLAGS_OPT)
opt: CXXFLAGS += -DNDEBUG -march=native -O3 -flto
opt: $(LIB) opt: $(LIB)
.PHONY: debug debug: CXXFLAGS += $(CXXFLAGS_DEBUG)
debug: CXXFLAGS += -D_DEBUG
debug: $(LIB) debug: $(LIB)
.PHONY: coverage coverage: CXXFLAGS += $(CXXFLAGS_COVERAGE)
coverage: CXXFLAGS += -D_DEBUG -fprofile-arcs -ftest-coverage
coverage: $(LIB) coverage: $(LIB)
profile: CXXFLAGS += $(CXXFLAGS_PROFILE)
profile: $(LIB)
profiled: CXXFLAGS += $(CXXFLAGS_PROFILED)
profiled: $(LIB)
$(PCH): stdafx.h $(PCH): stdafx.h
$(CXX) $(CXXFLAGS) -x c++-header $< $(CXX) $(CXXFLAGS) -x c++-header $<

View File

@ -4,4 +4,5 @@ CXXFLAGS = -I ../inc
CXXFILES = Bus.cpp EventArgs.cpp InputOutput.cpp IntelProcessor.cpp Memory.cpp Processor.cpp CXXFILES = Bus.cpp EventArgs.cpp InputOutput.cpp IntelProcessor.cpp Memory.cpp Processor.cpp
include ../compile.mk
include ../lib_build.mk include ../lib_build.mk