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 available to download #1507

Open
macintoshplus opened this issue Mar 23, 2024 · 29 comments
Open

Windows DLL available to download #1507

macintoshplus opened this issue Mar 23, 2024 · 29 comments

Comments

@macintoshplus
Copy link

I am pleased to announce that this extension is now compiled for Windows by the PHP Extension Repository site.

You can download the DLLs on the extension page: https://phpext.phptools.online/extension/database/pdo_sqlsrv-96

If you have any questions, I am available to discuss them.

@Jan-E
Copy link

Jan-E commented Jul 19, 2024

Did you already try to compile this for PHP 8.4.0 VS17, Alpha 2?

@macintoshplus
Copy link
Author

Hi @Jan-E ,

Yes, I have tried to compile the latest version (5.12.0).

The result is poor.

Error example:
error C2039: 'const_pointer' not a member of 'std::allocator'
NMAKE : fatal error U1077

I will work on it later.

@Jan-E
Copy link

Jan-E commented Jul 24, 2024

@cmb69 Jean-Baptiste Nahan aka @macintoshplus was able to compile php_pdo_sqlsrv.dll for PHP 8.3, but this fails for PHP 8.4.0 Alpha 2. Any idea what could be causing that?

@cmb69
Copy link

cmb69 commented Jul 24, 2024

@Jan-E, no particular idea, but since the latest commit in this repo was about updating the changelog to state "Support for PHP 8.3", I'd assume that the maintainers had no time yet to establish compatibility with PHP 8.4.

@cmb69
Copy link

cmb69 commented Jul 24, 2024

Also note that https://github.com/php/php-windows-builder already supports building pdo_sqlsrv and sqlsrv (and respective DLL downloads are available via the PECL website). I assume that mass rebuilds will be done later.

@macintoshplus
Copy link
Author

@Jan-E what architecture (x86/x64) and ts/nts do you need?

@cmb69
Copy link

cmb69 commented Jul 24, 2024

error C2039: 'const_pointer' not a member of 'std::allocator'

That apparently is not supported with /std:c++20.

@macintoshplus
Copy link
Author

error C2039: 'const_pointer' not a member of 'std::allocator'

That apparently is not supported with /std:c++20.

Ok, but /std:c++20 is needed to solve errors.

To solve this error error C4146: unary minus operator applied to unsigned type, result still unsigned, I need to change the php-8.4.0alpha2-devel-vs17-x64\include\ext\random\php_random_uint128.h in PHP devel.

Why?

Other error error C4576: a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax

@Jan-E
Copy link

Jan-E commented Jul 24, 2024

I had roughly the same errors. For GRPC 1.63.0 I had to go for standard C11:

ADD_FLAG("CFLAGS_GRPC", " /std:c11 ");

Might be a try. Change the CFLAGS into the good one for SQLSRV or PDO_SQLSRV

@cmb69
Copy link

cmb69 commented Jul 24, 2024

Ok, but /std:c++20 is needed to solve errors.

No, this is not (and should not be) needed. See php/php-src#15094 regarding the php_random.h issue, and php/php-src#15096 regarding an issue with zend_portability.h. I did successfully build (haven't run any test, though), but need to sort out the mess I've created in the meantime. Perhaps there are more issues that need to be properly fixed. And of course, the /sdl needs to be removed, like for PHP 8.3.

I had roughly the same errors. For GRPC 1.63.0 I had to go for standard C11:

That should be irrelevant, since this is a C++ extension. The default (C++14) should be good enough (with the already existing /Zc:__cplusplus directive, which sets __cplusplus accordingly).

@cmb69
Copy link

cmb69 commented Jul 24, 2024

Perhaps there are more issues that need to be properly fixed.

Apparently not. :)

@Jan-E
Copy link

Jan-E commented Jul 24, 2024

@Jan-E what architecture (x86/x64) and ts/nts do you need?

Actually, all of them. This is what triggered my question:
https://www.apachelounge.com/viewtopic.php?p=42895#42895
But it looks like @cmb69 is on track for solving the issue.

@macintoshplus
Copy link
Author

@cmb69 I have build sucessfully with your change in PR and this change:

file: php-8.4.0alpha2-devel-vs17-x64\include\ext\random\php_random_uint128.h

@84
- 	return (v >> s) | (v << ((-s) & 63));
+ 	return (v >> s) | (v << ((s) & 63));
@124
- 	return (v >> s) | (v << ((-s) & 63));
+ 	return (v >> s) | (v << ((s) & 63));

@cmb69
Copy link

cmb69 commented Jul 24, 2024

I think that this patch would change the behavior: s is unsigned, and the - is relevant, and the code is just relying on underflow, what is even specified behavior (IIRC), but certainly not undefined behavior. Or is that different in C++?

Better use #1496 instead, in my opinion.

@Jan-E
Copy link

Jan-E commented Jul 25, 2024

Even with the patch from php/php-src#15100 I am still getting error C2039: 'const_pointer': is not a member of 'std::allocator<void>'

That seems to be due yo the fact that it is used in L469 of

// memory allocation/deallocation
inline pointer allocate( _In_ size_type cnt,
typename std::allocator<void>::const_pointer = 0 )
{
return reinterpret_cast<pointer>( sqlsrv_malloc(cnt, sizeof (T), 0));
}

What did you change to make it compile?

@cmb69
Copy link

cmb69 commented Jul 25, 2024

error C2039: 'const_pointer': is not a member of 'std::allocator'

Try with an older C++ standard; that failed for me with C++20, but worked with the default (for me C++14).

@Jan-E
Copy link

Jan-E commented Jul 25, 2024

error C2039: 'const_pointer': is not a member of 'std::allocator'

Try with an older C++ standard; that failed for me with C++20, but worked with the default (for me C++14).

Works. https://phpdev.toolsforresearch.com/php-8.4.0alpha2-nts-Win32-vs17-x64.htm
I was already wondering why sqlsrv 5.11.1 was compiling with VS16, but failed with VS17. 5.11.1 has the same lines.
I did not run tests (due to missing a running SQL Server), but I will ask at Apachelounge if anyone can do some informal tests.

@cmb69
Copy link

cmb69 commented Jul 25, 2024

Note that building against early pre-releases is certainly a good idea to catch issues (either necessary changes to extension code, or, like in this case, upstream issues), but please do not redistribute such builds (at least add a warning), since the API version bump usually is done shortly prior to RC1, so previously build extension cannot be loaded anymore ("expected API version X, but got Y"). And building during RC stage for redistribution might still not be the best idea. When the PECL build machine was still running, we usually triggered mass rebuilds only a while after GA.

@Jan-E
Copy link

Jan-E commented Jul 25, 2024

The topic on Apachelounge starts with:

This topic is about 'non-production' builds.

@Jan-E
Copy link

Jan-E commented Jul 25, 2024

https://www.apachelounge.com/viewtopic.php?p=42906#42906

@cmb69
Copy link

cmb69 commented Jul 25, 2024

It seems pdo_sqlsrv 5.12.0 builds fine against PHP 8.4.0alpha2 with the same modifications.

@Jan-E
Copy link

Jan-E commented Jul 25, 2024

Yes, both sqlsrv 5.12.0 extensions are already included:
https://phpdev.toolsforresearch.com/php-8.4.0alpha2-nts-Win32-vs17-x64.htm
https://phpdev.toolsforresearch.com/php-8.4.0alpha2-Win32-vs17-x64.htm

@macintoshplus
Copy link
Author

macintoshplus commented Jul 25, 2024

Hi,

Like last night, the build error is always the same. I have tried using CFLAGS=/std:c++20 or /std:c++14 without change.

What have you changed after the 2 patches of @cmb69 and removing /sdl flag?

@cmb69 I have build sucessfully with your change in PR and this change:

file: php-8.4.0alpha2-devel-vs17-x64\include\ext\random\php_random_uint128.h

@84
- 	return (v >> s) | (v << ((-s) & 63));
+ 	return (v >> s) | (v << ((s) & 63));
@124
- 	return (v >> s) | (v << ((-s) & 63));
+ 	return (v >> s) | (v << ((s) & 63));

@cmb69 your 2 patches work fine and resolve errors but not all.

@macintoshplus
Copy link
Author

Ok, I can build the extensions. To solve the error, I removed the extension source code and extracted it again.

@Jan-E
Copy link

Jan-E commented Jul 25, 2024

Warnings, no errors. Sorry for the long lines. I am working on an iPad right now with a VNC connection to my build machine.

core_stmt.cpp
N:\php-sdk\php84dev\Zend\zend_gc.h(156): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data (compiling source file ext\pdo_sqlsrv\shared\core_init.cpp)
N:\php-sdk\php84dev\Zend\zend_gc.h(156): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data (compiling source file ext\pdo_sqlsrv\shared\core_results.cpp)
N:\php-sdk\php84dev\Zend\zend_gc.h(156): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data (compiling source file ext\pdo_sqlsrv\shared\core_conn.cpp)
N:\php-sdk\php84dev\Zend\zend_gc.h(156): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data (compiling source file ext\pdo_sqlsrv\shared\core_stmt.cpp)
N:\php-sdk\php84dev\ext\random\php_random_uint128.h(84): warning C4146: unary minus operator applied to unsigned type, result still unsigned (compiling source file ext\pdo_sqlsrv\shared\core_results.cpp)
N:\php-sdk\php84dev\ext\random\php_random_uint128.h(84): warning C4146: unary minus operator applied to unsigned type, result still unsigned (compiling source file ext\pdo_sqlsrv\shared\core_init.cpp)
N:\php-sdk\php84dev\ext\random\php_random_uint128.h(84): warning C4146: unary minus operator applied to unsigned type, result still unsigned (compiling source file ext\pdo_sqlsrv\shared\core_conn.cpp)
N:\php-sdk\php84dev\ext\random\php_random_uint128.h(84): warning C4146: unary minus operator applied to unsigned type, result still unsigned (compiling source file ext\pdo_sqlsrv\shared\core_stmt.cpp)
ext\pdo_sqlsrv\shared\core_conn.cpp(952): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data
core_stream.cpp
ext\pdo_sqlsrv\shared\core_conn.cpp(1195): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(951): warning C4244: '=': conversion from 'SQLLEN' to 'long', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1609): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1621): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1624): warning C4244: 'argument': conversion from '__int64' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1664): warning C4244: '=': conversion from 'SQLLEN' to 'SQLSMALLINT', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1899): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1946): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1947): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1953): warning C4244: 'argument': conversion from '__int64' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1964): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1969): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1971): warning C4244: 'argument': conversion from '__int64' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1977): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1980): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(1981): warning C4244: '=': conversion from '__int64' to 'int', possible loss of data
ext\pdo_sqlsrv\shared\core_stmt.cpp(3567): warning C4267: 'argument': conversion from 'size_t' to 'unsigned short', possible loss of data
core_util.cpp

@macintoshplus
Copy link
Author

Now, I have this log too.

@cmb69
Copy link

cmb69 commented Jul 25, 2024

In a perfect world, these warnings should be resolved, but as far as I can tell, these are level 2 and 3 warnings; if you want them suppressed, remove the /W3 from config.w32 (it's on the same line as '/sdl'), and phpize again.

@Jan-E
Copy link

Jan-E commented Jul 25, 2024

With a x86 build there are less warnings.

core_stmt.cpp
N:\php-sdk\php84dev\ext\random\php_random_uint128.h(84): warning C4146: unary minus operator applied to unsigned type, result still unsigned (compiling source file ext\sqlsrv\shared\core_init.cpp)
N:\php-sdk\php84dev\ext\random\php_random_uint128.h(84): warning C4146: unary minus operator applied to unsigned type, result still unsigned (compiling source file ext\sqlsrv\shared\core_results.cpp)
N:\php-sdk\php84dev\ext\random\php_random_uint128.h(84): warning C4146: unary minus operator applied to unsigned type, result still unsigned (compiling source file ext\sqlsrv\shared\core_stmt.cpp)
N:\php-sdk\php84dev\ext\random\php_random_uint128.h(84): warning C4146: unary minus operator applied to unsigned type, result still unsigned (compiling source file ext\sqlsrv\shared\core_conn.cpp)
core_stream.cpp
ext\sqlsrv\shared\core_stmt.cpp(1664): warning C4244: '=': conversion from 'SQLINTEGER' to 'SQLSMALLINT', possible loss of data
ext\sqlsrv\shared\core_stmt.cpp(1918): warning C4018: '<': signed/unsigned mismatch
ext\sqlsrv\shared\core_stmt.cpp(3567): warning C4267: 'argument': conversion from 'size_t' to 'unsigned short', possible loss of data
core_util.cpp

@Jan-E
Copy link

Jan-E commented Jul 31, 2024

https://www.apachelounge.com/viewtopic.php?p=42906#42906

With a reply:

I can confirm this current 8.4.0 Alpha 2 does contain SQLSRV and it works.
I've tested my use cases (Mostly selects and inserts) and all works like a charm.

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