Title: Making snuffleupagus run on Alpine Linux
Date: 2019-01-12 19:30

This is a short blogpost about an issue that I faced when I wanted to make
[Snuffleupagus](https://snuffleupagus.rtfd.io)' testsuite run on Alpine Linux.

No errors during the compilation, but when I tried to run the testsuite the
following error appeared:

```
PHP Warning:  PHP Startup: Unable to load dynamic library 'snuffleupagus.so' (tried: /builds/jvoisin/snuffleupagus/src/modules/snuffleupagus.so (Error relocating /builds/jvoisin/snuffleupagus/src/modules/snuffleupagus.so: ps_globals: symbol not found), /builds/jvoisin/snuffleupagus/src/modules/snuffleupagus.so.so (Error loading shared library /builds/jvoisin/snuffleupagus/src/modules/snuffleupagus.so.so: No such file or directory)) in Unknown on line 0
```

Five minutes of web searches didn't yield any obvious solution, and instead of
looking at php's source code for clues, I lazily asked on Alpine's IRC, where
[ncopa](https://twitter.com/n_copa) (thanks!) found that I wasn't the only person with
[this issue](https://github.com/igbinary/igbinary/commit/491c5468ecb06bd5d5ee99e1583ed8ae32d8fc09).

A quick glance at php's source code confirmed that `php_ps_globals` is indeed
defined in `ext/session/php_session.h`, and that sessions support isn't
[necessarily builtin](http://php.net/manual/en/session.installation.php),
but can be disabled entirely (except on Windows, because reasons I guess).

It's interesting to note that installing the
[php7-session](https://pkgs.alpinelinux.org/package/edge/community/x86/php7-session)
package won't help in this particular case, because there is no way to register
a custom function handler when sessions support is added as a module and not
as a builtin.

The solution to prevent Snuffleupagus from crashing on Alpine was simply to add
a guard `#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)` around a
warning, should the user try to use a session-related feature. There are other
issues remaining that are preventing the testsuite from running correctly on
Alpine, but those will likely be detailed in an other blogpost ;)
