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

Compiling extension statically into PHP fails #894

Closed
jjeising opened this issue Dec 5, 2018 · 4 comments
Closed

Compiling extension statically into PHP fails #894

jjeising opened this issue Dec 5, 2018 · 4 comments

Comments

@jjeising
Copy link
Contributor

jjeising commented Dec 5, 2018

PHP Driver version or file name 5.3.0
Client operating system macOS 10.14.1
PHP version 7.2.12
Microsoft ODBC Driver version 17.2.0.1

Problem description

Currently it seems not possible to compile the sqlsrv and pdo_sqlsrv extensions statically into PHP. Compilation fails because the extensions main header files php_pdo_sqlsrv.h and php_sqlsrv.h are included from C files, while both files currently extensively include C++ specific code.

The main header files should be splitted to allow static compilation.

Expected behavior and actual behavior

This should work:

phpsrc $ rm configure
phpsrc $ ./buildconf --force
phpsrc $ ./configure --with-pdo_sqlsrv
phpsrc $ make

Actual behaviour:

In file included from main/internal_functions_cli.c:77:
In file included from php-7.2.12/ext/sqlsrv/php_sqlsrv.h:25:
In file included from php-7.2.12/ext/sqlsrv/shared/core_sqlsrv.h:41:
In file included from php-7.2.12/ext/sqlsrv/shared/FormattedPrint.h:24:
In file included from php-7.2.12/ext/sqlsrv/shared/xplat_winnls.h:24:
In file included from php-7.2.12/ext/sqlsrv/shared/typedefs_for_linux.h:23:
php-7.2.12/ext/sqlsrv/shared/xplat.h:27:10: fatal error: 'iostream' file not found
#include <iostream>
         ^~~~~~~~~~
1 error generated.

Please note, that this specific error is only a symptom.

Repro code or steps to reproduce

  1. Download and extract PHP source
  2. Extract Extension source to ext/
  3. Run rm configure && ./buildconf --force && ./configure --with-pdo_sqlsrv && make
@yitam
Copy link
Contributor

yitam commented Dec 5, 2018

Yes @jjeising we are aware of this. As indicated here, shared objects allow us to distribute the extensions as separate packages. Another advantage is one can update the extensions without rebuilding PHP.

Is there any strong reason you want to compile our drivers statically into PHP?

@jjeising
Copy link
Contributor Author

jjeising commented Dec 6, 2018

As indicated here, shared objects allow us to distribute the extensions as separate packages. Another advantage is one can update the extensions without rebuilding PHP.

I don't argue that separate builds are beneficial in most cases, I just think statical builds should be possible. I assume splitting the header file should not be to complicated or introduce a maintenance burden.

Is there any strong reason you want to compile our drivers statically into PHP?

As far as I know static building is possible for almost all extensions (except Xdebug, for functionality reasons). It simplifies configuration (file pathes, zend_extension, etc) and ensures compatibility when upgrading PHP. These may not be too strong, but if you don't have any objections I may try to implement this. Or do you see further issues with a C only header file?

@yitam
Copy link
Contributor

yitam commented Dec 6, 2018

@jjeising sure you're more than welcome to try this out. When you're ready, please submit your pull request to the dev branch, not the master branch.

@yitam
Copy link
Contributor

yitam commented Dec 24, 2018

Closing this issue as we have already merged your pull request, @jjeising
Please feel free to reopen if you like

@yitam yitam closed this as completed Dec 24, 2018
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

2 participants