diff options
| author | Zach Clark <zach@ibm.com> | 2019-05-01 11:18:13 -0500 |
|---|---|---|
| committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2019-05-13 09:10:45 -0500 |
| commit | 6a2bedba84d0cc0b4a8837341e516a491218b729 (patch) | |
| tree | 97b465ab89b43692408a5d2329ff7fdb6a65f185 /src/build/mkrules | |
| parent | 06d0a08aa27fa9e28cc300fbd2814fd9b84d59cf (diff) | |
| download | talos-hostboot-6a2bedba84d0cc0b4a8837341e516a491218b729.tar.gz talos-hostboot-6a2bedba84d0cc0b4a8837341e516a491218b729.zip | |
Developer Improvement: Get code coverage tool working with Hostboot
This commit fixes GCOV code coverage for P9 with GCC 4.9.2
Change-Id: Ie1e7c35f67414531dbd6e7a771ac1529a9ebd59d
RTC: 208351
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/76812
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/build/mkrules')
| -rw-r--r-- | src/build/mkrules/cc.rules.mk | 33 | ||||
| -rw-r--r-- | src/build/mkrules/gcov.env.mk | 50 |
2 files changed, 68 insertions, 15 deletions
diff --git a/src/build/mkrules/cc.rules.mk b/src/build/mkrules/cc.rules.mk index c89995f82..584b11db4 100644 --- a/src/build/mkrules/cc.rules.mk +++ b/src/build/mkrules/cc.rules.mk @@ -5,7 +5,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2013,2017 +# Contributors Listed Below - COPYRIGHT 2013,2019 # [+] International Business Machines Corp. # # @@ -31,11 +31,27 @@ $(OBJDIR)/%.list : $(OBJDIR)/%.o $(C2) " OBJDUMP $(notdir $<)" $(C1)$(OBJDUMP) -rdlCS $< > $@ +# SOURCE_FILE and INCLUDE_DIRS are variables that are either absolute +# paths to the .C file being compiled and the include directories if +# we're building with gcov, or else they are relative paths +# otherwise. The key thing to remember is that they are lazily +# expanded, so they're relevant to whatever rule they're used in. We +# don't want to always have absolute paths because of build +# performance and because it causes the build output with +# BUILD_VERBOSE to be larger and less readable. +ifdef HOSTBOOT_PROFILE +SOURCE_FILE=$(shell readlink -f $<) +INCLUDE_DIRS=$(shell $(ROOTPATH)/src/build/tools/cflags.sh $(INCFLAGS)) +else +SOURCE_FILE=$< +INCLUDE_DIRS=$(INCFLAGS) +endif + $(OBJDIR)/%.o : %.C @mkdir -p $(OBJDIR) $(C2) " CXX $(notdir $<)" - $(C1)$(CXX) -c $(call FLAGS_FILTER, $(CXXFLAGS), $<) $< \ - -o $@.trace $(INCFLAGS) -iquote . + $(C1)$(CXX) -c $(call FLAGS_FILTER, $(CXXFLAGS), $<) $(SOURCE_FILE) \ + -o $@.trace $(INCLUDE_DIRS) -iquote . $(C1)$(TRACE_HASHER) $@ $(TRACE_FLAGS) @rm $@.trace @@ -43,7 +59,8 @@ $(OBJDIR)/%.o : %.C $(OBJDIR)/%.o : %.cc @mkdir -p $(OBJDIR) $(C2) " CXX $(notdir $<)" - $(C1)$(CXX) -c $(CXXFLAGS) $< -o $@.trace $(INCFLAGS) -iquote . + $(C1)$(CXX) -c $(CXXFLAGS) $(SOURCE_FILE) -o $@.trace \ + $(INCLUDE_DIRS) -iquote . $(C1)$(TRACE_HASHER) $@ $(TRACE_FLAGS) @rm $@.trace @@ -54,12 +71,12 @@ $(OBJDIR)/%.o : %.c # CC_OVERRIDE is set in the makefile of the component ifndef CC_OVERRIDE $(C2) " CC $(notdir $<)" - $(C1)$(CC) -c $(call FLAGS_FILTER, $(CFLAGS), $<) $< \ - -o $@.trace $(INCFLAGS) -iquote . + $(C1)$(CC) -c $(call FLAGS_FILTER, $(CFLAGS), $<) $(SOURCE_FILE) \ + -o $@.trace $(INCLUDE_DIRS) -iquote . else $(C2) " CXX $(notdir $<)" - $(C1)$(CXX) -c $(call FLAGS_FILTER, $(CXXFLAGS), $<) $< \ - -o $@.trace $(INCFLAGS) -iquote . + $(C1)$(CXX) -c $(call FLAGS_FILTER, $(CXXFLAGS), $<) $(SOURCE_FILE) \ + -o $@.trace $(INCLUDE_DIRS) -iquote . endif $(C1)$(TRACE_HASHER) $@ $(TRACE_FLAGS) @rm $@.trace diff --git a/src/build/mkrules/gcov.env.mk b/src/build/mkrules/gcov.env.mk index 8ddcd3ef6..edce52a24 100644 --- a/src/build/mkrules/gcov.env.mk +++ b/src/build/mkrules/gcov.env.mk @@ -5,7 +5,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2013,2014 +# Contributors Listed Below - COPYRIGHT 2013,2019 +# [+] International Business Machines Corp. +# # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,21 +28,44 @@ # Configuration of the GCOV settings. GCOVDIR = $(ROOTPATH)/obj/gcov +vpath %.C $(ROOTPATH)/src/sys/prof ifdef MODULE -GCOVNAME = $(MODULE).lcov + +# Don't profile HBRT modules to keep size down +ifdef HOSTBOOT_RUNTIME +HOSTBOOT_PROFILE= +endif + +## We don't want certain modules to be profiled (HBB, HBRT). + +# This is replacing spaces with colons so that we can get an exact +# match on the module name in the list of unprofilable modules with +# findstring, which otherwise would find matches on "partial" +# substrings (i.e. we don't want to deprofile module ABC just because +# module ABCD is blacklisted, so we create a blacklist of modules +# separated by colons and search for :ABC:). +null := +MODULE_PROFILE_BLACKLIST:=:$(subst ${null} ${null},:,$(BASE_MODULES_GCOV_BLACKLIST) $(RUNTIME_MODULES_GCOV_BLACKLIST)): + +ifneq (,$(findstring :$(MODULE):,$(MODULE_PROFILE_BLACKLIST))) +HOSTBOOT_PROFILE= +endif + +GCOVNAME := $(MODULE).lcov + ifndef TESTS ifdef HOSTBOOT_PROFILE -vpath %.C $(ROOTPATH)/src/sys/prof OBJS := gcov.o $(OBJS) endif endif else -GCOVNAME = $(notdir $(shell pwd)).lcov +GCOVNAME := $(notdir $(shell pwd)).lcov endif -## Disable coverage on test cases, any directory that sets -## HOSTBOOT_PROFILE_NO_INSTRUMENT or any file that has 'gcov' in the name. +## Disable coverage on test cases or any directory that sets +## HOSTBOOT_PROFILE_NO_INSTRUMENT + ifndef TESTS ifdef HOSTBOOT_PROFILE ifndef HOSTBOOT_PROFILE_NO_INSTRUMENT @@ -59,5 +84,16 @@ endif ## Reduce the optimization level when profiling is enabled to ensure the ## base image fits in 512k still. ifdef HOSTBOOT_PROFILE -OPT_LEVEL = -Os +# We're not doing this right now because it causes linker errors in +# various parts of hostboot with or without gcov (i.e. functions that +# the code relies on being inlined are not; some const statics that +# aren't defined in a compilation unit have linker references, etc.) +# and it also causes the image to be generated incorrectly (symbol +# names are wrong, calls to functions named things like __savegpr_rXX +# are emitted but the functions themselves aren't and so you end up +# jumping into an area of zeroes, ...). We should come back to this +# later and fix, we might be able to profile more of hostboot with the +# space savings that -Os could give. + +#OPT_LEVEL = -Os endif |

