php / pie

The PHP Installer for Extensions
159 stars 3 forks source link

Support extensions written in Rust? #26

Open cmb69 opened 1 month ago

cmb69 commented 1 month ago

There is some discussion about PECL extensions written in Rust on the PECL mailing list (https://news-web.php.net/php.pecl.dev/17600 ff), but so far without any consensus. Since @derickr said:

For the new PECL installer (PIE, https://github.com/php/pie) supporting this "style" hasn't been taken under consideration.

So maybe it's a good idea to consider this?

asgrim commented 1 month ago

If a Rust ext uses phpize && ./configure && make && make install, it will work with PIE. If not, it's something we can certainly consider! Do we have any examples of Rust exts?

cmb69 commented 1 month ago

https://pecl.php.net/package/skywalking is already on PECL (and there may be more), and https://github.com/genkgo/php-ext-fs-notify has requested to be added to PECL. Note that both extensions use https://github.com/phper-framework/phper.

The problem is not necessarily that these extensions don't support phpize && ./configure && make && make install, but rather that they require to have a Rust/Cargo environment already available. If you do something like pecl install skywalking that likely fails on the usual servers (which have C build environment, but none for Rust).

If an extension written in Rust would support Windows (I'm not aware of any), that might also be an issue for https://github.com/php/php-windows-builder.

Anyway, I don't necessarily suggest that there needs to be full Rust build support in PIE, but rather that there is some information in the schema (maybe just rough, or maybe more thorough), and maybe that this is checked before even downloading and trying to install such extensions.

johannes commented 1 month ago

I don't know much about pie, but I would suggest to try being agnostic to the build system. Even for C (or C++) extensions there is some value in CMake or other build systems. (Better cross platform support, tooling support, some libraries one was TA to wrap might use CMake or other as their primary system etc )

derickr commented 1 month ago

I don't think pie currently first checks for a working C compilation set-up. At least, PECL never used to do that. So although "pie" doesn't take a working rust build system under consideration, it is no different than checking for a working C build system.

So I guess that that could be the real question here — whether it should check for a working build environment?

I don't think PIE should first check for a working build (C/Rust) environment, as there will be way too many permutations. config.m4 is the place for that — and I suppose there could be a new provided check for this — perhaps initially for Rust — so that not everybody will have to write these on their own, but this issue (or repository) is the place for that discussion.

cmb69 commented 1 month ago

So I guess that that could be the real question here — whether it should check for a working build environment?

Not necessarily. In my opinion it would be sufficient to have some information in the schema. Not sure if https://github.com/ThePHPF/pie-design/blob/main/composer-json-php-ext-schema.json is up-to-date, but it could be added there (or whereever), so users (not necessarily PIE) could check that in advance. Maybe there could even be a PIE (sub-)command to list these requirements (perhaps something like pie build-info <package>).

asgrim commented 1 month ago

It's certainly something that could be considered as an enhancement at some point, but for the initial iteration lets try and keep it simple :grin:

cmb69 commented 1 month ago

At the very least, it appears sensible to me to add some info to the schema right away; maybe similar to "support-zts" (which, by the way, does not really cater to extensions which require ZTS, like PECL/parallel).