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

Generate includes from PHP source directly #52

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

iggyvolz
Copy link

@iggyvolz iggyvolz commented Feb 4, 2022

This PR generates the .h files directly from the PHP source code (committing them to the docker so as not to require a C compiler at runtime), using srcml to extract the relevant symbols. This adds support for PHP 7.4 and 8.1, as well as thread-safe versions (although 7.4 needs some work to get tests passing since the code assumes PHP 8 functionality - not sure if it's worth bothering).

RUN apt update
RUN apt install libffi-dev
RUN docker-php-ext-install ffi
RUN curl http://131.123.42.38/lmcrs/v1.0.0/srcml_1.0.0-1_ubuntu20.04.deb > srcml.deb
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the official srcML download link is HTTP - https://www.srcml.org/ - not an issue at runtime unless you're regenerating the headers but it's definitely a security issue.

@@ -109,7 +109,11 @@ public function getGlobalsSize(): int
*/
public function getGlobals(): ?CData
{
return $this->moduleEntry->globals_ptr;
if(ZEND_THREAD_SAFE) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/* disable usage of builtin instruction for strlen() */
public const COMPILE_NO_BUILTIN_STRLEN = (1 << 7);
// public const COMPILE_NO_BUILTIN_STRLEN = Defines::ZEND_COMPILE_NO_BUILTIN_STRLEN;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this symbol was removed in PHP 8.1 - unused in the rest of the repo

public const IS_CALLABLE = Defines::IS_CALLABLE;
public const IS_ITERABLE = Defines::IS_ITERABLE;
public const IS_VOID = Defines::IS_VOID;
// public const IS_STATIC = Defines::IS_STATIC;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These symbols were only added in 8.0 - removed to get 7.4 compatibility but they could be re-added if needed.

@lisachenko
Copy link
Owner

Wow! @iggyvolz such an amazing work! It's so pity that I have returned to my project only now, but I really would like to review and merge this PR, just need to allocate some time to check how it works )

I'm going to try to review and test this on weekend and leave my feedback.

@lisachenko lisachenko added the enhancement New feature or request label Oct 11, 2022
@lisachenko lisachenko mentioned this pull request Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants