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

uwsgi with php plugin doesn't compile #97352

Closed
gdamjan opened this issue Sep 7, 2020 · 5 comments · Fixed by #97536 or #107403
Closed

uwsgi with php plugin doesn't compile #97352

gdamjan opened this issue Sep 7, 2020 · 5 comments · Fixed by #97536 or #107403

Comments

@gdamjan
Copy link
Contributor

gdamjan commented Sep 7, 2020

Describe the bug
when enabling the php plugin in the uwsgi package the compile of the plugin fails.

To Reproduce
Steps to reproduce the behavior:

  1. nix-build -E 'with import <nixpkgs> {}; uwsgi.override { plugins=[ "php" ]; }'

Screenshots

*** uWSGI is ready, launch it with ./uwsgi ***
using profile: buildconf/nixos.ini
detected include path: ['/nix/store/vb1fh8zqdcs7n3hvn8awlrpdfnic6zjg-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/include', '/nix/store/vb1fh8zqdcs7n3hvn8awlrpdfnic6zjg-gcc-9.3.0/include', '/nix/store/vb1fh8zqdcs7n3hvn8awlrpdfnic6zjg-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/include-fixed', '/nix/store/vbs3xx1b5i5bzf1sjkz2lkmz7b8cy92y-glibc-2.30-dev/include']
*** uWSGI building and linking plugin plugins/php ***
/bin/sh: php-config: not found
/bin/sh: php-config: not found
/bin/sh: php-config: not found
/bin/sh: php-config: not found
[gcc] /nix/store/yjg3pdnwgynl1sz9rkc5gyjcgjamgfi9-uwsgi-2.0.18/lib/uwsgi/php_plugin.so
In file included from plugins/php/php_plugin.c:1:
plugins/php/common.h:1:10: fatal error: php.h: No such file or directory
    1 | #include "php.h"
      |          ^~~~~~~
compilation terminated.
In file included from plugins/php/session.c:1:
plugins/php/common.h:1:10: fatal error: php.h: No such file or directory
    1 | #include "php.h"
      |          ^~~~~~~
compilation terminated.
*** unable to build php plugin ***

Additional context

The uwsgi build system tries to invoke php-config to get the include paths for the compile, but php-config is not in the path (it's in the php.dev package). This can be fixed by setting the UWSGICONFIG_PHPDIR = "${php-embed.unwrapped.dev}"; environment variable. uwsgi then finds php.h, but fails on #include "ext/session/php_session.h" which is in extensions.session.dev, and under a different path in the store.

https://github.com/unbit/uwsgi/blob/master/plugins/php/common.h
https://github.com/unbit/uwsgi/blob/master/plugins/php/uwsgiplugin.py

I'll try to find a better solution next.

Notify maintainers
@abbradar @schneefux @globin

Metadata
Maintainer information:

 - system: `"x86_64-linux"`
 - host os: `Linux 5.8.7-arch1-1, Alpine Linux, noversion`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.6`
 - channels(root): `"nixpkgs-20.09pre228453.dcb64ea42e6"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
@gdamjan
Copy link
Contributor Author

gdamjan commented Sep 7, 2020

trying to fix the issue here
master...gdamjan:fix-uwsgi-php-try1

includes are fine, but php-config returns an empty --ldflags list, so linkig fails with:

*** uWSGI building and linking plugin plugins/php ***
[gcc] /nix/store/p9mzbjm5fb1sv2f3gyzjzg5km1afkiwh-uwsgi-2.0.19.1/lib/uwsgi/php_plugin.so
/nix/store/zp4vhfn31ky68xy0s6mssxh4c90z9v9a-binutils-2.31.1/bin/ld: cannot find -largon2
collect2: error: ld returned 1 exit status

@gdamjan
Copy link
Contributor Author

gdamjan commented Sep 8, 2020

With the above changes the compile command is (stripped of some of the options and defines):

gcc
-fPIC
-shared
-o /nix/store/98l6in3hxjv3zglaajkhacpw0jfqsby0-uwsgi-2.0.19.1/lib/uwsgi/php_plugin.so
…
-I/nix/store/6a7ys7yzpnzwirbch4qycz2lxix2gm96-php-session-7.4.8-dev/include
-I/nix/store/ckklsxzdp10myy6i9a5qdy1cxxvqkbfa-pcre-8.44-dev/include
-I/nix/store/90n4d0cjgiw190zvq501q1p6j4xsn1r9-jansson-2.13.1/include
-I/nix/store/na6yq1y381j78677iph8p8l92igqbg84-php-7.4.8-dev/include/php
-I/nix/store/na6yq1y381j78677iph8p8l92igqbg84-php-7.4.8-dev/include/php/main
-I/nix/store/na6yq1y381j78677iph8p8l92igqbg84-php-7.4.8-dev/include/php/TSRM
-I/nix/store/na6yq1y381j78677iph8p8l92igqbg84-php-7.4.8-dev/include/php/Zend
-I/nix/store/na6yq1y381j78677iph8p8l92igqbg84-php-7.4.8-dev/include/php/ext
-I/nix/store/na6yq1y381j78677iph8p8l92igqbg84-php-7.4.8-dev/include/php/ext/date/lib
…
-lcrypt
-largon2
-lresolv
-lcrypt
-lrt
-lm
-ldl
-lxml2
-lpcre2-8
-lcrypt
-largon2
-lxml2
-lcrypt
-lphp7

Obviously there are no -L flags to gcc.

@gdamjan
Copy link
Contributor Author

gdamjan commented Sep 8, 2020

more success with these changes master...gdamjan:fix-uwsgi-php-try2 now uwsgi compiles and links fine, but at runtime it fails with

!!! UNABLE to load uWSGI plugin: /nix/store/pd2031xdjprr1vlwphm1f9l41zkdyif1-uwsgi-2.0.19.1/lib/uwsgi/php_plugin.so: undefined symbol: php_session_create_id !!!

@azazel75
Copy link
Contributor

Have you had a complete success on this? I'm stuck on it but I must say I'm no PHP nor uwsgi expert

@gdamjan
Copy link
Contributor Author

gdamjan commented Dec 19, 2020

@azazel75 yes, see the PR #97536. I'm using that to run a couple of php apps.

Unfortunetlly, it seems there are no reviewers so there's no progress on merging it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants