diff options
| author | Peter Eisentraut | 2008-02-25 17:55:42 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2008-02-25 17:55:42 +0000 |
| commit | 9956ddc19164b02dc1925fb389a1af77472eba5e (patch) | |
| tree | 4d7853b99df5794d8d127578246942c0d5dc9e14 /src/backend/common.mk | |
| parent | ad20c990f7392a14d2b9699b5b5857d5e5353715 (diff) | |
Link postgres from all object files at once, to avoid the error-prone
SUBSYS.o step and allow for better optimization by the linker.
Instead of partial linking into SUBSYS.o, the list of object files is
assembled in objfiles.txt files that are expanded when the final
linking is done.
Because we are not yet sure how long command lines different platforms
can handle, the old way of linking is still available, by defining the
make variable PARTIAL_LINKING (e.g., make all PARTIAL_LINKING=1). If
we determine that this is necessary for some platforms, then we will
document this in a more prominent place.
Diffstat (limited to 'src/backend/common.mk')
| -rw-r--r-- | src/backend/common.mk | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/backend/common.mk b/src/backend/common.mk index daa1f54ba0b..9fdfa8623fc 100644 --- a/src/backend/common.mk +++ b/src/backend/common.mk @@ -1,25 +1,47 @@ # # Common make rules for backend # -# $PostgreSQL: pgsql/src/backend/common.mk,v 1.1 2008/02/19 10:30:06 petere Exp $ +# $PostgreSQL: pgsql/src/backend/common.mk,v 1.2 2008/02/25 17:55:42 petere Exp $ # -SUBDIROBJS = $(SUBDIRS:%=%/SUBSYS.o) +# When including this file, set OBJS to the object files created in +# this directory and SUBDIRS to subdirectories containing more things +# to build. -all: SUBSYS.o +ifdef PARTIAL_LINKING +# old style: linking using SUBSYS.o +subsysfilename = SUBSYS.o +else +# new style: linking all object files at once +subsysfilename = objfiles.txt +endif + +SUBDIROBJS = $(SUBDIRS:%=%/$(subsysfilename)) + +# top-level backend directory obviously has its own "all" target +ifneq ($(subdir), src/backend) +all: $(subsysfilename) +endif SUBSYS.o: $(SUBDIROBJS) $(OBJS) $(LD) $(LDREL) $(LDOUT) $@ $^ +objfiles.txt: $(SUBDIROBJS) $(OBJS) + ( $(if $(SUBDIROBJS),cat $(SUBDIROBJS); )echo $(addprefix $(subdir)/,$(OBJS)) ) >$@ + +# make function to expand objfiles.txt contents +expand_subsys = $(foreach file,$(filter %/objfiles.txt,$(1)),$(patsubst ../../src/backend/%,%,$(addprefix $(top_builddir)/,$(shell cat $(file))))) $(filter-out %/objfiles.txt,$(1)) + +# Parallel make trickery $(SUBDIROBJS): $(SUBDIRS:%=%-recursive) ; .PHONY: $(SUBDIRS:%=%-recursive) $(SUBDIRS:%=%-recursive): - $(MAKE) -C $(subst -recursive,,$@) SUBSYS.o + $(MAKE) -C $(subst -recursive,,$@) all clean: clean-local clean-local: ifdef SUBDIRS for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean || exit; done endif - rm -f SUBSYS.o $(OBJS) + rm -f $(subsysfilename) $(OBJS) |
