Skip to content

chore: compile postgres statically to reduce the PLT function call #1064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build-cloudberry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ jobs:
},
{"test":"ic-parallel-retrieve-cursor",
"make_configs":["src/test/isolation2:installcheck-parallel-retrieve-cursor"]
},
{"test":"ic-cbdb-parallel",
"make_configs":["src/test/regress:installcheck-cbdb-parallel"]
}
]
}'
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build-dbg-cloudberry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,6 @@ jobs:
# Define base test configurations
ALL_TESTS='{
"include": [
{"test":"ic-cbdb-parallel",
"make_configs":["src/test/regress:installcheck-cbdb-parallel"]
}
]
}'

Expand Down
51 changes: 51 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ enable_ic_proxy
enable_external_fts
HAVE_CXX14
enable_gpcloud
enable_link_postgres_with_shared
enable_shared_postgres_backend
enable_mapreduce
enable_serverless
Expand Down Expand Up @@ -903,6 +904,7 @@ enable_catalog_ext
enable_serverless
enable_mapreduce
enable_shared_postgres_backend
enable_link_postgres_with_shared
enable_gpcloud
enable_external_fts
enable_ic_proxy
Expand Down Expand Up @@ -1630,6 +1632,9 @@ Optional Features:
--enable-mapreduce enable Cloudberry Mapreduce support
--disable-shared-postgres-backend
enable Cloudberry shared postgres backend support
--enable-link-postgres-with-shared
build Cloudberry using the shared library
libpostgres.so
--enable-gpcloud enable gpcloud support
--enable-external-fts enable external fts support
--enable-ic-proxy enable interconnect proxy mode (requires libuv
Expand Down Expand Up @@ -8589,6 +8594,45 @@ if test "$enable_shared_postgres_backend" = yes ; then :

fi # fi

#
# --enable-link-postgres-with-shared enables linking postgres with shared library libpostgres.so
#


# Check whether --enable-link-postgres-with-shared was given.
if test "${enable_link_postgres_with_shared+set}" = set; then :
enableval=$enable_link_postgres_with_shared;
case $enableval in
yes)

$as_echo "#define USE_LINK_POSTGRES_WITH_SHARED 1" >>confdefs.h

;;
no)
:
;;
*)
as_fn_error $? "no argument expected for --enable-link-postgres-with-shared option" "$LINENO" 5
;;
esac

else
enable_link_postgres_with_shared=no

fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to build Cloudberry using the shared library libpostgres.so... $enable_link_postgres_with_shared" >&5
$as_echo "checking whether to build Cloudberry using the shared library libpostgres.so... $enable_link_postgres_with_shared" >&6; }


# check if enable-shared-postgres-backend is yes when enable-link-postgres-with-shared is yes
if test "$enable_link_postgres_with_shared" = yes; then
if test "$enable_shared_postgres_backend" = no; then
as_fn_error $? "--enable-link-postgres-with-shared is yes, but --enable-shared-postgres-backend is no" "$LINENO" 5
fi
fi

#
# gpcloud, enabled by default
#
Expand Down Expand Up @@ -16057,6 +16101,13 @@ fi



# for contrib/pax_storage
if test "$enable_pax" = yes; then
if test "$enable_shared_postgres_backend" = no; then
as_fn_error $? "PAX support requires --enable-shared-postgres-backend" "$LINENO" 5
fi
fi

# for contrib/sepgsql
if test "$with_selinux" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for security_compute_create_name in -lselinux" >&5
Expand Down
25 changes: 24 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ AC_SUBST(enable_mapreduce)
#
PGAC_ARG_BOOL(enable, shared-postgres-backend, yes, [enable Cloudberry shared postgres backend support],
[AC_DEFINE([USE_SHARED_POSTGRES_BACKEND], 1,
[Define to 1 to build with shared postgres backend capabilities (--enable-shared-postgres-backend)])])
[Define to 1 to build with shared Cloudberry backend capabilities (--enable-shared-postgres-backend)])])
AC_MSG_RESULT([checking whether to build with Cloudberry shared postgres backend... $enable_shared_postgres_backend])
AC_SUBST(enable_shared_postgres_backend)

Expand All @@ -881,6 +881,22 @@ AS_IF([test "$enable_shared_postgres_backend" = yes ],
CXXFLAGS="$CXXFLAGS -fPIC "
]) # fi

#
# --enable-link-postgres-with-shared enables linking postgres with shared library libpostgres.so
#
PGAC_ARG_BOOL(enable, link-postgres-with-shared, no, [build Cloudberry using the shared library libpostgres.so],
[AC_DEFINE([USE_LINK_POSTGRES_WITH_SHARED], 1,
[Define to 1 to build Cloudberry using the shared library libpostgres.so (--enable-link-postgres-with-shared)])])
AC_MSG_RESULT([checking whether to build Cloudberry using the shared library libpostgres.so... $enable_link_postgres_with_shared])
AC_SUBST(enable_link_postgres_with_shared)

# check if enable-shared-postgres-backend is yes when enable-link-postgres-with-shared is yes
if test "$enable_link_postgres_with_shared" = yes; then
if test "$enable_shared_postgres_backend" = no; then
AC_MSG_ERROR([--enable-link-postgres-with-shared is yes, but --enable-shared-postgres-backend is no])
fi
fi

#
# gpcloud, enabled by default
#
Expand Down Expand Up @@ -1783,6 +1799,13 @@ fi
AC_SUBST(LDAP_LIBS_FE)
AC_SUBST(LDAP_LIBS_BE)

# for contrib/pax_storage
if test "$enable_pax" = yes; then
if test "$enable_shared_postgres_backend" = no; then
AC_MSG_ERROR([PAX support requires --enable-shared-postgres-backend])
fi
fi

# for contrib/sepgsql
if test "$with_selinux" = yes; then
AC_CHECK_LIB(selinux, security_compute_create_name, [],
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.global.in
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ enable_debug_extensions = @enable_debug_extensions@
enable_orafce = @enable_orafce@
enable_mapreduce = @enable_mapreduce@
enable_shared_postgres_backend = @enable_shared_postgres_backend@
enable_link_postgres_with_shared = @enable_link_postgres_with_shared@
enable_gpcloud = @enable_gpcloud@
enable_ic_proxy = @enable_ic_proxy@
enable_pax = @enable_pax@
Expand Down
8 changes: 7 additions & 1 deletion src/backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,22 @@ $(SYMBOL_MAP_FILE): $(top_builddir)/src/interfaces/libpq/exports.txt
( echo '{ global: *; '; echo ' local:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $< | grep -v -E $(SAFELY_EXPORTED_SYMBOLS_PATTERN); echo '};' ) >$@
SYMBOL_MAPPING_FLAGS = -Wl,--version-script=$(SYMBOL_MAP_FILE)
endif

ifeq ($(enable_shared_postgres_backend),yes)
all: libpostgres.so
libpostgres.so: $(OBJS) $(SYMBOL_MAP_FILE)
$(CXX) -shared $(CXXFLAGS) $(LDFLAGS) $(LDFLAGS_SL) $(export_dynamic) \
$(filter-out main/main.o, $(call expand_subsys,$(OBJS))) $(LIBS) $(SYMBOL_MAPPING_FLAGS) -o $@

# if enable-build-postgres-with-shared is yes, link postgres with shared library libpostgres.so
ifeq ($(enable_link_postgres_with_shared),yes)
postgres: main/main.o libpostgres.so $(top_builddir)/src/port/libpgport_srv.a $(top_builddir)/src/common/libpgcommon_srv.a
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) \
main/main.o libpostgres.so $(top_builddir)/src/port/libpgport_srv.a \
$(top_builddir)/src/common/libpgcommon_srv.a $(LIBS) -o $@
else
postgres: $(OBJS) $(SYMBOL_MAP_FILE)
$(CXX) $(CXXFLAGS) $(call expand_subsys,$(OBJS)) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(LIBS) $(SYMBOL_MAPPING_FLAGS) -o $@
endif

else
postgres: $(OBJS) $(SYMBOL_MAP_FILE)
Expand Down
Loading