Title: Porting Snuffleupagus to PHP8
Date: 2021-02-01 12:00

Porting [Snuffleupagus](https://snuffleupagus.rtfd.io) to PHP8 was tedious,
but not hard, thanks to PHP's [nice page](https://www.php.net/manual/en/migration80.php)
on how to migrate extensions from PHP7 to [PHP8.]( https://wiki.php.net/rfc/php8 ),

- `ZEND_ARG_IS_VARIADIC(execute_data->func->op_array.arg_info)` is
  [used](https://github.com/jvoisin/snuffleupagus/commit/394edbf3b5232c30dd3019f8c3a5dfadc310884f)
	instead of `execute_data->func->op_array.arg_info->is_variadic`: 
- `TSRMLS_C` and `TSRMLS_FETCH`, relics of some [thread-safety related black-magic](http://blog.golemon.com/2006/06/what-heck-is-tsrmlscc-anyway.html)
  that never really worked aren't defined anymore.
- Some  `char*` function parameters were *constified*,
  [changing signatures]( https://github.com/jvoisin/snuffleupagus/commit/93cc22bfb57fc881889165ead1adc94dda30dfc4).
- The biggest piece was the eternal [pcre](http://www.pcre.org/) to [pcre2](http://www.pcre.org/current/doc/html/pcre2.html) "situation".
  I had oh so much __fun__ dealing with bundled pcre, bundled pcre2, non-bundled pcre2,
	weird headers, inclusion order, … across
	different version of php, because we're still supporting php7.0.

To debug everything in PHP8, I used [Alpine Linux](https://www.alpinelinux.org/)
in a [docker image](https://hub.docker.com/_/php/), resulting in the following
mystery that I took way to much time to solve:

```bash
# git clone https://github.com/jvoisin/snuffleupagus; cd snuffleupagus
#  make tests
cd src; phpize
Configuring for:
PHP Api Version:         20200930
Zend Module Api No:      20200930
Zend Extension Api No:   420200930
cd src; ./configure --enable-snuffleupagus
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... no
checking for cc... cc
checking whether the C compiler works... no
configure: error: in `/var/www/html/snuffleupagus/src':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** [Makefile:10: release] Error 77
# tail config.log
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared
#
```

The solution is simply to `apk add musl-dev`.

You can check Snuffleupagus'
[commits](https://github.com/jvoisin/snuffleupagus/commits/master?after=484bb5613be54cc37d7b2136eca9e2f4e3eb6f1a+34&branch=master)
from December 2020 if you want the gory details.
