Skip to content

PHPC-2262: Replace ICU dep with vendored utf8proc lib #1447

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

Merged
merged 1 commit into from
Jul 19, 2023
Merged
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
18 changes: 9 additions & 9 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1194,17 +1194,17 @@ axes:
display_name: libmongoc version
values:
- id: "lowest-supported"
display_name: "1.24.1"
variables:
LIBMONGOC_VERSION: "1.24.1"
- id: "upcoming-stable"
display_name: "1.24-dev"
variables:
LIBMONGOC_VERSION: "r1.24"
- id: "latest-dev"
display_name: "master"
display_name: "1.25-dev"
variables:
LIBMONGOC_VERSION: "master"
# - id: "upcoming-stable"
# display_name: "1.25-dev"
# variables:
# LIBMONGOC_VERSION: "r1.25"
# - id: "latest-dev"
# display_name: "master"
# variables:
# LIBMONGOC_VERSION: "master"


buildvariants:
Expand Down
29 changes: 23 additions & 6 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ if test "$PHP_MONGODB" != "no"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
AC_MSG_CHECKING(for libbson)
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libbson-1.0; then
if $PKG_CONFIG libbson-1.0 --atleast-version 1.24.1; then
if $PKG_CONFIG libbson-1.0 --atleast-version 1.25.0; then
PHP_MONGODB_BSON_CFLAGS=`$PKG_CONFIG libbson-1.0 --cflags`
PHP_MONGODB_BSON_LIBS=`$PKG_CONFIG libbson-1.0 --libs`
PHP_MONGODB_BSON_VERSION=`$PKG_CONFIG libbson-1.0 --modversion`
PHP_MONGODB_BSON_VERSION_STRING="System ($PHP_MONGODB_BSON_VERSION)"
AC_MSG_RESULT(version $PHP_MONGODB_BSON_VERSION found)
else
AC_MSG_ERROR(system libbson must be upgraded to version >= 1.24.1)
AC_MSG_ERROR(system libbson must be upgraded to version >= 1.25.0)
fi
else
AC_MSG_ERROR(pkgconfig and libbson must be installed)
Expand All @@ -271,14 +271,14 @@ if test "$PHP_MONGODB" != "no"; then

AC_MSG_CHECKING(for libmongoc)
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmongoc-1.0; then
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.24.1; then
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.25.0; then
PHP_MONGODB_MONGOC_CFLAGS=`$PKG_CONFIG libmongoc-1.0 --cflags`
PHP_MONGODB_MONGOC_LIBS=`$PKG_CONFIG libmongoc-1.0 --libs`
PHP_MONGODB_MONGOC_VERSION=`$PKG_CONFIG libmongoc-1.0 --modversion`
PHP_MONGODB_MONGOC_VERSION_STRING="System ($PHP_MONGODB_MONGOC_VERSION)"
AC_MSG_RESULT(version $PHP_MONGODB_MONGOC_VERSION found)
else
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.24.1)
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.25.0)
fi
else
AC_MSG_ERROR(pkgconfig and libmongoc must be installed)
Expand Down Expand Up @@ -318,7 +318,11 @@ if test "$PHP_MONGODB" != "no"; then

if test "$PHP_MONGODB_SYSTEM_LIBS" = "no"; then
PHP_MONGODB_BUNDLED_CFLAGS="$STD_CFLAGS -DBSON_COMPILATION -DMONGOC_COMPILATION"
PHP_MONGODB_LIBMONGOCRYPT_CFLAGS="-DKMS_MSG_STATIC -DMLIB_USER"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I relocated this within if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" = "yes"; since it's only referenced within that scope (i.e. building with bundled sources and libmongocrypt is enabled).


dnl CheckUtf8Proc.m4 will modify this when using bundled utf8proc
PHP_MONGODB_UTF8PROC_CFLAGS=""

dnl CheckCompression.m4 will modify this when using bundled zlib
PHP_MONGODB_ZLIB_CFLAGS=""

dnl M4 doesn't know if we're building statically or as a shared module, so
Expand Down Expand Up @@ -355,7 +359,7 @@ if test "$PHP_MONGODB" != "no"; then
_include([scripts/autotools/libmongoc/CheckResolv.m4])
_include([scripts/autotools/libmongoc/CheckSasl.m4])
_include([scripts/autotools/libmongoc/CheckSSL.m4])
_include([scripts/autotools/libmongoc/CheckICU.m4])
_include([scripts/autotools/libmongoc/CheckUtf8Proc.m4])
_include([scripts/autotools/libmongoc/FindDependencies.m4])
_include([scripts/autotools/libmongoc/PlatformFlags.m4])
_include([scripts/autotools/libmongoc/Versions.m4])
Expand Down Expand Up @@ -417,6 +421,10 @@ if test "$PHP_MONGODB" != "no"; then
dnl Generated with: find src/libmongoc/src/libmongoc/src/mongoc -name '*.c' -print0 | cut -sz -d / -f 7- | sort -dz | tr '\000' ' '
PHP_MONGODB_MONGOC_SOURCES="mcd-azure.c mcd-rpc.c mongoc-aggregate.c mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-client-side-encryption.c mongoc-cluster-aws.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypt.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-change-stream.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-error.c mongoc-find-and-modify.c mongoc-flags.c mongoc-generation-map.c mongoc-gridfs-bucket.c mongoc-gridfs-bucket-file.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-handshake.c mongoc-host-list.c mongoc-http.c mongoc-index.c mongoc-init.c mongoc-interrupt.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-ocsp-cache.c mongoc-opcode.c mongoc-openssl.c mongoc-optional.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-api.c mongoc-server-description.c mongoc-server-monitor.c mongoc-server-stream.c mongoc-set.c mongoc-shared.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-gridfs-download.c mongoc-stream-gridfs-upload.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-timeout.c mongoc-topology-background-monitoring.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-ts-pool.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-concern.c service-gcp.c"

dnl Generated with: find src/libmongoc/src/utf8proc-2.8.0 -maxdepth 1 -name '*.c' ! -name 'utf8proc_data.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
dnl Note: utf8proc_data.c is included from utf8proc.c and should not be compiled directly
Comment on lines +424 to +425
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added ! -name 'utf8proc_data.c' to the find command in case someone decides to run this manually but update-submodule-sources.php has separate code to exclude utf8proc_data.c.

PHP_MONGODB_UTF8PROC_SOURCES="utf8proc.c"

dnl Generated with: find src/libmongoc/src/zlib-1.2.13 -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
PHP_MONGODB_ZLIB_SOURCES="adler32.c compress.c crc32.c deflate.c gzclose.c gzlib.c gzread.c gzwrite.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c"

Expand Down Expand Up @@ -455,6 +463,13 @@ if test "$PHP_MONGODB" != "no"; then
${ac_config_dir}/src/libmongoc/src/libmongoc/src/mongoc/mongoc-version.h
])

if test "x$bundled_utf8proc" = "xyes"; then
PHP_MONGODB_UTF8PROC_CFLAGS="$PHP_MONGODB_BUNDLED_CFLAGS $PHP_MONGODB_UTF8PROC_CFLAGS"
PHP_MONGODB_ADD_SOURCES([src/libmongoc/src/utf8proc-2.8.0/], $PHP_MONGODB_UTF8PROC_SOURCES, $PHP_MONGODB_UTF8PROC_CFLAGS)
PHP_MONGODB_ADD_INCLUDE([src/libmongoc/src/utf8proc-2.8.0/])
PHP_MONGODB_ADD_BUILD_DIR([src/libmongoc/src/utf8proc-2.8.0/])
fi

if test "x$bundled_zlib" = "xyes"; then
PHP_MONGODB_ZLIB_CFLAGS="$PHP_MONGODB_BUNDLED_CFLAGS $PHP_MONGODB_ZLIB_CFLAGS"
PHP_MONGODB_ADD_SOURCES([src/libmongoc/src/zlib-1.2.13/], $PHP_MONGODB_ZLIB_SOURCES, $PHP_MONGODB_ZLIB_CFLAGS)
Expand All @@ -464,6 +479,8 @@ if test "$PHP_MONGODB" != "no"; then
fi

if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" = "yes"; then
PHP_MONGODB_LIBMONGOCRYPT_CFLAGS="-DKMS_MSG_STATIC -DMLIB_USER"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relocated from above.


dnl Since libmongocrypt adds kms-message, we can enable AWS auth in this case
AC_SUBST(MONGOC_ENABLE_MONGODB_AWS_AUTH, 1)
AC_SUBST(MONGOCRYPT_ENABLE_TRACE, 1)
Expand Down
27 changes: 8 additions & 19 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if (PHP_MONGODB != "no") {
ADD_EXTENSION_DEP("mongodb", "openssl", false);

var PHP_MONGODB_CFLAGS="\
/D BSON_COMPILATION /D MONGOC_COMPILATION \
/D BSON_COMPILATION /D MONGOC_COMPILATION /D UTF8PROC_STATIC \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't bother adding system library detection for utf8proc on Windows, so we always build with this constant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good - I'm not sure whether we should rely on that library being available locally for people that download our DLLs, so compiling with bundled utf8proc seems like the logical choice.

/I" + configure_module_dirname + " \
/I" + configure_module_dirname + "/src \
/I" + configure_module_dirname + "/src/BSON \
Expand All @@ -98,6 +98,7 @@ if (PHP_MONGODB != "no") {
/I" + configure_module_dirname + "/src/libmongoc/src/libbson/src \
/I" + configure_module_dirname + "/src/libmongoc/src/libbson/src/jsonsl \
/I" + configure_module_dirname + "/src/libmongoc/src/libmongoc/src \
/I" + configure_module_dirname + "/src/libmongoc/src/utf8proc-2.8.0 \
";

// Condense whitespace in CFLAGS
Expand All @@ -119,6 +120,9 @@ if (PHP_MONGODB != "no") {
// Generated with: find src/libmongoc/src/libmongoc/src/mongoc -name '*.c' -print0 | cut -sz -d / -f 7- | sort -dz | tr '\000' ' '
var PHP_MONGODB_MONGOC_SOURCES="mcd-azure.c mcd-rpc.c mongoc-aggregate.c mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-client-side-encryption.c mongoc-cluster-aws.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypt.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-change-stream.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-error.c mongoc-find-and-modify.c mongoc-flags.c mongoc-generation-map.c mongoc-gridfs-bucket.c mongoc-gridfs-bucket-file.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-handshake.c mongoc-host-list.c mongoc-http.c mongoc-index.c mongoc-init.c mongoc-interrupt.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-ocsp-cache.c mongoc-opcode.c mongoc-openssl.c mongoc-optional.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-api.c mongoc-server-description.c mongoc-server-monitor.c mongoc-server-stream.c mongoc-set.c mongoc-shared.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-gridfs-download.c mongoc-stream-gridfs-upload.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-timeout.c mongoc-topology-background-monitoring.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-ts-pool.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-concern.c service-gcp.c";

// Generated with: find src/libmongoc/src/utf8proc-2.8.0 -maxdepth 1 -name '*.c' ! -name 'utf8proc_data.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
var PHP_MONGODB_UTF8PROC_SOURCES="utf8proc.c";

EXTENSION("mongodb", "php_phongo.c", null, PHP_MONGODB_CFLAGS);
MONGODB_ADD_SOURCES("/src", "phongo_apm.c phongo_bson.c phongo_bson_encode.c phongo_client.c phongo_compat.c phongo_error.c phongo_execute.c phongo_ini.c phongo_util.c");
MONGODB_ADD_SOURCES("/src/BSON", "Binary.c BinaryInterface.c Document.c Iterator.c DBPointer.c Decimal128.c Decimal128Interface.c Int64.c Javascript.c JavascriptInterface.c MaxKey.c MaxKeyInterface.c MinKey.c MinKeyInterface.c ObjectId.c ObjectIdInterface.c PackedArray.c Persistable.c Regex.c RegexInterface.c Serializable.c Symbol.c Timestamp.c TimestampInterface.c Type.c Undefined.c Unserializable.c UTCDateTime.c UTCDateTimeInterface.c functions.c");
Expand All @@ -129,6 +133,7 @@ if (PHP_MONGODB != "no") {
MONGODB_ADD_SOURCES("/src/libmongoc/src/libbson/src/bson", PHP_MONGODB_BSON_SOURCES);
MONGODB_ADD_SOURCES("/src/libmongoc/src/libbson/src/jsonsl", PHP_MONGODB_JSONSL_SOURCES);
MONGODB_ADD_SOURCES("/src/libmongoc/src/libmongoc/src/mongoc", PHP_MONGODB_MONGOC_SOURCES);
MONGODB_ADD_SOURCES("/src/libmongoc/src/utf8proc-2.8.0", PHP_MONGODB_UTF8PROC_SOURCES);

var bson_opts = {
BSON_BYTE_ORDER: 1234,
Expand Down Expand Up @@ -193,7 +198,7 @@ if (PHP_MONGODB != "no") {
MONGOC_ENABLE_SASL_CYRUS: 0,
MONGOC_ENABLE_SASL_GSSAPI: 0,
MONGOC_ENABLE_SASL_SSPI: 0,
MONGOC_ENABLE_ICU: 0,
MONGOC_ENABLE_SRV: 0,
MONGOC_ENABLE_RDTSCP: 0,
MONGOC_ENABLE_SHM_COUNTERS: 0,
MONGOC_HAVE_ASN1_STRING_GET0_DATA: 0,
Expand Down Expand Up @@ -327,23 +332,7 @@ if (PHP_MONGODB != "no") {
if (CHECK_LIB("dnsapi.lib", "mongodb", PHP_MONGODB) &&
CHECK_HEADER_ADD_INCLUDE("windns.h", "CFLAGS_MONGODB")) {
mongoc_opts.MONGOC_HAVE_DNSAPI = 1;
}

if (CHECK_LIB("icuuc.lib", "mongodb", PHP_MONGODB) &&
CHECK_HEADER_ADD_INCLUDE("unicode/utf.h", "CFLAGS_MONGODB")) {
mongoc_opts.MONGODB_ENABLE_ICU = 1;

ADD_FLAG("LIBS_MONGODB", "icudt.lib icuin.lib icuio.lib");

/* Compat for ICU before 58.1.*/
if (CHECK_LIB("icule.lib", "mongodb", PHP_MONGODB)) {
ADD_FLAG("LIBS_MONGODB", "icule.lib");
}
if (CHECK_LIB("iculx.lib", "mongodb", PHP_MONGODB)) {
ADD_FLAG("LIBS_MONGODB", "iculx.lib");
}

ADD_FLAG("CFLAGS_MONGODB", "/EHsc /D U_USING_ICU_NAMESPACE=1");
mongoc_opts.MONGOC_ENABLE_SRV = 1;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is conditionally enabled if we find dnsapi.lib. I assume the behavior is the same if we don't find it, and users will just get a runtime error when attempting to connect with a mongodb+srv:// URI.

}

if (typeof COMPILER_NAME === 'string') {
Expand Down
37 changes: 0 additions & 37 deletions scripts/autotools/libmongoc/CheckICU.m4

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/autotools/libmongoc/CheckResolv.m4
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
dnl Disable SRV until we find a library
AC_SUBST(MONGOC_ENABLE_SRV, 0)

dnl Disable Windows DNSAPI
AC_SUBST(MONGOC_HAVE_DNSAPI, 0)

Expand Down Expand Up @@ -97,6 +100,10 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
])
])

AS_IF([test "$found_resolv" = "yes"],[
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is set independently of whether we need to link a separate resolv library or can rely on libc.

AC_SUBST(MONGOC_ENABLE_SRV, 1)
])

if test "$libc_has_resolv" = "no"; then
LIBS="$old_LIBS"

Expand Down
40 changes: 40 additions & 0 deletions scripts/autotools/libmongoc/CheckUtf8Proc.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
PHP_ARG_WITH([mongodb-utf8proc],
[whether to use system or bundled utf8proc for SCRAM-SHA-256 SASLprep],
[AS_HELP_STRING([--with-mongodb-utf8proc=@<:@bundled/system@:>@],
[MongoDB: Enable utf8proc for SCRAM-SHA-256 SASLprep [default=bundled]])],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, ICU was an optional dependency. IIRC, MONGOC_ENABLE_ICU could be undefined and libmongoc would conditionally raise a runtime exception if SASLprep was needed but not possible.

Since utf8proc is vendored, libmongoc provides no mechanism to disable it. We default to bundled sources here for consistency with libmongoc (their boolean build flags default to "on").

[bundled],
[no])

found_utf8proc="no"
bundled_utf8proc="no"

AS_IF([test "$PHP_MONGODB_UTF8PROC" = "system"],[
PKG_CHECK_MODULES([PHP_MONGODB_UTF8PROC],[libutf8proc],[
PHP_MONGODB_BUNDLED_CFLAGS="$PHP_MONGODB_BUNDLED_CFLAGS $PHP_MONGODB_UTF8PROC_CFLAGS"
PHP_EVAL_LIBLINE([$PHP_MONGODB_UTF8PROC_LIBS],[MONGODB_SHARED_LIBADD])
found_utf8proc="yes"
],[
PHP_CHECK_LIBRARY([utf8proc],
[utf8proc_NFKC],
[have_utf8proc_lib="yes"],
[have_utf8proc_lib="no"])

AC_CHECK_HEADER([utf8proc.h],
[have_utf8proc_headers=yes],
[have_utf8proc_headers=no])

if test "$have_utf8proc_lib" = "yes" -a "$have_utf8proc_headers" = "yes"; then
PHP_ADD_LIBRARY([utf8proc],,[MONGODB_SHARED_LIBADD])
found_utf8proc="yes"
fi
Comment on lines +12 to +29
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I tested both of these code paths locally.

$ pkg-config  libutf8proc --libs
-lutf8proc
pkg-config  libutf8proc --cflags
-DUTF8PROC_EXPORTS

Configure only shows -lutf8proc, but I do see -DUTF8PROC_EXPORTS added to $PHP_MONGODB_BUNDLED_CFLAGS when using pkg-config. I'm not sure if it's required for the second branch. /cc @joshbsiegel

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think UTF8PROC_EXPORTS is relevant, as it's only referenced in the following conditional for Windows:

https://github.com/JuliaStrings/utf8proc/blob/1cb28a66ca79a0845e99433fd1056257456cef8b/utf8proc.h#L123-L137

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I didn't have to do anything with UTF8PROC_EXPORTS when making changes in the C driver.

])

if test "$PHP_MONGODB_UTF8PROC" = "system" -a "$found_utf8proc" = "no"; then
AC_MSG_ERROR([utf8proc library and development headers could not be found])
fi
])

AS_IF([test "$PHP_MONGODB_UTF8PROC" = "bundled"],[
PHP_MONGODB_UTF8PROC_CFLAGS="$PHP_MONGODB_UTF8PROC_CFLAGS -DUTF8PROC_STATIC"
bundled_utf8proc="yes"
])
6 changes: 6 additions & 0 deletions scripts/update-submodule-sources.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'PHP_MONGODB_BSON_SOURCES' => 'src/libmongoc/src/libbson/src/bson',
'PHP_MONGODB_JSONSL_SOURCES' => 'src/libmongoc/src/libbson/src/jsonsl',
'PHP_MONGODB_MONGOC_SOURCES' => 'src/libmongoc/src/libmongoc/src/mongoc',
'PHP_MONGODB_UTF8PROC_SOURCES' => 'src/libmongoc/src/utf8proc-2.8.0',
'PHP_MONGODB_ZLIB_SOURCES' => 'src/libmongoc/src/zlib-1.2.13',
'PHP_MONGODB_MONGOCRYPT_SOURCES' => 'src/libmongocrypt/src',
'PHP_MONGODB_MONGOCRYPT_CRYPTO_SOURCES' => 'src/libmongocrypt/src/crypto',
Expand All @@ -24,6 +25,11 @@

$files = trim(shell_exec(sprintf($cmd, $path, $cutNth)));

// Note: utf8proc_data.c is included from utf8proc.c and should not be compiled directly
if ($var === 'PHP_MONGODB_UTF8PROC_SOURCES') {
$files = trim(str_replace('utf8proc_data.c', '', $files));
}

$patterns[] = sprintf('/(%s=")([^"]*)(";?)/', $var);
$replacements[] = '$1' . $files . '$3';
}
Expand Down
2 changes: 1 addition & 1 deletion src/LIBMONGOC_VERSION_CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.24.1
1.25.0-20230718+git75db6e1af6
2 changes: 1 addition & 1 deletion src/libmongoc
Submodule libmongoc updated 170 files