Skip to content

Commit cc93dc8

Browse files
pmp-ptudor
andauthored
add a llvm-ar step before link optimisation (#9)
* add a llvm-ar step before link optimisation goal: keep libplite.a static with all debug speed up link/optimisation pass by re using the same static lib * use clang partial linkin (-r) --------- Co-authored-by: tudor <[email protected]>
1 parent 3c461da commit cc93dc8

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/backend/Makefile

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ LOCALOBJS += utils/probes.o
3737
endif
3838
endif
3939

40-
OBJS = \
40+
ONLYOBJS = \
4141
$(LOCALOBJS) \
42-
$(SUBDIROBJS) \
42+
$(SUBDIROBJS)
43+
OBJS = \
44+
$(ONLYOBJS) \
4345
$(top_builddir)/src/common/libpgcommon_srv.a \
4446
$(top_builddir)/src/port/libpgport_srv.a
4547

@@ -60,16 +62,32 @@ override LDFLAGS := $(LDFLAGS) $(LDFLAGS_EX) $(LDFLAGS_EX_BE)
6062

6163
all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
6264

65+
ifneq ($(PORTNAME), emscripten)
6366
ifneq ($(PORTNAME), cygwin)
6467
ifneq ($(PORTNAME), win32)
6568
ifneq ($(PORTNAME), aix)
6669

6770
postgres: $(OBJS)
68-
$(CC) $(MAIN_MODULE) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o $@
71+
$(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o $@
6972

7073
endif
7174
endif
7275
endif
76+
endif
77+
78+
ifeq ($(PORTNAME), emscripten)
79+
AR ?= llvm-ar
80+
LIBPGLITE ?= $(top_builddir)/libpglite.a
81+
LIBPG = $(top_builddir)/libpostgres.a
82+
PGLITE = $(top_builddir)/src/common/libpgcommon_srv.a $(top_builddir)/src/port/libpgport_srv.a $(LIBPG)
83+
PGMAIN = main/main.o tcop/postgres.o
84+
postgres: $(OBJS)
85+
$(AR) rcs $(top_builddir)/libpgmain.a $(PGMAIN)
86+
$(AR) rcs $(LIBPG) $(filter-out $(PGMAIN),$(call expand_subsys,$(ONLYOBJS)))
87+
$(CC) -r -o $(top_builddir)/libpglite.o -Wl,--whole-archive $(PGLITE)
88+
$(AR) rcs $(LIBPGLITE) $(top_builddir)/libpglite.o
89+
COPTS="$(LOPTS)" $(CC) $(MAIN_MODULE) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPGLITE) $(top_builddir)/libpgmain.a $(LIBS)
90+
endif
7391

7492
ifeq ($(PORTNAME), cygwin)
7593

0 commit comments

Comments
 (0)