Fix partial-build problems introduced by having more generated headers.

Commit 372728b0d created some problems for usages like building a
subdirectory without having first done "make all" at the top level,
or for proceeding directly to "make install" without "make all".
The only reasonably clean way to fix this seems to be to force the
submake-generated-headers rule to fire in *any* "make all" or "make
install" command anywhere in the tree.  To avoid lots of redundant work,
as well as parallel make jobs possibly clobbering each others' output, we
still need to be sure that the rule fires only once in a recursive build.
For that, adopt the same MAKELEVEL hack previously used for "temp-install".
But try to document it a bit better.

The submake-errcodes mechanism previously used in src/port/ and src/common/
is subsumed by this, so we can get rid of those special cases.  It was
inadequate for src/common/ anyway after the aforesaid commit, and it always
risked parallel attempts to build errcodes.h.

Discussion: https://postgr.es/m/E1f5FAB-0006LU-MB@gemulon.postgresql.org
This commit is contained in:
Tom Lane 2018-04-09 16:42:02 -04:00
부모 468abb8f7a
커밋 3b8f6e75f3
10개의 변경된 파일36개의 추가작업 그리고 42개의 파일을 삭제

파일 보기

@ -17,6 +17,8 @@
# to want to use.
html:
# We don't need the tree-wide headers or install support here.
NO_GENERATED_HEADERS=yes
NO_TEMP_INSTALL=yes
subdir = doc/src/sgml

파일 보기

@ -41,11 +41,6 @@ endif
$(recurse)
# Update the commonly used headers before building the subdirectories;
# otherwise, in a parallel build, several different sub-jobs will try to
# remake them concurrently
$(SUBDIRS:%=all-%-recurse): | submake-generated-headers
install: install-local
install-local: installdirs-local

파일 보기

@ -348,11 +348,39 @@ XGETTEXT = @XGETTEXT@
GZIP = gzip
BZIP2 = bzip2
# Tree-wide build support
# Just about every code subdirectory wants to have the generated headers
# available before building, but we don't want parallel makes all trying
# to build the same headers. These rules, together with the recursion rules
# below, ensure that we update the generated headers once, if needed,
# at the top level of any "make all" or "make install" request. If a
# particular subdirectory knows this isn't needed in itself or its children,
# it can set NO_GENERATED_HEADERS.
all install: submake-generated-headers
.PHONY: submake-generated-headers
submake-generated-headers:
ifndef NO_GENERATED_HEADERS
ifeq ($(MAKELEVEL),0)
$(MAKE) -C $(top_builddir)/src/backend generated-headers
endif
endif
# Testing
# In much the same way as above, these rules ensure that we build a temp
# install tree just once in any recursive "make check". The additional test
# on abs_top_builddir prevents doing anything foolish to the root directory.
check: temp-install
.PHONY: temp-install
temp-install:
ifndef NO_TEMP_INSTALL
ifneq ($(abs_top_builddir),)
@ -544,10 +572,7 @@ submake-libpgfeutils:
$(MAKE) -C $(top_builddir)/src/common all
$(MAKE) -C $(top_builddir)/src/fe_utils all
submake-generated-headers:
$(MAKE) -C $(top_builddir)/src/backend generated-headers
.PHONY: submake-libpq submake-libpgport submake-libpgfeutils submake-generated-headers
.PHONY: submake-libpq submake-libpgport submake-libpgfeutils
##########################################################################
@ -782,7 +807,9 @@ endif
# This function is only for internal use below. It should be called
# using $(eval). It will set up a target so that it recurses into
# a given subdirectory. Note that to avoid a nasty bug in make 3.80,
# a given subdirectory. For the tree-wide all/install/check cases,
# ensure we do our one-time tasks before recursing (see targets above).
# Note that to avoid a nasty bug in make 3.80,
# this function has to avoid using any complicated constructs (like
# multiple targets on a line) and also not contain any lines that expand
# to more than about 200 bytes. This is why we make it apply to just one
@ -793,7 +820,7 @@ endif
define _create_recursive_target
.PHONY: $(1)-$(2)-recurse
$(1): $(1)-$(2)-recurse
$(1)-$(2)-recurse: $(if $(filter check, $(3)), temp-install)
$(1)-$(2)-recurse: $(if $(filter all install, $(3)), submake-generated-headers) $(if $(filter check, $(3)), temp-install)
$$(MAKE) -C $(2) $(3)
endef
# Note that the use of $$ on the last line above is important; we want

파일 보기

@ -111,14 +111,6 @@ endif
endif # aix
# Update the commonly used headers before building the subdirectories
$(SUBDIRS:%=%-recursive): | generated-headers
# src/port needs a convenient way to force just errcodes.h to get built
submake-errcodes: $(top_builddir)/src/include/utils/errcodes.h
.PHONY: submake-errcodes
$(top_builddir)/src/port/libpgport_srv.a: | submake-libpgport

파일 보기

@ -27,7 +27,6 @@ CFLAGS += $(LLVM_CFLAGS)
CXXFLAGS += $(LLVM_CXXFLAGS)
override CPPFLAGS := $(LLVM_CPPFLAGS) $(CPPFLAGS)
SHLIB_LINK += $(LLVM_LIBS)
SHLIB_PREREQS += submake-generated-headers
# Because this module includes C++ files, we need to use a C++
# compiler for linking. Makefile.shlib uses $(COMPILER) to build

파일 보기

@ -88,13 +88,6 @@ libpgcommon_srv.a: $(OBJS_SRV)
%_srv.o: %.c %.o
$(CC) $(CFLAGS) $(subst -DFRONTEND ,, $(CPPFLAGS)) -c $< -o $@
$(OBJS_SRV): | submake-errcodes
.PHONY: submake-errcodes
submake-errcodes:
$(MAKE) -C ../backend submake-errcodes
# Dependencies of keywords.o need to be managed explicitly to make sure
# that you don't get broken parsing code, even in a non-enable-depend build.
# Note that gram.h isn't required for the frontend version of keywords.o.

파일 보기

@ -99,9 +99,6 @@ include $(top_srcdir)/src/Makefile.shlib
all: all-lib
$(OBJS): | submake-generated-headers
install: all install-lib install-data
installdirs: installdirs-lib

파일 보기

@ -87,13 +87,6 @@ libpgport_srv.a: $(OBJS_SRV)
%_srv.o: %.c %.o
$(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
$(OBJS_SRV): | submake-errcodes
.PHONY: submake-errcodes
submake-errcodes:
$(MAKE) -C ../backend submake-errcodes
# Dependency is to ensure that path changes propagate
path.o: path.c pg_config_paths.h

파일 보기

@ -20,6 +20,4 @@ SUBDIRS = \
test_shm_mq \
worker_spi
all: submake-generated-headers
$(recurse)

파일 보기

@ -65,8 +65,6 @@ include $(top_srcdir)/src/Makefile.shlib
all: all-lib
$(OBJS): | submake-generated-headers
# Test input and expected files. These are created by pg_regress itself, so we
# don't have a rule to create them. We do need rules to clean them however.
input_files = $(patsubst $(srcdir)/input/%.source,sql/%.sql, $(wildcard $(srcdir)/input/*.source))
@ -107,7 +105,7 @@ $(top_builddir)/contrib/spi/refint$(DLSUFFIX): | submake-contrib-spi ;
$(top_builddir)/contrib/spi/autoinc$(DLSUFFIX): | submake-contrib-spi ;
submake-contrib-spi: | submake-libpgport submake-generated-headers
submake-contrib-spi: | submake-libpgport
$(MAKE) -C $(top_builddir)/contrib/spi
.PHONY: submake-contrib-spi