-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Fix compiling and linking the php plugin in uwsgi #97536
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! Also, great job on the research 👍
Maybe someone with more uwsgi/Nix experience like @Mic92 can also have a look.
b6316b6
to
e48d05c
Compare
e48d05c
to
b55cc92
Compare
Should I prepare a PR for other branches of nixpkgs too? |
Let's wait until this is merged (I can only review) |
can we get some reviews here please? :) |
btw, I have this change in my tree too. not sure if I should add it to this PR, or to open a new one:
|
Hmmm, I tested this on my server and all my web pages are blank. Could these changes have caused it? |
well… more context is needed. Prior to this PR you couldn't even have uwsgi with PHP in nix. It just doesn't compile (see #97352). Apart from that, I don't know what your web pages are, what your uwsgi configuration is, or how you use it. I can assure you that I'm currently running uwsgi+php and a php app from this exact branch. |
@rnhmjoj is this something you have the ability to review? |
I think so, I spent some time studying uwsgi recently: I'll see what I can do.
It would be good to have a small test. I'll try to write it but I know nothing about php. |
00e73eb
to
23b45ee
Compare
thanks for that |
It took some trial and error but I managed to write a minimal test: It works all right. @schneefux may have had a more complicated setup or just misconfigured uwsgi: even if the doc is good I still find it quite tricky to get it right. Anyway, @gdamjan I had to rebase because your checkout is too old and the test has been changed in master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me, besides those two nits.
I'm not too fond of patching software but the fault here is on uwsgi, with their bizarre build system.
Thank you, can you squash the fixup commits? Looks good to be merged. |
just the two last commits into a single, or those two into the second one perhaps? |
I was thinking about squashing them into 27e5cbb. |
uwsgi needs to run php-config to get the include path. set the UWSGICONFIG_PHPPATH to the php-config in the php.dev store. Patch common.h to directly include php_session.h (since it's a separate package on nixos). NIX_CFLAGS_LINK was removed since it doesn't seem to be used at all https://github.com/unbit/uwsgi/blob/master/plugins/php/common.h
On NixOS the session.so php extension is a separate package (and not builtin in libphp.so). But since the uwsgi php plugin uses the session mechanisms, we need to link the plugin to that library too. With this change uwsgipluginpy is hacked to take an additional UWSGICONFIG_PHP_LDFLAGS environment variable and add it to its LDFLAGS, and then in the nix expression the UWSGICONFIG_PHP_LDFLAGS is set to point to php.extensions.session
0ed26c9
to
c32ef21
Compare
right. done! |
Uh, while you're at it: can you add the test to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Thank you very much @rnhmjoj! 🎉 |
Hi, just as a heads up I am having an issue with nixpkgs-review related to this PR:
|
Yeah, seems like eval is borked after this merge, all recent PRs are having an issue during evaluation: #107340, #107342, #107343, #107344, #107345, #107347, #107348
|
Reverted. Please we do have CI that catches such errors. There's this red cross next to the commit. https://gist.github.com/GrahamcOfBorg/cff3c8276a4df394f26fb8693825f8b6 |
Oof, sorry. I've tested locally by running the test but it must have been cached... |
can someone explain that error, and how to see it locally? |
I think you're missing parenthesis around the call to |
Caching won't prevent evaluation errors. @gdamjan: anything with that package will fail, e.g.
|
What's the process now. Open a new PR? |
Yes, I don't think there is any other way with github. |
right, for some reason php-opcache fails to compile on the latests master (for me), and I didn't catch the my error. ps. |
## Changelog for nixpkgs: Commits: [NixOS/nixpkgs@e9158eca...57a787c9](NixOS/nixpkgs@e9158ec...57a787c) * [`3c233e26`](NixOS/nixpkgs@3c233e2) soapyaudio: init at 0.1.1 * [`08319d05`](NixOS/nixpkgs@08319d0) sdrangel: add soapysdr dependency * [`640d9251`](NixOS/nixpkgs@640d925) buildDunePackage: use dune install instead of opaline * [`e55f7727`](NixOS/nixpkgs@e55f772) python3Packages.hstspreload: add pythonImportsCheck * [`17f8726e`](NixOS/nixpkgs@17f8726) flasm: init at 1.64 * [`37abd75b`](NixOS/nixpkgs@37abd75) libreoffice-fresh: 7.0.3.1 -> 7.0.4.2 * [`0446b8af`](NixOS/nixpkgs@0446b8a) ethminer: fix broken package by switching to clang * [`15dcf134`](NixOS/nixpkgs@15dcf13) nixos/manual: fix typo in virtualbox installation guide * [`0179b5f1`](NixOS/nixpkgs@0179b5f) steam-fhsenv: normalize ldPath * [`473ec944`](NixOS/nixpkgs@473ec94) steamPackages.steam: 1.0.0.61 -> 1.0.0.68 * [`ab91cd99`](NixOS/nixpkgs@ab91cd9) steam: fix desktop link * [`373cb5d4`](NixOS/nixpkgs@373cb5d) steam: fix readonly boostrap.tar.xz * [`39fad297`](NixOS/nixpkgs@39fad29) nixos: fix "nixos-rebuild build-vm-with-bootloader" for EFI systems * [`04cbb60e`](NixOS/nixpkgs@04cbb60) ocamlPackages.opam-state: use dune 2 * [`69e614e7`](NixOS/nixpkgs@69e614e) ocamlPackages.opam-repository: use dune 2 * [`926a1b20`](NixOS/nixpkgs@926a1b2) ocamlPackages.opam-format: use dune 2 * [`6c839492`](NixOS/nixpkgs@6c83949) waypoint: init at 0.1.5 * [`d1d2526f`](NixOS/nixpkgs@d1d2526) samba: 4.12.6 -> 4.13.0 * [`8e88dfc1`](NixOS/nixpkgs@8e88dfc) samba: 4.13.0 -> 4.13.3 * [`a9ddc4fc`](NixOS/nixpkgs@a9ddc4f) samba: fix macOS build * [`560dc49b`](NixOS/nixpkgs@560dc49) maintainers: add fab * [`6be8a0ec`](NixOS/nixpkgs@6be8a0e) maintainers: add stunkymonkey * [`6f64a415`](NixOS/nixpkgs@6f64a41) samba: mark as broken on darwin * [`e8488ab5`](NixOS/nixpkgs@e8488ab) notion: 4.0.1 -> 4.0.2 * [`0c0a1a9a`](NixOS/nixpkgs@0c0a1a9) kitty: 0.19.2 -> 0.19.3 * [`4078999d`](NixOS/nixpkgs@4078999) lein: 2.9.1 -> 2.9.5 * [`b9140da9`](NixOS/nixpkgs@b9140da) pythonPackages.discordpy: remove overly restrictive version constraints * [`fd018e99`](NixOS/nixpkgs@fd018e9) uwsgi: set UWSGICONFIG_PHPPATH to the php.dev store * [`22e88043`](NixOS/nixpkgs@22e8804) uwsgi: the php plugin needs to link with session.so * [`c32ef219`](NixOS/nixpkgs@c32ef21) nixos/tests/uwsgi: test PHP plugin * [`b055fd11`](NixOS/nixpkgs@b055fd1) python3Packages.transformers: 4.0.1 -> 4.1.1 * [`5e5139ea`](NixOS/nixpkgs@5e5139e) python3Packages.ircstates: 0.11.6 -> 0.11.7 * [`e189177c`](NixOS/nixpkgs@e189177) uwsgi: add passthru.tests.uwsgi to derivation * [`6625d1d1`](NixOS/nixpkgs@6625d1d) python3Packages.botocore: 1.19.39 -> 1.19.40 * [`ff6ef5bc`](NixOS/nixpkgs@ff6ef5b) python3Packages.boto3: 1.16.39 -> 1.16.40 * [`b4c59d6a`](NixOS/nixpkgs@b4c59d6) awscli: 1.18.199 -> 1.18.200 * [`9dc0ab94`](NixOS/nixpkgs@9dc0ab9) linux: 5.10.1 -> 5.10.2 * [`6b4ee3bf`](NixOS/nixpkgs@6b4ee3b) linux: 5.4.84 -> 5.4.85 * [`4859bf28`](NixOS/nixpkgs@4859bf2) linux: 5.9.15 -> 5.9.16 * [`c0e091e6`](NixOS/nixpkgs@c0e091e) linux-rt_5_10: 5.10.1-rt19 -> 5.10.1-rt20 * [`e49c1a00`](NixOS/nixpkgs@e49c1a0) mathematica: 12.1.1 -> 12.2.0 (NixOS/nixpkgs#107309) * [`9521efa6`](NixOS/nixpkgs@9521efa) cling: fix libc include path for non-glibc * [`b7045dac`](NixOS/nixpkgs@b7045da) libcryptui: enableParallelBuilding * [`4bded925`](NixOS/nixpkgs@4bded92) nixos/thermald: Allow switching package * [`7e63c972`](NixOS/nixpkgs@7e63c97) folly: 2019.11.11.00 -> 2020.09.28.00, fix build (NixOS/nixpkgs#99133) * [`a63c1a93`](NixOS/nixpkgs@a63c1a9) kafka: remove old versions * [`95c123d1`](NixOS/nixpkgs@95c123d) libsmartcols: init at v2.36.1 * [`31e7bbc9`](NixOS/nixpkgs@31e7bbc) prometheus-lnd-exporter: unstable-2020-01-09 -> unstable-2020-12-04 * [`bbd59a22`](NixOS/nixpkgs@bbd59a2) python3Packages.pytest-trio: 0.6.0 -> 0.7.0 * [`65fd0312`](NixOS/nixpkgs@65fd031) nixos: add prometheus_nginxlog_exporter module + test * [`bd841250`](NixOS/nixpkgs@bd84125) nomad_1_0: init at 1.0.1 * [`b2a1f176`](NixOS/nixpkgs@b2a1f17) docopts: add to all-packages * [`bf444739`](NixOS/nixpkgs@bf44473) Revert "Merge NixOS/nixpkgs#107253: bintools-wrapper: fix inverted link32 check" * [`363175cd`](NixOS/nixpkgs@363175c) Revert "bintools-wrapper: skip dynamic linker for static binaries" * [`ac03cfa3`](NixOS/nixpkgs@ac03cfa) Revert "Merge NixOS/nixpkgs#94582: clang, cc-wrapper: Move `--gcc-toolchain` logic..." * [`58347020`](NixOS/nixpkgs@5834702) Revert "Merge NixOS/nixpkgs#97536: uwsgi: fix compiling and linking" * [`91d6b7d0`](NixOS/nixpkgs@91d6b7d) nvidia-x11.vulkan_beta: 455.46.02 -> 455.46.04 * [`58c52f0b`](NixOS/nixpkgs@58c52f0) wireshark: 3.4.0 -> 3.4.2 * [`7bc70734`](NixOS/nixpkgs@7bc7073) bash: 5.0 -> 5.1 * [`e19995e4`](NixOS/nixpkgs@e19995e) codimd: 1.6.0 -> 1.7.0, rename to hedgedoc * [`1c556217`](NixOS/nixpkgs@1c55621) nixos/codimd: rename to hedgedoc * [`97e863ad`](NixOS/nixpkgs@97e863a) nixos/doc: add note about codimd -> hedgedoc to release notes * [`16a33fb0`](NixOS/nixpkgs@16a33fb) sdrangel: set SOAPYSDR_DIR in build * [`da247171`](NixOS/nixpkgs@da24717) mutagen: install agents bundle (NixOS/nixpkgs#107297) * [`af5b6f9f`](NixOS/nixpkgs@af5b6f9) nerdctl: 0.3.0 -> 0.4.0 * [`1ebf7ecb`](NixOS/nixpkgs@1ebf7ec) youtube-dl: 2020.12.14 -> 2020.12.22 * [`a59c33f3`](NixOS/nixpkgs@a59c33f) manaplus: init at 1.9.3.23 * [`e18b62a5`](NixOS/nixpkgs@e18b62a) maintainer-list: add lrworth * [`160ba18d`](NixOS/nixpkgs@160ba18) unused: init at 0.2.1 * [`9d92c9d0`](NixOS/nixpkgs@9d92c9d) iso-image: add 'serial console' boot entry * [`f3939a9b`](NixOS/nixpkgs@f3939a9) python37Packages.pulp: 2.3.1 -> 2.4 * [`bbceaa8c`](NixOS/nixpkgs@bbceaa8) element-web: 1.7.15 -> 1.7.16 * [`b9dabe73`](NixOS/nixpkgs@b9dabe7) element-desktop: 1.7.15 -> 1.7.16 * [`d36f0023`](NixOS/nixpkgs@d36f002) packer: 1.6.5 -> 1.6.6 * [`4d0c6c64`](NixOS/nixpkgs@4d0c6c6) nvimpager: init at 0.9 (NixOS/nixpkgs#107057) * [`9f52d1f2`](NixOS/nixpkgs@9f52d1f) Revert "nixos/wireless: fix failure with no interfaces" * [`68b265d8`](NixOS/nixpkgs@68b265d) lexicon: 3.4.3 -> 3.5.2 * [`80b09974`](NixOS/nixpkgs@80b0997) nixos/udev: harmonize extraRules example * [`30a21ff2`](NixOS/nixpkgs@30a21ff) iosevka-bin: 4.0.3 -> 4.1.1 * [`9a9ad8c7`](NixOS/nixpkgs@9a9ad8c) esptool: 2.7 -> 3.0, fix NixOS/nixpkgs#82965 * [`20a3b851`](NixOS/nixpkgs@20a3b85) python3Packages.daphne: 2.5.0 -> 3.0.1 * [`bf5af025`](NixOS/nixpkgs@bf5af02) monero: 0.17.1.6 -> 0.17.1.7 * [`b45e4ddb`](NixOS/nixpkgs@b45e4dd) monero-gui: 0.17.1.6 -> 0.17.1.7 * [`05fe6112`](NixOS/nixpkgs@05fe611) Fix small typo in a comment of emacs-packages * [`b36e05ef`](NixOS/nixpkgs@b36e05e) htop: 3.0.3 -> 3.0.4 * [`74971a10`](NixOS/nixpkgs@74971a1) gitlab-runner: 13.6.0 -> 13.7.0 (NixOS/nixpkgs#107378) * [`86ff1e45`](NixOS/nixpkgs@86ff1e4) ungoogled-chromium: Support enableWideVine=true * [`6dd858dc`](NixOS/nixpkgs@6dd858d) uwsgi: set UWSGICONFIG_PHPPATH to the php.dev store * [`87bed6c8`](NixOS/nixpkgs@87bed6c) uwsgi: the php plugin needs to link with session.so * [`06749ba3`](NixOS/nixpkgs@06749ba) nixos/tests/uwsgi: test PHP plugin * [`41af371d`](NixOS/nixpkgs@41af371) uwsgi: add passthru.tests.uwsgi to derivation * [`5d3baeb1`](NixOS/nixpkgs@5d3baeb) polybar: 3.5.0 -> 3.5.2 * [`044cd65e`](NixOS/nixpkgs@044cd65) gitui: 0.10.1 -> 0.11.0 * [`c6f65b1d`](NixOS/nixpkgs@c6f65b1) ulauncher: 5.8.1 -> 5.9.0 * [`123f953c`](NixOS/nixpkgs@123f953) grocy: 2.7.1 -> 3.0.0 * [`b3aed95a`](NixOS/nixpkgs@b3aed95) chroma: 0.8.1 -> 0.8.2 * [`7bc0da6a`](NixOS/nixpkgs@7bc0da6) dasel: 1.10.0 -> 1.11.0 * [`a926df73`](NixOS/nixpkgs@a926df7) python37Packages.toposort: 1.5 -> 1.6 * [`d156f38d`](NixOS/nixpkgs@d156f38) python37Packages.pyvips: 2.1.13 -> 2.1.14 * [`b29490c8`](NixOS/nixpkgs@b29490c) python37Packages.sqlite-utils: 3.0 -> 3.1 * [`458fc5d9`](NixOS/nixpkgs@458fc5d) python37Packages.hvac: 0.10.5 -> 0.10.6 * [`cf3c6d3e`](NixOS/nixpkgs@cf3c6d3) python37Packages.tlslite-ng: 0.7.5 -> 0.7.6 * [`157edfdf`](NixOS/nixpkgs@157edfd) python37Packages.requests-hawk: 1.0.1 -> 1.1.0 * [`0cefcc62`](NixOS/nixpkgs@0cefcc6) pythonPackages.progressbar2: fix build * [`f0bce04b`](NixOS/nixpkgs@f0bce04) sudo: 1.9.4p1 -> 1.9.4p2 * [`9a6de998`](NixOS/nixpkgs@9a6de99) nodejs-15_x: 15.4.0 -> 15.5.0 * [`d130a659`](NixOS/nixpkgs@d130a65) MediaElch: init at 2.8.2 * [`6fc561f9`](NixOS/nixpkgs@6fc561f) python3Packages.botocore: 1.19.40 -> 1.19.41 * [`d943d0a2`](NixOS/nixpkgs@d943d0a) python3Packages.boto3: 1.16.40 -> 1.16.41 * [`8e3726f3`](NixOS/nixpkgs@8e3726f) awscli: 1.18.200 -> 1.18.201 * [`96396f35`](NixOS/nixpkgs@96396f3) linux-rt_5_4: 5.4.82-rt45 -> 5.4.84-rt47 * [`371b8673`](NixOS/nixpkgs@371b867) linux/hardened/patches/5.4: 5.4.84.a -> 5.4.85.a * [`bf0589a3`](NixOS/nixpkgs@bf0589a) linux/hardened/patches/5.9: 5.9.15.a -> 5.9.16.a * [`0f8e7ab7`](NixOS/nixpkgs@0f8e7ab) mapproxy: 1.12.0 -> 1.13.0 (NixOS/nixpkgs#107203) * [`fd4e4bd8`](NixOS/nixpkgs@fd4e4bd) waffle: Use meson instead of cmake * [`807c0b0d`](NixOS/nixpkgs@807c0b0) waffle: Add support for non-linux platforms * [`dd5ffa7b`](NixOS/nixpkgs@dd5ffa7) libdnf: init at 0.55.2 * [`638eefae`](NixOS/nixpkgs@638eefa) microdnf: init at 3.6.0 * [`702161d4`](NixOS/nixpkgs@702161d) winetricks: 20200412 -> 20201206 * [`e7bfbe36`](NixOS/nixpkgs@e7bfbe3) umockdev: disable tests * [`02040cb5`](NixOS/nixpkgs@02040cb) python37Packages.chalice: 1.21.6 -> 1.21.7 * [`e57c6c25`](NixOS/nixpkgs@e57c6c2) python37Packages.netcdf4: 1.5.5 -> 1.5.5.1 * [`357f132b`](NixOS/nixpkgs@357f132) doc: convert Steam to CommonMark * [`2ae527c5`](NixOS/nixpkgs@2ae527c) qtractor: 0.9.18 -> 0.9.19 * [`55504ab4`](NixOS/nixpkgs@55504ab) python37Packages.breathe: 4.24.1 -> 4.25.1 * [`56139b3d`](NixOS/nixpkgs@56139b3) gitAndTools.delta: 0.4.4 -> 0.4.5 * [`019eb959`](NixOS/nixpkgs@019eb95) tdesktop: 2.4.7 -> 2.5.0 * [`2688e2d3`](NixOS/nixpkgs@2688e2d) tdesktop: 2.5.0 -> 2.5.1 * [`87e7d8b3`](NixOS/nixpkgs@87e7d8b) bind: 9.16.8 -> 9.16.10 * [`5ec44bb2`](NixOS/nixpkgs@5ec44bb) qolibri: migrate to Qt5.15 * [`0d025be7`](NixOS/nixpkgs@0d025be) kstars: migrate to Qt5.15 * [`d63dc152`](NixOS/nixpkgs@d63dc15) kstars: use mkDerivation instead of wrapQtAppsHook * [`8db56b45`](NixOS/nixpkgs@8db56b4) kstars: add optional dependencies * [`b8da36eb`](NixOS/nixpkgs@b8da36e) python3Packages.botocore: 1.19.41 -> 1.19.42 * [`8db43ec6`](NixOS/nixpkgs@8db43ec) python3Packages.boto3: 1.16.41 -> 1.16.42 * [`d1418293`](NixOS/nixpkgs@d141829) awscli: 1.18.201 -> 1.18.202 * [`05bf935b`](NixOS/nixpkgs@05bf935) ripgrep: Add test * [`bdbb37ad`](NixOS/nixpkgs@bdbb37a) python37Packages.django-storages: 1.10.1 -> 1.11 * [`72386991`](NixOS/nixpkgs@7238699) python37Packages.JPype1: 1.1.2 -> 1.2.0 * [`2d6c7dd0`](NixOS/nixpkgs@2d6c7dd) python37Packages.azure-mgmt-synapse: 0.5.0 -> 0.6.0 * [`85994040`](NixOS/nixpkgs@8599404) python37Packages.clickhouse-driver: 0.1.5 -> 0.2.0 * [`0597dcb0`](NixOS/nixpkgs@0597dcb) python37Packages.bumps: 0.7.18 -> 0.8.0 * [`1539732c`](NixOS/nixpkgs@1539732) shadow: Add test * [`49ca6941`](NixOS/nixpkgs@49ca694) release-combined: Add shadow test * [`825d4705`](NixOS/nixpkgs@825d470) pythonPackages.tqdm: 4.54.0 -> 4.54.1 * [`56beaeb3`](NixOS/nixpkgs@56beaeb) python37Packages.seaborn: 0.11.0 -> 0.11.1 * [`57a787c9`](NixOS/nixpkgs@57a787c) Revert Merge NixOS/nixpkgs#107275: nixos: fix "nixos-rebuild ...
Motivation for this change
fixes #97352 - it enables the use of the php plugin of uwsgi.
Things done
I tested in a nixos docker container, on ArchLinux host:
Explanation of the changes
The root of the problem is that uwsgi has a bit of a different build system, and it would expect to find the
php-config
binary in order to set it's compiler and linker flags. There was an additional problem that the uwsgi-php plugin needs to also link with thesession.so
php extension - which on NixOS is a separate package¹.The first problem was solved by adding all the required
buildInputs
to the uwsgi package so that it can find all the needed header files, libraries and to have php-config in its PATH.I also had to patch uwsgi to not look for
php_session.h
with a path like this#include "ext/session/php_session.h"
, since on NixOS it's just in…php-session-7.4.8-dev/include
.Third, I had to patch the uwsgi build system for the php plugin to explicitly add the
session.so
library and its rpath toLDFLAGS
. In the nix expression that's exported as the UWSGICONFIG_PHP_LDFLAGS environment variable. It's important that these flags are not used for the main uwsgi binary, but just for the php-plugin shared object.¹ not sure why the session extension is separated on NixOS, it's builtin in libphp.so on both Debian/Ubuntu and ArchLinux - something to be discussed by the PHP team i guess.
ps.
this is my first involvement with the NixOS project, so I'm open to any criticism and suggestions.