Add ENABLE_COVERAGE, for building a +Coverage (gcov) configuration.

- Required some extra makefile tweaks to introduce a new flag var
   which only goes to compile/link tools but not the relink step,
   otherwise we get a copy of libgcov in the relinked .o files.

 - No configure magic for this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66945 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-03-13 20:59:41 +00:00
parent 14ea1ec232
commit 55a07b20cd

View File

@ -282,6 +282,14 @@ ifndef REQUIRES_RTTI
# CXX.Flags += -fno-rtti # CXX.Flags += -fno-rtti
endif endif
ifdef ENABLE_COVERAGE
BuildMode := $(BuildMode)+Coverage
# These only go to .NoRelink because otherwise we will end up
# linking -lgcov into the .o libraries that get built.
CXX.Flags.NoRelink += -ftest-coverage -fprofile-arcs
C.Flags.NoRelink += -ftest-coverage -fprofile-arcs
endif
# If DISABLE_ASSERTIONS=1 is specified (make command line or configured), # If DISABLE_ASSERTIONS=1 is specified (make command line or configured),
# then disable assertions by defining the appropriate preprocessor symbols. # then disable assertions by defining the appropriate preprocessor symbols.
ifdef DISABLE_ASSERTIONS ifdef DISABLE_ASSERTIONS
@ -550,20 +558,26 @@ CPP.Flags += $(sort -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \
$(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \ $(LLVM_OBJ_ROOT) $(LLVM_SRC_ROOT))) \
$(CPP.BaseFlags) $(CPP.BaseFlags)
ifeq ($(BUILD_COMPONENT), 1) ifeq ($(BUILD_COMPONENT), 1)
Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c $(CompileCommonOpts) -c
Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \ $(CompileCommonOpts) -c
$(LD.Flags) $(Strip) Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) \
$(CXX.Flags.NoRelink) -E
Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
$(CompileCommonOpts) $(LD.Flags) $(Strip)
Relink = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \ Relink = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
$(Relink.Flags) $(Relink.Flags)
else else
Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \
Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) -c $(CompileCommonOpts) -c
Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \ $(CompileCommonOpts) -c
$(LD.Flags) $(Strip) Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) \
$(CXX.Flags.NoRelink) -E
Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \
$(CompileCommonOpts) $(LD.Flags) $(Strip)
Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \ Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) \
$(Relink.Flags) $(Relink.Flags)
endif endif