Merged parallel-fixes branch

This separates out the rules for %.d files from the rules that
create the related target file (%.o etc).  Doing this can reduce
the amount of work to be done when rebuilding applications after
making source changes.  For files in O.Common which can be built
by any target architecture this can solve problems when parallel
builds (-j) are used.
This commit is contained in:
Andrew Johnson
2012-04-06 16:13:22 -05:00
9 changed files with 119 additions and 61 deletions

View File

@@ -30,7 +30,7 @@ DIVIDER = .
CROSS1 = $(CROSS_COMPILER_TARGET_ARCHS$(word 1,$(CROSS_COMPILER_HOST_ARCHS)))
# CROSS2 will be defined only when CROSS_COMPILER_HOST_ARCHS is defined
# and EPICS_HOST_ARCH is one of it's words
# and EPICS_HOST_ARCH is one of its words
CROSS2 = $(CROSS_COMPILER_TARGET_ARCHS$(filter-out 1,$(words $(filter $(EPICS_HOST_ARCH),$(CROSS_COMPILER_HOST_ARCHS)))))
BUILD_ARCHS = $(EPICS_HOST_ARCH) $(CROSS1) $(CROSS2)
@@ -272,11 +272,11 @@ INCLUDES = -I. $(SRC_INCLUDES) $(INSTALL_INCLUDES) $(RELEASE_INCLUDES)\
CFLAGS = $($(BUILD_CLASS)_CFLAGS) $(POSIX_CFLAGS) $(OPT_CFLAGS) $(DEBUG_CFLAGS)\
$(PIPE_CFLAGS) $(WARN_CFLAGS) $(TARGET_CFLAGS) $(USR_CFLAGS) $(ARCH_DEP_CFLAGS)\
$(CODE_CFLAGS) $(STATIC_CFLAGS) $(OP_SYS_CFLAGS) $(LIBRARY_SRC_CFLAGS) $(HDEPENDS_CFLAGS)
$(CODE_CFLAGS) $(STATIC_CFLAGS) $(OP_SYS_CFLAGS) $(LIBRARY_SRC_CFLAGS)
CXXFLAGS = $($(BUILD_CLASS)_CXXFLAGS) $(POSIX_CXXFLAGS) $(OPT_CXXFLAGS) $(DEBUG_CXXFLAGS)\
$(PIPE_CFLAGS) $(WARN_CXXFLAGS) $(TARGET_CXXFLAGS) $(USR_CXXFLAGS) $(ARCH_DEP_CXXFLAGS)\
$(CODE_CXXFLAGS) $(STATIC_CXXCFLAGS) $(OP_SYS_CXXFLAGS) $(LIBRARY_SRC_CFLAGS) $(HDEPENDS_CFLAGS)
$(CODE_CXXFLAGS) $(STATIC_CXXCFLAGS) $(OP_SYS_CXXFLAGS) $(LIBRARY_SRC_CFLAGS)
LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS) $(POSIX_LDFLAGS) \
$(ARCH_DEP_LDFLAGS) $(DEBUG_LDFLAGS) $(OP_SYS_LDFLAGS) $($(BUILD_CLASS)_LDFLAGS)\
@@ -326,15 +326,16 @@ HDEPENDS_METHOD = CMD
HDEPENDS_INCLUDES = $(subst -I,,$(INCLUDES))
HDEPENDSFLAGS = -m $*$(DEP) $(HDEPENDS_INCLUDES) $@ $<
HDEPENDSCMD = -$(MKMF) $(HDEPENDS_FLAGS) $(HDEPENDSFLAGS)
HDEPENDS_CMD_NO = $(ECHO) ""
HDEPENDS_CMD_YES = $(if $(filter CMD,$(HDEPENDS_METHOD)),$(HDEPENDSCMD),$(HDEPENDS_CMD_NO))
HDEPENDS_CMD = $(HDEPENDS_CMD_$(HDEPENDS))
HDEPENDS_CMD_YES = $(MKMF) $(HDEPENDS_FLAGS) $(HDEPENDSFLAGS)
HDEPENDSCFLAGS = -MMD
HDEPENDS_CFLAGS_YES = $(if $(filter CFLAGS,$(HDEPENDS_METHOD)),$(HDEPENDSCFLAGS))
HDEPENDS_CFLAGS = $(HDEPENDS_CFLAGS_$(HDEPENDS))
HDEPENDSCFLAGS = -MM > $*$(DEP)
HDEPSUFFIX = $(if $(filter .c,$(suffix $<)),.c,.cpp)
HDEPENDS_CFLAGS_NO = $(ECHO) ""
HDEPENDS_CFLAGS_YES = $(COMPILE$(HDEPSUFFIX)) $(HDEPENDSCFLAGS) $<
HDEPENDS_CMD = $(HDEPENDS_$(HDEPENDS_METHOD)_$(HDEPENDS))
#--------------------------------------------------
# depends definition
@@ -342,7 +343,7 @@ HDEPENDS_CFLAGS = $(HDEPENDS_CFLAGS_$(HDEPENDS))
TARGET_SRCS = $(foreach name, $(TESTPROD) $(PROD) $(TESTLIBRARY) $(LIBRARY) $(LOADABLE_LIBRARY), $($(name)_SRCS))
SRC_FILES = $(LIB_SRCS) $(LIBSRCS) $(SRCS) $(USR_SRCS) $(PROD_SRCS) $(TARGET_SRCS)
HDEPENDS_FILES_YES = $(addsuffix $(DEP),$(notdir $(basename $(SRC_FILES))))
HDEPENDS_FILES = $(if $(filter NO,$(HDEPENDS)),,$(HDEPENDS_FILES_YES))
HDEPENDS_FILES = $(HDEPENDS_FILES_$(HDEPENDS))
#---------------------------------------------------------------
# Names of installed items

View File

@@ -90,6 +90,8 @@ endif
INSTALL_DB_INSTALLS = $(addprefix $(INSTALL_DB)/,$(notdir $(DB_INSTALLS)))
INSTALL_DBD_INSTALLS = $(addprefix $(INSTALL_DBD)/,$(notdir $(DBD_INSTALLS)))
COMMONDEP_TARGET = $(COMMON_DIR)/$(basename $@)
##################################################### acf files
# An access security configuration file, *.acf, can be created from
# an *.acs file (has format of acf file plus #include "filename" lines)
@@ -100,7 +102,7 @@ ACF_CPPFLAGS = $(ACF_CPPFLAGS_$(GNU))
ACF_INCLUDES = -I. $(TARGET_INCLUDES) $(USR_INCLUDES)\
$(SRC_INCLUDES) -I$(INSTALL_DB)
ACFDEPENDS_CMD = -$(MKMF) -m $(notdir $@)$(DEP) $(subst -I,,$(ACF_INCLUDES)) $@ $<
ACFDEPENDS_CMD = $(MKMF) -m $@ $(subst -I,,$(ACF_INCLUDES)) $(COMMONDEP_TARGET) $<
ACF_CMD = $(CPP) $(ACF_CPPFLAGS) $(ACF_INCLUDES) $< > $@
##################################################### dependancies
@@ -110,7 +112,8 @@ COMMON_DBDINC += $(addprefix $(COMMON_DIR)/,$(HINC))
DBDDEPENDS_FILES += $(addsuffix $(DEP),$(HINC) \
$(patsubst $(COMMON_DIR)/%,%,$(COMMON_DBS)) \
$(patsubst $(COMMON_DIR)/%,%,$(COMMON_DBDS)))
$(patsubst $(COMMON_DIR)/%,%, \
$(filter-out $(COMMON_DIR)/bpt%.dbd,$(COMMON_DBDS))))
MAKEDBDEPENDS = $(PERL) $(TOOLS)/makeDbDepends.pl
@@ -159,8 +162,6 @@ ifneq (,$(strip $(DBDDEPENDS_FILES)))
-include $(DBDDEPENDS_FILES)
endif
$(DBDDEPENDS_FILES):
##################################################### build dependancies, clean rule
inc : $(COMMON_INC) $(INSTALL_INC)
@@ -181,6 +182,51 @@ db_clean :
realclean: clean
##################################################### Dependency files
%Record.h$(DEP): $(COMMON_DIR)/%Record.dbd
@$(RM) $@
@$(DBTORECORDTYPEH) -D $(DBDFLAGS) -o $(COMMONDEP_TARGET) $< > $@
@echo "$(COMMONDEP_TARGET): ../Makefile" >> $@
%Record.h$(DEP): %Record.dbd
@$(RM) $@
@$(DBTORECORDTYPEH) -D $(DBDFLAGS) -o $(COMMONDEP_TARGET) $< > $@
@echo "$(COMMONDEP_TARGET): ../Makefile" >> $@
menu%.h$(DEP): $(COMMON_DIR)/menu%.dbd
@$(RM) $@
@$(DBTOMENUH) -D $(DBDFLAGS) -o $(COMMONDEP_TARGET) $< > $@
@echo "$(COMMONDEP_TARGET): ../Makefile" >> $@
menu%.h$(DEP): menu%.dbd
@$(RM) $@
@$(DBTOMENUH) -D $(DBDFLAGS) -o $(COMMONDEP_TARGET) $< > $@
@echo "$(COMMONDEP_TARGET): ../Makefile" >> $@
%.dbd$(DEP): $(COMMON_DIR)/%Include.dbd
@$(RM) $@
@$(DBEXPAND) -D $(DBDFLAGS) -o $(COMMONDEP_TARGET) $< > $@
@echo "$(COMMONDEP_TARGET): ../Makefile" >> $@
%.dbd$(DEP): %Include.dbd
@$(RM) $@
@$(DBEXPAND) -D $(DBDFLAGS) -o $(COMMONDEP_TARGET) $< > $@
@echo "$(COMMONDEP_TARGET): ../Makefile" >> $@
%.db$(RAW)$(DEP): %.substitutions
@$(RM) $@
$(MAKEDBDEPENDS) $(COMMONDEP_TARGET) $< $(TEMPLATE_FILENAME) > $@
@echo "$(COMMONDEP_TARGET): $(TEMPLATE_FILENAME)" >> $@
%.db$(RAW)$(DEP): %.template
@$(RM) $@
@$(MAKEDBDEPENDS) $(COMMONDEP_TARGET) $< > $@
%.acf$(DEP): %.acs
@$(RM) $@
@$(ACFDEPENDS_CMD)
##################################################### CapFast filter
$(COMMON_DIR)/%.edf: ../%.sch $(DEPSCHS)
@@ -222,33 +268,21 @@ $(INSTALL_DB)/%.template: %.template
##################################################### INC files
$(COMMON_DIR)/%Record.h: $(COMMON_DIR)/%Record.dbd
@$(RM) $(notdir $@)$(DEP)
@$(DBTORECORDTYPEH) -D $(DBDFLAGS) -o $@ $< > $(notdir $@)$(DEP)
@echo "$@: ../Makefile" >> $(notdir $@)$(DEP)
@$(RM) $(notdir $@)
$(DBTORECORDTYPEH) $(DBDFLAGS) -o $(notdir $@) $<
@$(MV) $(notdir $@) $@
$(COMMON_DIR)/%Record.h: %Record.dbd
@$(RM) $(notdir $@)$(DEP)
@$(DBTORECORDTYPEH) -D $(DBDFLAGS) -o $@ $< > $(notdir $@)$(DEP)
@echo "$@: ../Makefile" >> $(notdir $@)$(DEP)
@$(RM) $(notdir $@)
$(DBTORECORDTYPEH) $(DBDFLAGS) -o $(notdir $@) $<
@$(MV) $(notdir $@) $@
$(COMMON_DIR)/menu%.h: $(COMMON_DIR)/menu%.dbd
@$(RM) $(notdir $@)$(DEP)
@$(DBTOMENUH) -D $(DBDFLAGS) -o $@ $< > $(notdir $@)$(DEP)
@echo "$@: ../Makefile" >> $(notdir $@)$(DEP)
@$(RM) $(notdir $@)
$(DBTOMENUH) $(DBDFLAGS) -o $(notdir $@) $<
@$(MV) $(notdir $@) $@
$(COMMON_DIR)/menu%.h: menu%.dbd
@$(RM) $(notdir $@)$(DEP)
@$(DBTOMENUH) -D $(DBDFLAGS) -o $@ $< > $(notdir $@)$(DEP)
@echo "$@: ../Makefile" >> $(notdir $@)$(DEP)
@$(RM) $(notdir $@)
$(DBTOMENUH) $(DBDFLAGS) -o $(notdir $@) $<
@$(MV) $(notdir $@) $@
@@ -258,23 +292,18 @@ $(COMMON_DIR)/menu%.h: menu%.dbd
##################################################### DBD files
$(COMMON_DIR)/bpt%.dbd: bpt%.data
@$(RM) $(notdir $@)
$(MAKEBPT) $< $(notdir $@)
@$(MV) $(notdir $@) $@
$(COMMON_DIR)/%.dbd: $(COMMON_DIR)/%Include.dbd
@$(RM) $(notdir $@)$(DEP)
@$(DBEXPAND) -D $(DBDFLAGS) -o $@ $< > $(notdir $@)$(DEP)
@echo "$@: ../Makefile" >> $(notdir $@)$(DEP)
$(ECHO) "Expanding dbd"
$(ECHO) "Expanding created dbd file $(notdir $<)"
@$(RM) $(notdir $@)
@$(DBEXPAND) $(DBDFLAGS) -o $(notdir $@) $<
$(DBEXPAND) $(DBDFLAGS) -o $(notdir $@) $<
@$(MV) $(notdir $@) $@
$(COMMON_DIR)/%.dbd: %Include.dbd
@$(RM) $(notdir $@)$(DEP)
@$(DBEXPAND) -D $(DBDFLAGS) -o $@ $< > $(notdir $@)$(DEP)
@echo "$@: ../Makefile" >> $(notdir $@)$(DEP)
$(ECHO) "Expanding dbd"
$(ECHO) "Expanding dbd file $<"
@$(RM) $(notdir $@)
$(DBEXPAND) $(DBDFLAGS) -o $(notdir $@) $<
@$(MV) $(notdir $@) $@
@@ -309,25 +338,18 @@ $(COMMON_DIR)/%.db$(RAW): $(COMMON_DIR)/%.edf
@$(RM) $*.VAR
$(COMMON_DIR)/%.db$(RAW): %.substitutions
@$(RM) $(notdir $@)$(DEP)
$(MAKEDBDEPENDS) $@ $< $(TEMPLATE_FILENAME) > $(notdir $@)$(DEP)
@echo "$@: $(TEMPLATE_FILENAME)" >> $(notdir $@)$(DEP)
$(ECHO) "Inflating database from $< $(TEMPLATE_FILENAME)"
@$(RM) $@ $*.tmp
$(MSI) $(DBFLAGS) -S$< $(TEMPLATE_FILENAME) > $*.tmp
$(MV) $*.tmp $@
$(COMMON_DIR)/%.db$(RAW): %.template
@$(RM) $(notdir $@)$(DEP)
@$(MAKEDBDEPENDS) $@ $< > $(notdir $@)$(DEP)
$(ECHO) "Inflating database from $<"
@$(RM) $@ $*.tmp
$(MSI) $(DBFLAGS) $< > $*.tmp
$(MV) $*.tmp $@
$(COMMON_DIR)/%.acf: %.acs
@$(RM) $(notdir $@)$(DEP)
@$(ACFDEPENDS_CMD)
$(ECHO) "Creating acf file $@"
@$(RM) $@
$(ACF_CMD)
@@ -385,6 +407,5 @@ IOC_INST_TOP := $(firstword $(IOCS_APPL_TOP) \
$(MV) $*.tmp $@
.PRECIOUS: %_registerRecordDeviceDriver.cpp
.PRECIOUS: %$(DEP)
##################################################### END OF FILE

View File

@@ -76,6 +76,7 @@ all: install
-include $(CONFIG)/RULES_JAVA
ifneq (,$(strip $(HDEPENDS_FILES)))
$(filter-out $(wildcard *$(DEP)), $(HDEPENDS_FILES)): $(COMMON_INC)
-include $(HDEPENDS_FILES)
endif
@@ -200,18 +201,27 @@ $(OBJLIBNAME):%$(OBJ):
@$(RM) $@
$(COMPILE.ctdt) $<
%$(OBJ): %.c
%$(DEP):%.c
@$(RM) $@
@$(HDEPENDS_CMD)
%$(DEP):%.cc
@$(RM) $@
@$(HDEPENDS_CMD)
%$(DEP):%.cpp
@$(RM) $@
@$(HDEPENDS_CMD)
%$(OBJ): %.c
@$(RM) $@
$(COMPILE.c) $(call PATH_FILTER,$<) $(COMPILE_FILTER.c)
%$(OBJ): %.cc
@$(HDEPENDS_CMD)
@$(RM) $@
$(COMPILE.cpp) $(call PATH_FILTER,$<) $(COMPILE_FILTER.cpp)
%$(OBJ): %.cpp
@$(HDEPENDS_CMD)
@$(RM) $@
$(COMPILE.cpp) $(call PATH_FILTER,$<) $(COMPILE_FILTER.cpp)

View File

@@ -53,13 +53,12 @@ VALID_BUILDS = Ioc
# through the following contortions to get the EPICS flags back.
CFLAGS = $(CROSS_CFLAGS) $(OPT_CFLAGS) $(DEBUG_CFLAGS)\
$(WARN_CFLAGS) $(TARGET_CFLAGS) $(USR_CFLAGS) $(ARCH_DEP_CFLAGS)\
$(CODE_CFLAGS) $(STATIC_CFLAGS) $(OP_SYS_CFLAGS) $(LIBRARY_SRC_CFLAGS)\
$(HDEPENDS_CFLAGS)
$(CODE_CFLAGS) $(STATIC_CFLAGS) $(OP_SYS_CFLAGS) $(LIBRARY_SRC_CFLAGS)
CXXFLAGS = $(CROSS_CXXFLAGS) $(OPT_CXXFLAGS)\
$(DEBUG_CXXFLAGS) $(WARN_CXXFLAGS) $(TARGET_CXXFLAGS) $(USR_CXXFLAGS)\
$(ARCH_DEP_CXXFLAGS) $(CODE_CXXFLAGS) $(STATIC_CXXCFLAGS) $(OP_SYS_CXXFLAGS)\
$(LIBRARY_SRC_CFLAGS) $(HDEPENDS_CFLAGS)
$(LIBRARY_SRC_CFLAGS)
LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS) \
$(ARCH_DEP_LDFLAGS) $(DEBUG_LDFLAGS) $(OP_SYS_LDFLAGS) $(CROSS_LDFLAGS)\

View File

@@ -55,14 +55,9 @@ LOADABLE_SHRLIB_LDFLAGS = -G -h $@ -z text
OP_SYS_LDFLAGS += -z ignore -z combreloc -z lazyload
# Filter for getting rid of "invalid white space character in directive" compiler warnings
# when including headers created during win32 build.
#COMPILE_FILTER.c = 2>&1 | $(EPICS_BASE)/configure/tools/filterWarnings.pl
#COMPILE_FILTER.cpp = $(COMPILE_FILTER.c)
# Header dependency file generation command
HDEPENDS_METHOD=CMD
HDEPENDSCMD = $(if $(filter .c,$(suffix $<)),$(COMPILE.c),$(COMPILE.cpp)) -xM1 $< >$*$(DEP)
HDEPENDS_METHOD = CFLAGS
HDEPENDSCFLAGS = -xM1 > $*$(DEP)
#--------------------------------------------------
# Allow site overrides

View File

@@ -15,6 +15,36 @@ EPICS Base 3.15.0.x releases are not intended for use in production systems.</p>
<h2 align="center">Changes between 3.14.x and 3.15.0.x</h2>
<!-- Insert new items immediately below here ... -->
<h4>Parallel Builds</h4>
<p>
As EPICS sites get computers with more CPUs they report additional bugs in our
parallel build rules. Various issues have been fixed by separating out the build
rules that generate dependency (.d) files, ensuring that they are constructed at
the appropriate time in the build.</p>
<p>
These rule changes can cause additional warning messages to appear when building
support modules. Where an application provides its own Makefile rules it may now
have to add rules to construct an associated dependency file. In many cases
though the change needed is just to replace a dependency for a
<tt>target$(OBJ)</tt> with the <tt>target$(DEP)</tt> so this</p>
<pre>
myLib$(OBJ): myLib_lex.c</pre>
<p>
becomes</p>
<pre>
myLib$(DEP): myLib_lex.c</pre>
<p>
To debug build issues assocated with dependency files, use the command <tt>make
--debug=m</tt> which tells GNUmake to display information about what it is doing
during the first pass when it updates its makefiles.</p>
<h3>
Removed tsDefs.h</h3>

View File

@@ -13,9 +13,12 @@
# $(filter-out $(STATIC_SRCS),$(dbCore_SRCS)) : $(COMMON_DIR)/dbCommon.h
dbCommon.h$(DEP): $(IOCDIR)/db/dbCommonRecord.dbd
@$(RM) $@
@$(DBTORECORDTYPEH) -D -I ../db -o $(COMMONDEP_TARGET) $< > $@
@echo "$(COMMONDEP_TARGET): ../Makefile" >> $@
$(COMMON_DIR)/dbCommon.h: $(IOCDIR)/db/dbCommonRecord.dbd
@$(RM) $(notdir $@)$(DEP)
@$(DBTORECORDTYPEH) -D -I ../db -o $@ $< > $(notdir $@)$(DEP)
@$(RM) $(notdir $@)
$(DBTORECORDTYPEH) -I ../db -o $(notdir $@) $<
@$(MV) $(notdir $@) $@

View File

@@ -12,8 +12,9 @@
# This is a Makefile fragment, see src/libCom/Makefile.
# Extra rule since asLib_lex.c is included by asLib.c
asLib$(OBJ): asLib_lex.c
asLib$(DEP): asLib_lex.c
# Ensure that lexer and parser are built before they are needed
asLib.c: $(call PATH_FILTER, $(TOOLS)/antelope$(HOSTEXE))
asLib_lex.c: $(call PATH_FILTER, $(TOOLS)/e_flex$(HOSTEXE))
asLib_lex.c: $(INSTALL_INCLUDE)/flex.skel.static

View File

@@ -12,8 +12,6 @@ include $(TOP)/configure/CONFIG
STDDIR=$(TOP)/src/std
USR_DBDFLAGS += -I ../rec -I ../dev -I ../softIoc
LIBRARY_IOC += dbRecStd
dbRecStd_LIBS = dbCore ca Com