Skip to content

Commit

Permalink
[6.0]Optimize config.m4 (#5361)
Browse files Browse the repository at this point in the history
* optimize config.m4

* optimize config.m4

* remove unused code
  • Loading branch information
NathanFreeman committed Jun 6, 2024
1 parent 89d87cc commit df4f664
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 38 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ext.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: ext-swoole
on: [ push, pull_request ]

env:
CPPFLAGS: "-I/opt/homebrew/opt/c-ares/include/ -I/opt/homebrew/opt/pcre2/include/ -I/opt/homebrew/opt/openssl/include/"
LDFLAGS: "-L/opt/homebrew/opt/c-ares/lib -L/opt/homebrew/opt/openssl/lib/"
CPPFLAGS: "-I/opt/homebrew/opt/pcre2/include/"

jobs:
build-ubuntu-latest:
Expand Down Expand Up @@ -66,7 +65,7 @@ jobs:
--enable-swoole-curl --enable-debug-log &&
make clean && make -j$(sysctl -n hw.ncpu)
- name: build7
run: ./configure CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" --enable-sockets --enable-mysqlnd --enable-openssl --enable-swoole-curl
run: ./configure CPPFLAGS="${CPPFLAGS}" --enable-sockets --enable-mysqlnd --enable-openssl --enable-swoole-curl
--enable-debug-log --enable-cares &&
make clean && make -j$(sysctl -n hw.ncpu)

Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
pull_request:

env:
CPPFLAGS: "-I/opt/homebrew/opt/c-ares/include/ -I/opt/homebrew/opt/pcre2/include/ -I/opt/homebrew/opt/openssl/include/"
LDFLAGS: "-L/opt/homebrew/opt/c-ares/lib -L/opt/homebrew/opt/openssl/lib/"
CPPFLAGS: "-I/opt/homebrew/opt/pcre2/include/"

jobs:
linux:
Expand Down Expand Up @@ -108,7 +107,7 @@ jobs:
- name: Build Swoole
run: |
phpize
./configure LDFLAGS="${LDFLAGS}" CPPFLAGS="${CPPFLAGS}" --enable-openssl --enable-mysqlnd --enable-swoole-curl --enable-cares
./configure CPPFLAGS="${CPPFLAGS}" --enable-openssl --enable-mysqlnd --enable-swoole-curl --enable-cares
make -j$(sysctl -n hw.ncpu)
sudo make install
php --ri swoole
Expand Down
73 changes: 42 additions & 31 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ PHP_ARG_WITH([nghttp2_dir],
[AS_HELP_STRING([[--with-nghttp2-dir[=DIR]]],
[Include nghttp2 support])], [no], [no])

PHP_ARG_WITH([jemalloc_dir],
[dir of jemalloc],
[AS_HELP_STRING([[--with-jemalloc-dir[=DIR]]],
[Include jemalloc support])], [no], [no])

PHP_ARG_ENABLE([asan],
[enable asan],
[AS_HELP_STRING([--enable-asan],
Expand Down Expand Up @@ -372,7 +367,6 @@ if test "$PHP_SWOOLE" != "no"; then
AC_CHECK_LIB(pthread, pthread_mutexattr_setrobust, AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_SETROBUST, 1, [have pthread_mutexattr_setrobust]))
AC_CHECK_LIB(pthread, pthread_mutex_consistent, AC_DEFINE(HAVE_PTHREAD_MUTEX_CONSISTENT, 1, [have pthread_mutex_consistent]))
AC_CHECK_LIB(pcre, pcre_compile, AC_DEFINE(HAVE_PCRE, 1, [have pcre]))
AC_CHECK_LIB(cares, ares_gethostbyname, AC_DEFINE(HAVE_CARES, 1, [have c-ares]))

if test "$PHP_SWOOLE_DEV" = "yes"; then
AX_CHECK_COMPILE_FLAG(-Wbool-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wbool-conversion")
Expand Down Expand Up @@ -410,6 +404,9 @@ if test "$PHP_SWOOLE" != "no"; then
fi

if test "$PHP_SWOOLE_CURL" = "yes"; then
PKG_CHECK_MODULES([CURL], [libcurl >= 7.56.0])
PHP_EVAL_LIBLINE($CURL_LIBS, SWOOLE_SHARED_LIBADD)
PHP_EVAL_INCLINE($CURL_CFLAGS)
AC_DEFINE(SW_USE_CURL, 1, [do we enable cURL native client])
fi

Expand Down Expand Up @@ -847,15 +844,24 @@ EOF
PHP_ADD_LIBRARY(z, 1, SWOOLE_SHARED_LIBADD)
])

if test "$PHP_BROTLI" = "yes"; then
AC_CHECK_LIB(brotlienc, BrotliEncoderCreateInstance, [
AC_CHECK_LIB(brotlidec, BrotliDecoderCreateInstance, [
AC_DEFINE(SW_HAVE_COMPRESSION, 1, [have compression])
AC_DEFINE(SW_HAVE_BROTLI, 1, [have brotli encoder])
PHP_ADD_LIBRARY(brotlienc, 1, SWOOLE_SHARED_LIBADD)
PHP_ADD_LIBRARY(brotlidec, 1, SWOOLE_SHARED_LIBADD)
])
])
if test "$PHP_BROTLI" != "no" || test "$PHP_BROTLI_DIR" != "no"; then
if test "$PHP_BROTLI_DIR" != "no"; then
PHP_ADD_INCLUDE("${PHP_BROTLI_DIR}/include")
PHP_ADD_LIBRARY_WITH_PATH(brotli, "${PHP_BROTLI_DIR}/${PHP_LIBDIR}")
PHP_ADD_LIBRARY_WITH_PATH(brotlienc, "${PHP_BROTLI_DIR}/${PHP_LIBDIR}")
PHP_ADD_LIBRARY_WITH_PATH(brotlidec, "${PHP_BROTLI_DIR}/${PHP_LIBDIR}")
else
PKG_CHECK_MODULES([BROTLIENC], [libbrotlienc])
PHP_EVAL_LIBLINE($BROTLIENC_LIBS, SWOOLE_SHARED_LIBADD)
PHP_EVAL_INCLINE($BROTLIENC_CFLAGS)

PKG_CHECK_MODULES([BROTLIDEC], [libbrotlidec])
PHP_EVAL_LIBLINE($BROTLIDEC_LIBS, SWOOLE_SHARED_LIBADD)
PHP_EVAL_INCLINE($BROTLIDEC_CFLAGS)
fi

AC_DEFINE(SW_HAVE_COMPRESSION, 1, [have compression])
AC_DEFINE(SW_HAVE_BROTLI, 1, [have brotli encoder])
fi

PHP_ADD_LIBRARY(pthread)
Expand Down Expand Up @@ -908,15 +914,18 @@ EOF
fi

if test "$PHP_CARES" = "yes"; then
PKG_CHECK_MODULES([CARES], [libcares])
PHP_EVAL_LIBLINE($CARES_LIBS, SWOOLE_SHARED_LIBADD)
PHP_EVAL_INCLINE($CARES_CFLAGS)
AC_DEFINE(SW_USE_CARES, 1, [do we enable c-ares support])
PHP_ADD_LIBRARY(cares, 1, SWOOLE_SHARED_LIBADD)
AC_DEFINE(HAVE_CARES, 1, [have c-ares])
fi

if test "$PHP_IOURING" = "yes"; then
AC_CHECK_LIB(uring, io_uring_queue_init, [
AC_DEFINE(SW_USE_IOURING, 1, [have io_uring])
PHP_ADD_LIBRARY(uring, 1, SWOOLE_SHARED_LIBADD)
])
PKG_CHECK_MODULES([URING], [liburing])
PHP_EVAL_LIBLINE($URING_LIBS, SWOOLE_SHARED_LIBADD)
PHP_EVAL_INCLINE($URING_CFLAGS)
AC_DEFINE(SW_USE_IOURING, 1, [have io_uring])
fi

AC_SWOOLE_CPU_AFFINITY
Expand Down Expand Up @@ -965,13 +974,23 @@ EOF
fi

if test "$PHP_OPENSSL" != "no" || test "$PHP_OPENSSL_DIR" != "no"; then
if test "$PHP_OPENSSL_DIR" != "no"; then
if test "$PHP_OPENSSL_DIR" != "no"; then
PHP_ADD_INCLUDE("${PHP_OPENSSL_DIR}/include")
PHP_ADD_LIBRARY_WITH_PATH(ssl, "${PHP_OPENSSL_DIR}/${PHP_LIBDIR}")

PHP_ADD_LIBRARY(ssl, 1, SWOOLE_SHARED_LIBADD)
PHP_ADD_LIBRARY(crypto, 1, SWOOLE_SHARED_LIBADD)
else
PKG_CHECK_MODULES([SSL], [libssl])
PHP_EVAL_LIBLINE($SSL_LIBS, SWOOLE_SHARED_LIBADD)
PHP_EVAL_INCLINE($SSL_CFLAGS)

PKG_CHECK_MODULES([CRYPTO], [libcrypto])
PHP_EVAL_LIBLINE($CRYPTO_LIBS, SWOOLE_SHARED_LIBADD)
PHP_EVAL_INCLINE($CRYPTO_CFLAGS)
fi

AC_DEFINE(SW_USE_OPENSSL, 1, [enable openssl support])
PHP_ADD_LIBRARY(ssl, 1, SWOOLE_SHARED_LIBADD)
PHP_ADD_LIBRARY(crypto, 1, SWOOLE_SHARED_LIBADD)
fi

if test "$PHP_BROTLI_DIR" != "no"; then
Expand All @@ -984,19 +1003,11 @@ EOF
fi

if test "$PHP_NGHTTP2_DIR" != "no"; then
AC_DEFINE(SW_USE_SYSTEM_LIBNGHTTP2, 1, [Use the system libnghttp2])
PHP_ADD_INCLUDE("${PHP_NGHTTP2_DIR}/include")
PHP_ADD_LIBRARY_WITH_PATH(nghttp2, "${PHP_NGHTTP2_DIR}/${PHP_LIBDIR}")
PHP_ADD_LIBRARY(nghttp2, 1, SWOOLE_SHARED_LIBADD)
fi

if test "$PHP_JEMALLOC_DIR" != "no"; then
AC_DEFINE(SW_USE_JEMALLOC, 1, [use jemalloc])
PHP_ADD_INCLUDE("${PHP_JEMALLOC_DIR}/include")
PHP_ADD_LIBRARY_WITH_PATH(jemalloc, "${PHP_JEMALLOC_DIR}/${PHP_LIBDIR}")
PHP_ADD_LIBRARY(jemalloc, 1, SWOOLE_SHARED_LIBADD)
fi

PHP_ADD_LIBRARY(pthread, 1, SWOOLE_SHARED_LIBADD)

if test "$PHP_MYSQLND" = "yes"; then
Expand Down
2 changes: 1 addition & 1 deletion tests/swoole_curl/multi/bug4393.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ run(function () {
while ($n--) {
$s = microtime(true);
$test();
Assert::lessThan(microtime(true) - $s, 2.0);
Assert::lessThan(microtime(true) - $s, 3.0);
}

echo 'Done' . PHP_EOL;
Expand Down
5 changes: 5 additions & 0 deletions tests/swoole_runtime/file_hook/bug_4327.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Swoole\Runtime::enableCoroutine($flags = SWOOLE_HOOK_ALL);

function createDirectories($protocol = "")
{
if (defined('SWOOLE_THREAD')) {
echo "SUCCESS".PHP_EOL;
return;
}

$barrier = Barrier::make();
$first = "$protocol/".rand(0, 1000);
$second = "/".rand(0, 1000);
Expand Down

0 comments on commit df4f664

Please sign in to comment.