mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-13 01:47:05 +08:00
On some platforms, -fpic fails for sufficiently large shared libraries. We've mostly not hit that boundary yet, but there are some extensions such as Citus and pglogical where it's becoming a problem. A bit of research suggests that the penalty for -fPIC is small, in the single-digit-percentage range --- and there's none at all on popular platforms such as x86_64. So let's just default to -fPIC everywhere and provide one less thing for extension developers to worry about. Per complaint from Christoph Berg. Back-patch to all supported branches. (I did not bother to touch the recently-removed Makefiles for sco and unixware in the back branches, though. We'd have no way to test that it doesn't break anything on those platforms.) Discussion: https://postgr.es/m/20170529155850.qojdfrwkkqnjb3ap@msg.df7cb.de
26 lines
476 B
Makefile
26 lines
476 B
Makefile
AROPT = cr
|
|
|
|
ifdef ELF_SYSTEM
|
|
export_dynamic = -Wl,-E
|
|
rpath = -Wl,-R'$(rpathdir)'
|
|
endif
|
|
|
|
DLSUFFIX = .so
|
|
|
|
CFLAGS_SL = -fPIC -DPIC
|
|
|
|
|
|
# Rule for building a shared library from a single .o file
|
|
%.so: %.o
|
|
ifdef ELF_SYSTEM
|
|
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $<
|
|
else
|
|
$(LD) $(LDREL) $(LDOUT) $<.obj -x $<
|
|
@echo building shared object $@
|
|
@rm -f $@.pic
|
|
@${AR} cq $@.pic $<.obj
|
|
${RANLIB} $@.pic
|
|
@rm -f $@
|
|
$(LD) -x -Bshareable -Bforcearchive -o $@ $@.pic
|
|
endif
|