diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 50bfe83..3e07ea5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,8 +6,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - arch: ["amd64", "arm64v8"] - version: ["8.1", "8.2"] + arch: ["amd64", "arm64v8", "s390x"] + version: ["8.1", "8.2", "8.3"] type: ["cli", "zts"] distro: ["bullseye", "alpine"] steps: @@ -27,6 +27,10 @@ jobs: - name: Run tests run: | docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION=1 dev + - name: Test extension with PHP Debug Build + if: matrix.arch == 'amd64' + run: | + docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_DEBUG=1 dev - name: Test extension with Valgrind if: matrix.arch == 'amd64' run: | diff --git a/Dockerfile b/Dockerfile index f11b177..e6cb7ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,10 +4,12 @@ ARG TAG=8.2-cli FROM ${IMAGE}:${TAG} ARG PSKEL_SKIP_DEBUG="" +ARG PSKEL_EXTRA_CONFIGURE_OPTIONS="" ENV USE_ZEND_ALLOC=0 ENV ZEND_DONT_UNLOAD_MODULES=1 ENV PSKEL_SKIP_DEBUG=${PSKEL_SKIP_DEBUG} +ENV PSKEL_EXTRA_CONFIGURE_OPTIONS=${PSKEL_EXTRA_CONFIGURE_OPTIONS} RUN if test -f "/etc/debian_version"; then \ apt-get update && \ @@ -17,11 +19,12 @@ RUN if test -f "/etc/debian_version"; then \ docker-php-source extract && \ cd "/usr/src/php" && \ CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \ - --includedir="/usr/local/include/gcc-debug-php" --program-prefix="gcc-debug-" \ - --disable-cgi --disable-fpm --disable-phpdbg --enable-cli \ + --includedir="/usr/local/include/gcc-valgrind-php" --program-prefix="gcc-valgrind-" \ + --disable-cgi --disable-fpm --enable-cli \ --enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \ --enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \ --with-valgrind \ + ${PSKEL_EXTRA_CONFIGURE_OPTIONS} \ --enable-option-checking=fatal && \ make -j$(nproc) && \ make install && \ @@ -30,11 +33,25 @@ RUN if test -f "/etc/debian_version"; then \ docker-php-source extract && \ cd "/usr/src/php" && \ CC=clang CXX=clang++ CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure \ - --includedir="/usr/local/include/clang-debug-php" --program-prefix="clang-debug-" \ - --disable-cgi --disable-all --disable-fpm --disable-phpdbg --enable-cli \ + --includedir="/usr/local/include/clang-sanitizer-php" --program-prefix="clang-sanitizer-" \ + --disable-cgi --disable-all --disable-fpm --enable-cli \ --enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \ --enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \ --enable-memory-sanitizer \ + ${PSKEL_EXTRA_CONFIGURE_OPTIONS} \ + --enable-option-checking=fatal && \ + make -j$(nproc) && \ + make install && \ + cd - && \ + docker-php-source delete && \ + docker-php-source extract && \ + cd "/usr/src/php" && \ + CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \ + --includedir="/usr/local/include/debug-php" --program-prefix="debug-" \ + --disable-cgi --disable-fpm --enable-cli \ + --enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \ + --enable-debug "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \ + ${PSKEL_EXTRA_CONFIGURE_OPTIONS} \ --enable-option-checking=fatal && \ make -j$(nproc) && \ make install && \ @@ -47,11 +64,25 @@ RUN if test -f "/etc/debian_version"; then \ docker-php-source extract && \ cd "/usr/src/php" && \ CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \ - --includedir="/usr/local/include/gcc-debug-php" --program-prefix="gcc-debug-" \ - --disable-cgi --disable-fpm --disable-phpdbg --enable-cli \ + --includedir="/usr/local/include/gcc-valgrind-php" --program-prefix="gcc-valgrind-" \ + --disable-cgi --disable-fpm --enable-cli \ --enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \ --enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \ --with-valgrind \ + ${PSKEL_EXTRA_CONFIGURE_OPTIONS} \ + --enable-option-checking=fatal && \ + make -j$(nproc) && \ + make install && \ + cd - && \ + docker-php-source delete && \ + docker-php-source extract && \ + cd "/usr/src/php" && \ + CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \ + --includedir="/usr/local/include/debug-php" --program-prefix="debug-" \ + --disable-cgi --disable-fpm --enable-cli \ + --enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \ + --enable-debug "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \ + ${PSKEL_EXTRA_CONFIGURE_OPTIONS} \ --enable-option-checking=fatal && \ make -j$(nproc) && \ make install && \ diff --git a/README.md b/README.md index 7fe3105..50df82c 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,15 @@ A debug build of PHP is included in advance. Debug builds using GCC and Clang ar They each have the following binary prefixes. The build toolchains are the same. -- `gcc-debug-php` -- `clang-debug-php` +- `debug-php` +- `gcc-valgrind-php` +- `clang-sanitizer-php` For example, the method to test the extension using GCC + Valgrind is as follows: ``` -# gcc-debug-phpize -# ./configure --with-php-config=$(which gcc-debug-php-config) +# gcc-valgrind-phpize +# ./configure --with-php-config=$(which gcc-valgrind-php-config) # TEST_PHP_ARGS="-q -m --show-diff" make -j$(nproc) test ``` @@ -37,7 +38,7 @@ For example, the method to test the extension using GCC + Valgrind is as follows Yes. Build using the debug version of PHP and run as follows: ``` -# gdb --args gcc-debug-php -dextension=./modules/your_extension_name.so example.php +# gdb --args gcc-valgrind-php -dextension=./modules/your_extension_name.so example.php ``` #### Can I develop using something other than Visual Studio Code? diff --git a/ci.sh b/ci.sh index c301820..a22b31f 100755 --- a/ci.sh +++ b/ci.sh @@ -3,9 +3,10 @@ case "${1}" in "") ;; "test") TEST_EXTENSION=1;; + "debug") TEST_EXTENSION_DEBUG=1;; "gcc"|"valgrind") TEST_EXTENSION_VALGRIND=1;; "clang"|"msan") TEST_EXTENSION_MSAN=1;; - *) printf "Pskel CI\nusage:\n\t%s\t: %s\n\t%s\t: %s\n\t%s\t: %s\n" "test" "Test extension with pre-installed PHP binary. [bin: $(which "php")]" "gcc" "Test extension with GCC binary with Valgrind. [bin: $(which "gcc-debug-php")]" "clang" "Test extension with Clang binary with MemorySanitizer. [bin: $(which "clang-debug-php")]"; exit 0;; + *) printf "Pskel CI\nusage:\n\t%s\t: %s\n\t%s\t: %s\n\t%s\t: %s\n" "test" "Test extension with pre-installed PHP binary. [bin: $(which "php")]" "gcc" "Test extension with GCC binary with Valgrind. [bin: $(which "gcc-valgrind-php")]" "clang" "Test extension with Clang binary with MemorySanitizer. [bin: $(which "clang-sanitizer-php")]"; exit 0;; esac echo "[Pskel CI] BEGIN TEST" @@ -21,16 +22,27 @@ else echo "[Pskel CI] skip: TEST_EXTENSION is not set" fi +if test "${TEST_EXTENSION_DEBUG}" != ""; then + cd "/ext" + debug-phpize + ./configure --with-php-config="$(which debug-php-config)" + make clean + make -j"$(nproc)" + TEST_PHP_ARGS="--show-diff -q" make test +else + echo "[Pskel CI] skip: TEST_EXTENSION_DEBUG is not set" +fi + if test "${TEST_EXTENSION_VALGRIND}" != ""; then - if type "gcc-debug-php" > /dev/null 2>&1; then + if type "gcc-valgrind-php" > /dev/null 2>&1; then cd "/ext" - gcc-debug-phpize - ./configure --with-php-config="$(which gcc-debug-php-config)" + gcc-valgrind-phpize + ./configure --with-php-config="$(which gcc-valgrind-php-config)" make clean make -j"$(nproc)" TEST_PHP_ARGS="--show-diff -q -m" make test else - echo "[Pskel CI] missing gcc-debug-php" + echo "[Pskel CI] missing gcc-valgrind-php" exit 1 fi else @@ -38,15 +50,15 @@ else fi if test "${TEST_EXTENSION_MSAN}" != ""; then - if type "clang-debug-php" > /dev/null 2>&1; then + if type "clang-sanitizer-php" > /dev/null 2>&1; then cd "/ext" - clang-debug-phpize - CC="clang" CXX="clang++" CFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC" CPPFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC ${CPPFLAGS}" LDFLAGS="-fsanitize=memory" ./configure --with-php-config="$(which clang-debug-php-config)" + clang-sanitizer-phpize + CC="clang" CXX="clang++" CFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC" CPPFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC ${CPPFLAGS}" LDFLAGS="-fsanitize=memory" ./configure --with-php-config="$(which clang-sanitizer-php-config)" make clean CFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC ${CFLAGS}" CPPFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC ${CPPFLAGS}" LDFLAGS="-fsanitize=memory" make -j"$(nproc)" TEST_PHP_ARGS="--show-diff -q --msan" make test else - echo "[Pskel CI] missing clang-debug-php" + echo "[Pskel CI] missing clang-sanitizer-php" exit 1 fi else