grpc / grpc

The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)
https://grpc.io
Apache License 2.0
41.57k stars 10.49k forks source link

Unable to build PHP PECL extension on Windows. #35474

Open macintoshplus opened 8 months ago

macintoshplus commented 8 months ago

What version of gRPC and what language are you using?

PHP 8.2 x64 gRPC 1.60.0

What operating system (Linux, Windows,...) and version?

Windows 10 x64

What runtime / compiler are you using (e.g. python version or version of gcc)

Visual studio 2019 (vs16)

What did you do?

Please provide either 1) A unit test for reproducing the bug or 2) Specific steps for us to follow to reproduce the bug. If there’s not enough information to debug the problem, gRPC team may close the issue at their discretion. You’re welcome to re-open the issue once you have a reproduction. I want build the extension for Windows.

  1. extract PECL archive of version 1.60.0
  2. open CMD x64 build environement
  3. run PHP SDK phpsdk-vs16-x64.bat
  4. run phpize
  5. run configure --with-grpc --with-prefix=d:\actions-runner\_work\builder\builder\php-bin
  6. run nmake

What did you expect to see?

I expect the correct building PHP extension DLL.

What did you see instead?

When this command is exectuted:

"cl.exe" /D ZEND_COMPILE_DL_EXT=1 /D COMPILE_DL_GRPC /D GRPC_EXPORTS=1 /DOPENSSL_NO_ASM /D_GNU_SOURCE /DWIN32_LEAN_AND_MEAN /D_HAS_EXCEPTIONS=0 /DNOMINMAX /DGRPC_ARES=0 /D_WIN32_WINNT=0x600 /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0 /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\include /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\src\core\ext\upb-gen /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\src\core\ext\upbdefs-gen /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\src\php\ext\grpc /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\third_party\abseil-cpp /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\third_party\address_sorting\include /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\third_party\boringssl-with-bazel\src\include /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\third_party\re2 /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\third_party\upb /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\third_party\utf8_range /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\third_party\xxhash /ID:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\third_party\zlib  /nologo /I D:\actions-runner\_work\builder\builder\php-dev/include /I D:\actions-runner\_work\builder\builder\php-dev/include/main /I D:\actions-runner\_work\builder\builder\php-dev/include/Zend /I D:\actions-runner\_work\builder\builder\php-dev/include/TSRM /I D:\actions-runner\_work\builder\builder\php-dev/include/ext /D _WINDOWS /D WINDOWS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /D _USE_MATH_DEFINES /FS /FD /wd4996 /Qspectre /guard:cf /Zc:inline /Zc:__cplusplus /d2FuncCache1 /Zc:wchar_t /MP /LD /MD /Ox /D NDebug /D NDEBUG /GF /D ZEND_DEBUG=0 /D ZTS=1 /I "D:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\no\include" /FoD:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\x64\Release_TS\src\core\ext\filters\client_channel\lb_policy\grpclb\ /FpD:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\x64\Release_TS\src\core\ext\filters\client_channel\lb_policy\grpclb\ /FRD:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\x64\Release_TS\src\core\ext\filters\client_channel\lb_policy\grpclb\ /FdD:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\x64\Release_TS\src\core\ext\filters\client_channel\lb_policy\grpclb\ /c D:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\src\core\ext\filters\client_channel\lb_policy\grpclb\client_load_reporting_filter.cc D:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\src\core\ext\filters\client_channel\lb_policy\grpclb\grpclb.cc D:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\src\core\ext\filters\client_channel\lb_policy\grpclb\grpclb_balancer_addresses.cc D:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\src\core\ext\filters\client_channel\lb_policy\grpclb\grpclb_client_stats.cc D:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\src\core\ext\filters\client_channel\lb_policy\grpclb\load_balancer_api.cc

I have this error:

D:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\src\core\ext\filters\client_channel\lb_policy\grpclb\grpclb.cc: fatal error C1041: impossible d'ouvrir la base de données du programme 'D:\actions-runner\_work\builder\builder\ext\2\grpc-1.60.0\x64\Release_TS\src\core\ext\filters\client_channel\lb_policy\grpclb\vc140.idb' ; si plusieurs CL.EXE écrivent dans le même fichier .PDB, utilisez /FS.

To solve the fatal error C1041, I have try to add the /FS option without change.

Anything else we should know about your project / environment?

nope

macintoshplus commented 8 months ago

I found the solution. The destination folder does not exist before CL try create file.

I solve this issue by creating directory frere before build.

I close this issue.

macintoshplus commented 8 months ago

I have same issue for all x86 build for PHP 8.0 to 8.3. Any idea ?

I have already try:

tienvx commented 7 months ago

I am able to compile grpc extension for PHP 8.0 to 8.3 on Windows using this patch https://gist.github.com/tienvx/1ee366b4a2c64aea48f90db3ca3b8df4

macintoshplus commented 7 months ago

Thanks @tienvx, you can build for x86 architecture?

tienvx commented 7 months ago

No I didn't try. I only tried on x64 systems.