Skip to content

Commit 8eadd5c

Browse files
committed
aio: Add liburing dependency
Will be used in a subsequent commit, to implement io_method=io_uring. Kept separate for easier review. Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/uvrtrknj4kdytuboidbhwclo4gxhswwcpgadptsjvjqcluzmah%40brqs62irg4dt
1 parent f056f75 commit 8eadd5c

File tree

10 files changed

+218
-4
lines changed

10 files changed

+218
-4
lines changed

.cirrus.tasks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ task:
471471
--enable-cassert --enable-injection-points --enable-debug \
472472
--enable-tap-tests --enable-nls \
473473
--with-segsize-blocks=6 \
474+
--with-liburing \
474475
\
475476
${LINUX_CONFIGURE_FEATURES} \
476477
\

configure

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,9 @@ LIBCURL_LIBS
712712
LIBCURL_CFLAGS
713713
with_libcurl
714714
with_uuid
715+
LIBURING_LIBS
716+
LIBURING_CFLAGS
717+
with_liburing
715718
with_readline
716719
with_systemd
717720
with_selinux
@@ -865,6 +868,7 @@ with_selinux
865868
with_systemd
866869
with_readline
867870
with_libedit_preferred
871+
with_liburing
868872
with_uuid
869873
with_ossp_uuid
870874
with_libcurl
@@ -898,6 +902,8 @@ PKG_CONFIG_PATH
898902
PKG_CONFIG_LIBDIR
899903
ICU_CFLAGS
900904
ICU_LIBS
905+
LIBURING_CFLAGS
906+
LIBURING_LIBS
901907
LIBCURL_CFLAGS
902908
LIBCURL_LIBS
903909
XML2_CONFIG
@@ -1578,6 +1584,7 @@ Optional Packages:
15781584
--without-readline do not use GNU Readline nor BSD Libedit for editing
15791585
--with-libedit-preferred
15801586
prefer BSD Libedit over GNU Readline
1587+
--with-liburing build with io_uring support, for asynchronous I/O
15811588
--with-uuid=LIB build contrib/uuid-ossp using LIB (bsd,e2fs,ossp)
15821589
--with-ossp-uuid obsolete spelling of --with-uuid=ossp
15831590
--with-libcurl build with libcurl support
@@ -1614,6 +1621,10 @@ Some influential environment variables:
16141621
path overriding pkg-config's built-in search path
16151622
ICU_CFLAGS C compiler flags for ICU, overriding pkg-config
16161623
ICU_LIBS linker flags for ICU, overriding pkg-config
1624+
LIBURING_CFLAGS
1625+
C compiler flags for LIBURING, overriding pkg-config
1626+
LIBURING_LIBS
1627+
linker flags for LIBURING, overriding pkg-config
16171628
LIBCURL_CFLAGS
16181629
C compiler flags for LIBCURL, overriding pkg-config
16191630
LIBCURL_LIBS
@@ -8692,6 +8703,134 @@ fi
86928703

86938704

86948705

8706+
#
8707+
# liburing
8708+
#
8709+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build with liburing support" >&5
8710+
$as_echo_n "checking whether to build with liburing support... " >&6; }
8711+
8712+
8713+
8714+
# Check whether --with-liburing was given.
8715+
if test "${with_liburing+set}" = set; then :
8716+
withval=$with_liburing;
8717+
case $withval in
8718+
yes)
8719+
8720+
$as_echo "#define USE_LIBURING 1" >>confdefs.h
8721+
8722+
;;
8723+
no)
8724+
:
8725+
;;
8726+
*)
8727+
as_fn_error $? "no argument expected for --with-liburing option" "$LINENO" 5
8728+
;;
8729+
esac
8730+
8731+
else
8732+
with_liburing=no
8733+
8734+
fi
8735+
8736+
8737+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_liburing" >&5
8738+
$as_echo "$with_liburing" >&6; }
8739+
8740+
8741+
if test "$with_liburing" = yes; then
8742+
8743+
pkg_failed=no
8744+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for liburing" >&5
8745+
$as_echo_n "checking for liburing... " >&6; }
8746+
8747+
if test -n "$LIBURING_CFLAGS"; then
8748+
pkg_cv_LIBURING_CFLAGS="$LIBURING_CFLAGS"
8749+
elif test -n "$PKG_CONFIG"; then
8750+
if test -n "$PKG_CONFIG" && \
8751+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"liburing\""; } >&5
8752+
($PKG_CONFIG --exists --print-errors "liburing") 2>&5
8753+
ac_status=$?
8754+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
8755+
test $ac_status = 0; }; then
8756+
pkg_cv_LIBURING_CFLAGS=`$PKG_CONFIG --cflags "liburing" 2>/dev/null`
8757+
test "x$?" != "x0" && pkg_failed=yes
8758+
else
8759+
pkg_failed=yes
8760+
fi
8761+
else
8762+
pkg_failed=untried
8763+
fi
8764+
if test -n "$LIBURING_LIBS"; then
8765+
pkg_cv_LIBURING_LIBS="$LIBURING_LIBS"
8766+
elif test -n "$PKG_CONFIG"; then
8767+
if test -n "$PKG_CONFIG" && \
8768+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"liburing\""; } >&5
8769+
($PKG_CONFIG --exists --print-errors "liburing") 2>&5
8770+
ac_status=$?
8771+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
8772+
test $ac_status = 0; }; then
8773+
pkg_cv_LIBURING_LIBS=`$PKG_CONFIG --libs "liburing" 2>/dev/null`
8774+
test "x$?" != "x0" && pkg_failed=yes
8775+
else
8776+
pkg_failed=yes
8777+
fi
8778+
else
8779+
pkg_failed=untried
8780+
fi
8781+
8782+
8783+
8784+
if test $pkg_failed = yes; then
8785+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
8786+
$as_echo "no" >&6; }
8787+
8788+
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
8789+
_pkg_short_errors_supported=yes
8790+
else
8791+
_pkg_short_errors_supported=no
8792+
fi
8793+
if test $_pkg_short_errors_supported = yes; then
8794+
LIBURING_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "liburing" 2>&1`
8795+
else
8796+
LIBURING_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "liburing" 2>&1`
8797+
fi
8798+
# Put the nasty error message in config.log where it belongs
8799+
echo "$LIBURING_PKG_ERRORS" >&5
8800+
8801+
as_fn_error $? "Package requirements (liburing) were not met:
8802+
8803+
$LIBURING_PKG_ERRORS
8804+
8805+
Consider adjusting the PKG_CONFIG_PATH environment variable if you
8806+
installed software in a non-standard prefix.
8807+
8808+
Alternatively, you may set the environment variables LIBURING_CFLAGS
8809+
and LIBURING_LIBS to avoid the need to call pkg-config.
8810+
See the pkg-config man page for more details." "$LINENO" 5
8811+
elif test $pkg_failed = untried; then
8812+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
8813+
$as_echo "no" >&6; }
8814+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
8815+
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
8816+
as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
8817+
is in your PATH or set the PKG_CONFIG environment variable to the full
8818+
path to pkg-config.
8819+
8820+
Alternatively, you may set the environment variables LIBURING_CFLAGS
8821+
and LIBURING_LIBS to avoid the need to call pkg-config.
8822+
See the pkg-config man page for more details.
8823+
8824+
To get pkg-config, see <http://pkg-config.freedesktop.org/>.
8825+
See \`config.log' for more details" "$LINENO" 5; }
8826+
else
8827+
LIBURING_CFLAGS=$pkg_cv_LIBURING_CFLAGS
8828+
LIBURING_LIBS=$pkg_cv_LIBURING_LIBS
8829+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
8830+
$as_echo "yes" >&6; }
8831+
8832+
fi
8833+
fi
86958834

86968835
#
86978836
# UUID library

configure.ac

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,18 @@ AC_SUBST(with_readline)
975975
PGAC_ARG_BOOL(with, libedit-preferred, no,
976976
[prefer BSD Libedit over GNU Readline])
977977

978+
#
979+
# liburing
980+
#
981+
AC_MSG_CHECKING([whether to build with liburing support])
982+
PGAC_ARG_BOOL(with, liburing, no, [build with io_uring support, for asynchronous I/O],
983+
[AC_DEFINE([USE_LIBURING], 1, [Define to build with io_uring support. (--with-liburing)])])
984+
AC_MSG_RESULT([$with_liburing])
985+
AC_SUBST(with_liburing)
986+
987+
if test "$with_liburing" = yes; then
988+
PKG_CHECK_MODULES(LIBURING, liburing)
989+
fi
978990

979991
#
980992
# UUID library

doc/src/sgml/installation.sgml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,24 @@ build-postgresql:
11561156
</listitem>
11571157
</varlistentry>
11581158

1159+
<varlistentry id="configure-option-with-liburing">
1160+
<term><option>--with-liburing</option></term>
1161+
<listitem>
1162+
<para>
1163+
Build with liburing, enabling io_uring support for asynchronous I/O.
1164+
</para>
1165+
<para>
1166+
To detect the required compiler and linker options, PostgreSQL will
1167+
query <command>pkg-config</command>.
1168+
</para>
1169+
<para>
1170+
To use a liburing installation that is in an unusual location, you
1171+
can set <command>pkg-config</command>-related environment
1172+
variables (see its documentation).
1173+
</para>
1174+
</listitem>
1175+
</varlistentry>
1176+
11591177
<varlistentry id="configure-option-with-libxml">
11601178
<term><option>--with-libxml</option></term>
11611179
<listitem>
@@ -2611,6 +2629,22 @@ ninja install
26112629
</listitem>
26122630
</varlistentry>
26132631

2632+
<varlistentry id="configure-with-liburing-meson">
2633+
<term><option>-Dliburing={ auto | enabled | disabled }</option></term>
2634+
<listitem>
2635+
<para>
2636+
Build with liburing, enabling io_uring support for asynchronous I/O.
2637+
Defaults to auto.
2638+
</para>
2639+
2640+
<para>
2641+
To use a liburing installation that is in an unusual location, you
2642+
can set <command>pkg-config</command>-related environment
2643+
variables (see its documentation).
2644+
</para>
2645+
</listitem>
2646+
</varlistentry>
2647+
26142648
<varlistentry id="configure-with-libxml-meson">
26152649
<term><option>-Dlibxml={ auto | enabled | disabled }</option></term>
26162650
<listitem>

meson.build

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,18 @@ endif
944944

945945

946946

947+
###############################################################
948+
# Library: liburing
949+
###############################################################
950+
951+
liburingopt = get_option('liburing')
952+
liburing = dependency('liburing', required: liburingopt)
953+
if liburing.found()
954+
cdata.set('USE_LIBURING', 1)
955+
endif
956+
957+
958+
947959
###############################################################
948960
# Library: libxml
949961
###############################################################
@@ -3164,6 +3176,7 @@ backend_both_deps += [
31643176
icu_i18n,
31653177
ldap,
31663178
libintl,
3179+
liburing,
31673180
libxml,
31683181
lz4,
31693182
pam,
@@ -3819,6 +3832,7 @@ if meson.version().version_compare('>=0.57')
38193832
'icu': icu,
38203833
'ldap': ldap,
38213834
'libcurl': libcurl,
3835+
'liburing': liburing,
38223836
'libxml': libxml,
38233837
'libxslt': libxslt,
38243838
'llvm': llvm,

meson_options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ option('libcurl', type : 'feature', value: 'auto',
106106
option('libedit_preferred', type: 'boolean', value: false,
107107
description: 'Prefer BSD Libedit over GNU Readline')
108108

109+
option('liburing', type : 'feature', value: 'auto',
110+
description: 'io_uring support, for asynchronous I/O')
111+
109112
option('libxml', type: 'feature', value: 'auto',
110113
description: 'XML support')
111114

src/Makefile.global.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ with_gssapi = @with_gssapi@
196196
with_krb_srvnam = @with_krb_srvnam@
197197
with_ldap = @with_ldap@
198198
with_libcurl = @with_libcurl@
199+
with_liburing = @with_liburing@
199200
with_libxml = @with_libxml@
200201
with_libxslt = @with_libxslt@
201202
with_llvm = @with_llvm@
@@ -222,6 +223,9 @@ krb_srvtab = @krb_srvtab@
222223
ICU_CFLAGS = @ICU_CFLAGS@
223224
ICU_LIBS = @ICU_LIBS@
224225

226+
LIBURING_CFLAGS = @LIBURING_CFLAGS@
227+
LIBURING_LIBS = @LIBURING_LIBS@
228+
225229
TCLSH = @TCLSH@
226230
TCL_LIBS = @TCL_LIBS@
227231
TCL_LIB_SPEC = @TCL_LIB_SPEC@
@@ -246,7 +250,7 @@ CPP = @CPP@
246250
CPPFLAGS = @CPPFLAGS@
247251
PG_SYSROOT = @PG_SYSROOT@
248252

249-
override CPPFLAGS := $(ICU_CFLAGS) $(CPPFLAGS)
253+
override CPPFLAGS := $(ICU_CFLAGS) $(LIBURING_CFLAGS) $(CPPFLAGS)
250254

251255
ifdef PGXS
252256
override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)

src/backend/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ OBJS = \
4343
$(top_builddir)/src/common/libpgcommon_srv.a \
4444
$(top_builddir)/src/port/libpgport_srv.a
4545

46-
# We put libpgport and libpgcommon into OBJS, so remove it from LIBS; also add
47-
# libldap and ICU
48-
LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS)) $(LDAP_LIBS_BE) $(ICU_LIBS)
46+
# We put libpgport and libpgcommon into OBJS, so remove it from LIBS.
47+
LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS))
48+
# The backend conditionally needs libraries that most executables don't need.
49+
LIBS += $(LDAP_LIBS_BE) $(ICU_LIBS) $(LIBURING_LIBS)
4950

5051
# The backend doesn't need everything that's in LIBS, however
5152
LIBS := $(filter-out -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))

src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,9 @@
672672
/* Define to 1 to build with libcurl support. (--with-libcurl) */
673673
#undef USE_LIBCURL
674674

675+
/* Define to build with io_uring support. (--with-liburing) */
676+
#undef USE_LIBURING
677+
675678
/* Define to 1 to build with XML support. (--with-libxml) */
676679
#undef USE_LIBXML
677680

src/makefiles/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ pgxs_empty = [
199199
'PTHREAD_CFLAGS', 'PTHREAD_LIBS',
200200

201201
'ICU_LIBS',
202+
203+
'LIBURING_CFLAGS', 'LIBURING_LIBS',
202204
]
203205

204206
if host_system == 'windows' and cc.get_argument_syntax() != 'msvc'
@@ -230,6 +232,7 @@ pgxs_deps = {
230232
'icu': icu,
231233
'ldap': ldap,
232234
'libcurl': libcurl,
235+
'liburing': liburing,
233236
'libxml': libxml,
234237
'libxslt': libxslt,
235238
'llvm': llvm,

0 commit comments

Comments
 (0)