Skip to content
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

check linux kernel support iouring feature #20

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
ubuntu-native-build:
if: 1
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: native ubuntu install swoole
Expand Down Expand Up @@ -35,12 +35,12 @@ jobs:
- rockylinux:9.3
- fedora:41
- archlinux:latest
- php:8.3-zts-alpine3.20
- php:8.2-zts-alpine3.20
- php:8.1-zts-alpine3.20
- php:8.1-zts-bullseye
- php:8.2-zts-bullseye
- php:8.3-zts-bullseye
# - php:8.3-zts-alpine3.20
# - php:8.2-zts-alpine3.20
# - php:8.1-zts-alpine3.20
# - php:8.1-zts-bullseye
# - php:8.2-zts-bullseye
# - php:8.3-zts-bullseye

steps:
- uses: actions/checkout@v4
Expand All @@ -61,7 +61,7 @@ jobs:
strategy:
matrix:
macos_version:
- macos-12
# - macos-12
- macos-13
- macos-14
steps:
Expand Down
44 changes: 34 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ while [ $# -gt 0 ]; do
VERSION_LATEST=1
;;
--swoole-version)

if test -n "$2"; then
X_SWOOLE_VERSION="$2"
fi
Expand Down Expand Up @@ -273,6 +272,14 @@ install_php_ext_swoole_dependent_library() {
brew install c-ares libpq unixodbc brotli curl pcre2
;;
Linux)
LINUX_VERSION=$(uname -r | cut -d '-' -f 1)
LINUX_MAJOR_VERSION=$(echo $LINUX_VERSION | cut -d '.' -f 1)
LINUX_MINOR_VERSION=$(echo $LINUX_VERSION | cut -d '.' -f 2)
LINUX_KERNEL_SUPPORT_IO_URING_FEATURE=0
# shellcheck disable=SC2210
if test $LINUX_MAJOR_VERSION -gt 6 || (test $LINUX_MAJOR_VERSION -eq 6 && test $LINUX_MINOR_VERSION -ge 7); then
LINUX_KERNEL_SUPPORT_IO_URING_FEATURE=1
fi
OS_RELEASE="$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '\n' | tr -d '\"')"
case "$OS_RELEASE" in
'rocky' | 'almalinux' | 'alinux' | 'anolis' | 'fedora' | 'openEuler' | 'hce') # | 'amzn' | 'ol' | 'rhel' | 'centos' # 未测试
Expand All @@ -284,6 +291,8 @@ install_php_ext_swoole_dependent_library() {
yum install -y autoconf automake libtool cmake bison gettext zip unzip xz
yum install -y pkg-config bzip2 flex which
yum install -y c-ares-devel libcurl-devel pcre-devel postgresql-devel unixODBC brotli-devel sqlite-devel openssl-devel
yum install -y bc
yum install -y liburing

;;
'debian' | 'ubuntu' | 'kali')
Expand All @@ -301,6 +310,7 @@ install_php_ext_swoole_dependent_library() {
apt-get install -y libc-ares-dev libcurl4-openssl-dev
apt-get install -y libpcre3 libpcre3-dev libpq-dev libsqlite3-dev unixodbc-dev
apt-get install -y libbrotli-dev liburing-dev
apt-get install -y bc

;;
'alpine')
Expand Down Expand Up @@ -474,33 +484,47 @@ install_php_ext_swoole() {

case "$OS" in
Darwin)
BREW_PREFIX=$(echo $(brew --prefix) | tr -d '\n')
case "$ARCH" in
x86_64)
export PKG_CONFIG_PATH=/usr/local/opt/libpq/lib/pkgconfig/:/usr/local/opt/unixodbc/lib/pkgconfig/
SWOOLE_ODBC_OPTIONS="--with-swoole-odbc=unixODBC,/usr/local/opt/unixodbc/"
export PKG_CONFIG_PATH=${BREW_PREFIX}/opt/libpq/lib/pkgconfig/:${BREW_PREFIX}/opt/unixodbc/lib/pkgconfig/
SWOOLE_ODBC_OPTIONS="--with-swoole-odbc=unixODBC,${BREW_PREFIX}/opt/unixodbc/"
;;
arm64)
export PKG_CONFIG_PATH=/opt/homebrew/opt/libpq/lib/pkgconfig/:/opt/homebrew/opt/unixodbc/lib/pkgconfig/
export PKG_CONFIG_PATH=${BREW_PREFIX}/opt/libpq/lib/pkgconfig/:${BREW_PREFIX}/opt/unixodbc/lib/pkgconfig/
# /opt/homebrew/opt/pcre2/lib/pkgconfig
# export PATH=/opt/homebrew/opt/pcre2/bin/:$PATH
php-config --prefix
ln -s /opt/homebrew/opt/pcre2/include/pcre2.h $(php-config --prefix)/include/php/ext/pcre/pcre2.h
ln -s ${BREW_PREFIX}/opt/pcre2/include/pcre2.h $(php-config --prefix)/include/php/ext/pcre/pcre2.h

SWOOLE_ODBC_OPTIONS="--with-swoole-odbc=unixODBC,/opt/homebrew/opt/unixodbc/"
SWOOLE_ODBC_OPTIONS="--with-swoole-odbc=unixODBC,${BREW_PREFIX}/opt/unixodbc/"
;;
esac
;;
Linux)
HAVE_IOURING_FUTEX=0
if test ${LINUX_KERNEL_SUPPORT_IO_URING_FEATURE} -eq 1; then
{
URING_VERSION=$(pkg-config --modversion liburing)
IOURING_MAJOR_VERSION=$(echo $URING_VERSION | cut -d '.' -f 1)
IOURING_MINOR_VERSION=$(echo $URING_VERSION | cut -d '.' -f 2)
if test $IOURING_MAJOR_VERSION -gt 2 || (test $IOURING_MAJOR_VERSION -eq 2 && test $IOURING_MINOR_VERSION -ge 6); then
HAVE_IOURING_FUTEX=1
fi
} || {
echo $?
}
fi
OS_RELEASE="$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '\n' | tr -d '\"')"
case "$OS_RELEASE" in
'rocky' | 'almalinux' | 'alinux' | 'anolis' | 'fedora' | 'openEuler' | 'hce') # | 'amzn' | 'ol' | 'rhel' | 'centos' # 未测试
SWOOLE_ODBC_OPTIONS="" # 缺少 unixODBC-devel
;;
'debian' | 'ubuntu' | 'kali') # 'raspbian' | 'deeping'| 'uos' | 'kylin'
if test -f /.dockerenv -a -x "$(which docker-php-source)" -a -x "$(which docker-php-ext-enable)"; then
SWOOLE_IO_URING=' '
else
SWOOLE_IO_URING=' --enable-iouring '
if test ${HAVE_IOURING_FUTEX} -eq 1; then
SWOOLE_IO_URING=' --enable-iouring '
fi
fi

SWOOLE_ODBC_OPTIONS="--with-swoole-odbc=unixODBC,/usr"
Expand All @@ -527,6 +551,7 @@ install_php_ext_swoole() {

./configure --help

# --enable-swoole-pgsql \
./configure \
--with-php-config="${PHP_CONFIG}" \
${SWOOLE_DEBUG_OPTIONS} \
Expand All @@ -536,7 +561,6 @@ install_php_ext_swoole() {
--enable-cares \
--enable-swoole-curl \
${SWOOLE_OPTIONS} \
--enable-swoole-pgsql \
--enable-swoole-sqlite \
${SWOOLE_ODBC_OPTIONS} \
${SWOOLE_IO_URING} \
Expand Down
11 changes: 11 additions & 0 deletions test/connection-swoole-install-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)

cd ${__DIR__}

docker exec -it swoole-install-dev sh
34 changes: 34 additions & 0 deletions test/linux-os-origin-mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}

# use china mirror
# sh test/linux-os-origin-mirror.sh --mirror [ china | ustc | tuna ]

MIRROR=''
while [ $# -gt 0 ]; do
case "$1" in
--mirror)
MIRROR="$2"
;;
--*)
echo "no found mirror option $1"
;;
esac
shift $(($# > 0 ? 1 : 0))
done

case "$MIRROR" in
china | tuna | ustc)
test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save
test "$MIRROR" = "china" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
test "$MIRROR" = "tuna" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
test "$MIRROR" = "ustc" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
;;
esac
apk update
40 changes: 40 additions & 0 deletions test/run-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
__PROJECT__=$(
cd ${__DIR__}/../
pwd
)
cd ${__PROJECT__}

{
docker stop swoole-install-dev
sleep 5
} || {
echo $?
}
cd ${__DIR__}

IMAGE=alpine:3.20

MIRROR=''
while [ $# -gt 0 ]; do
case "$1" in
--mirror)
MIRROR="$2"
case "$MIRROR" in
china | openatom)
IMAGE="hub.atomgit.com/library/alpine:3.20"
;;
esac
;;
esac
shift $(($# > 0 ? 1 : 0))
done

cd ${__DIR__}
docker run --rm --name swoole-install-dev -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null
Loading