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

Windows dll #3

Open
vjardin opened this issue Aug 2, 2018 · 16 comments
Open

Windows dll #3

vjardin opened this issue Aug 2, 2018 · 16 comments

Comments

@vjardin
Copy link
Owner

vjardin commented Aug 2, 2018

Please, can you provide builds with bcgen dll for Windows?

@nanosonde
Copy link
Collaborator

Windows is not my target. If you want to support the Windows platform, please feel free to support this platform. Maybe you can create Travis-CI file to compile this PECL extension for Windows in the MINGW environment. I have not checked if this is possible though.

@vjardin
Copy link
Owner Author

vjardin commented Aug 3, 2018

Understood. First let's get the other fix before tackling Windows.

@vjardin
Copy link
Owner Author

vjardin commented Aug 5, 2018

Windows compilation fails, I'll check the root cause. See below some notes to compile it:

# Follow README.md - https://github.com/Microsoft/php-sdk-binary-tools/blob/master/README.md
$ cd C:\
$ git clone https://github.com/Microsoft/php-sdk-binary-tools.git c:\php-sdk
$ cd c:\php-sdk
$ phpsdk-vc15-x64.bat # assuming Visual Studio 2017 / Window 64 bits
$ phpsdk_buildtree phpmaster
$ git clone https://github.com/php/php-src.git
$ cd C:\php-sdk\phpmaster\vc15\x64\php-src
$ phpsdk_deps --update --branch master
$ buildconf
$ configure --enable-json --enable-sockets --enable-hash --enable-cli --enable-cgi --enable-session --enable-calendar --enable-ipv6 --enable-mbstring --enable-fileinfo --enable-zlib
$ nmake
$ nmake install

# build pecl - bcgen
$ mkdir C:\php-sdk\phpmaster\vc15\x64\pecl
$ cd C:\php-sdk\phpmaster\vc15\x64\pecl
$ git clone https://github.com/nanosonde/bcgen.git
$ cd C:\php-sdk\phpmaster\vc15\x64\php-src
$ buildconf --force
$ configure --disable-all --enable-cli --enable-cgi --enable-bcgen
$ nmake

zend_persist_calc.c
zend_shared_alloc.c ..\pecl\bcgen\zend_accelerator_util_funcs.c(50): error C2105: '--' necessite une l-value
..\pecl\bcgen\zend_persist.c(73): warning C4146: operateur moins unaire applique a un type non signe, le resultat sera non signe

@vjardin
Copy link
Owner Author

vjardin commented Aug 5, 2018

@nanosonde Many files from bcgen are extracted from opcache. Upstream opcache is able to compile on Windows so I was hoping to get a quick solution thanks to opcache.
However, when I try to analyze the modifications that you have applied on bcgen out of opcache, I cannot get it from your git logs.

For instance:

commit aadfa2c6e65f7be872efe6c1de445e2006602eeb
Author: Cille <[email protected]>
Date:   Mon May 14 17:42:23 2018 +0200

    Initial commit of BCgen for PHP-7.2

This initial commit seems to already have some modifications. I cannot find the same vanilla codes from any tag from https://github.com/php/php-src

Please, can you describe a bit more? Or do you have some records somewhere so we can rebase bcgen with https://github.com/php/php-src/tree/master/ext/opcache ?

@nanosonde
Copy link
Collaborator

@vjardin Hi!
First of all, I will be on vacation for three weeks now. After that I have project deadline at the 1.10.2018.
So I won't be able to investigate further at the moment.

Unfortunately, there is no commit history for the modifications. :(

What I basically did is to assume the the opcache option "file_cache_only"is set to true.
With this assumptions I have studied the opcache code and was supprised how much code could be removed. The most stuff in opcache is related to shared memory caching (SHM) and maintaining interned strings in the SHM.
However, the file_cache_only option forces opcache to NOT use SHM, although the file content is loaded into memory for obvious reasons though.
I have kept the function names of the most relevant files zend_persist.c, zend_persist_calc.c and zend_file_cache.c the same. With a DIFF tool it is still possible to compare opache and bcgen code.

@vjardin
Copy link
Owner Author

vjardin commented Aug 7, 2018

Thank you. Just in case, do you remember the git hash/tag that you started from?

Enjoy your holidays.

@nanosonde
Copy link
Collaborator

I have started from this branch: https://github.com/php/php-src/tree/PHP-7.2.6

@nanosonde
Copy link
Collaborator

The master branch is based on https://github.com/php/php-src/tree/master

Arround the date of the initial GitHub commit here.

@vjardin
Copy link
Owner Author

vjardin commented Aug 10, 2018

So do you mean around the date of :
57a916f
Initial checkin for PHP-7.3 on master branch
?

From may 14h ?
57a916f

@nanosonde
Copy link
Collaborator

Please see this initial commit on the 7.2 branch.
aadfa2c

@nanosonde
Copy link
Collaborator

nanosonde commented Aug 11, 2018

BTW: if you want to compare BCgen with the original OPcache from 7.2.6:

  • the optimizer directory has just been copied over. You could even leave out the optimizer at all
  • the tests directory contains only the tests from the old bcompiler adapted to run with BCgen and PHP7
  • most important stuff for serialization/deserialization is in zend_file_cache.[ch], zend_persist.[ch] and zend_persist_calc.c
  • I have kept the function names the same as in OPcache code. However, I have removed function arguments like the famous "shm" bool where they were not needed anymore.
  • it was relatively easy to follow matching Opcache minor version changes 7.2.x with only minor changes
  • Just follow what changed in OPcache upsteam, understand what needs to be done in BCgen then. ;)

@vjardin
Copy link
Owner Author

vjardin commented Aug 11, 2018

Currently, I am using bcgen with PHP 7.2 (but not the head yet / PHP 7.3). It works fine. Could you register bcgen on PECL:
https://pecl.php.net/account-request.php
or would you be OK if I do it on your behalf?

thank you,

@nanosonde
Copy link
Collaborator

If you could register it on PECL that would be fine.

One remark concerning platform compatibility:
BCgen puts the sizes of char, int, long, together with the alignment and the architecture (32bit/64bit) in the header of each file.
Currently, the code does not bail out if things do not match as I wanted to experiment with it.
After some experiments with 64bit/32 bit and X86 and ARM, I can say that BCgen compiled for one architecture size work on either platform: so x86 64-bit works on ARM 64 bit.
But you cannot use 32 bit BCgen compiled stuff on 64 bit version and vice versa.
I have always used PHP-7.2.6 for my tests and compiled it myself.

So the check of the header signature need to be strict: if some values in the header of a provided BCgen compiled file does not match the current values, then BCgen must exit as it would crash otherwise as the datatype sizes do not match.

I think that the datatype size problem could be fixed by always putting smaller datatypes into bigger ones, but at the moment I do not care about this.
If someone wants to provide BCgen compiled files, just two versions have to be provided: for 32-bit and for 64-bit
I can live with this caveat, especially because 64-bit becomes more popular every day.

@vjardin
Copy link
Owner Author

vjardin commented Aug 12, 2018

thanks for these comments. I'll check them.
Meanwhile, for the records, https://marc.info/?l=pecl-dev&m=153411407006547&w=2

@jin-pan
Copy link

jin-pan commented Mar 20, 2020

@vjardin Did the bcgen can build dll for windows now?

@vjardin
Copy link
Owner Author

vjardin commented Mar 20, 2020

Yes, it does compile: we use it.

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

No branches or pull requests

3 participants