awslabs / aws-crt-php

Apache License 2.0
322 stars 13 forks source link

Fatal error during compilation on Windows 10 x64 #68

Closed Synida closed 1 year ago

Synida commented 1 year ago

Confirm by changing [ ] to [x] below:

Platform/OS/Hardware/Device What are you running the sdk on? Windows 10 x64 with Visual Studio 2017 SDK version: 2.2.0 and 2.2.1-dev as well(same issue)

Describe the question I tried to compile this extension, because it's required for signature v4a, which is necessary for EventBridge to be able to put events on the bus, but keep getting fatal error. I was documenting what I was doing, and it's the following:

  1. Download SDK: https://github.com/Microsoft/php-sdk-binary-tools
  2. Put the SDK somewhere on your machine
  3. Use the following command: phpsdk-starter.bat -c vc15 -a x64 vc15 is for compiling PHP 7.2+, vc16 for master. vc15 is Visual Studio 2017, vc16 is Visual Studio 2019. x64/x86 is your OS architecture.
  4. Prepare the SDK environment for compiling PHP: phpsdk_buildtree php-dev This will create a php-dev/vc15/x64 folder structure, and cd into it
  5. Clone the php repo, and checkout the target version's branch: git clone https://github.com/php/php-src.git && cd php-src && git checkout PHP-7.4.32
  6. Download the module library dependencies: phpsdk_deps -u - throws error if you didn't have git file showing the correct branch
  7. Get the awscrt library: git clone --recursive https://github.com/awslabs/aws-crt-php.git ..\pecl\awscrt
  8. Check out the lts version of it by cd into the directory and go to the branch: cd ..\pecl\awscrt && git checkout tags/v1.0.2 && cd ..\..\php-src
  9. Clone the parallel repository in the same way: git clone --recursive https://github.com/krakjoe/parallel.git ..\pecl\parallel
  10. Checkout the LTS version for this one as well: cd ..\pecl\parallel && git checkout tags/v1.1.4 && phpize && cd ..\..\php-src - phpize might be a problem, solution?
  11. Build configuration: buildconf
  12. Configure:
    configure --disable-all --enable-cli --with-curl --enable-zts --enable-cgi --enable-zip --with-bz2 --enable-ftp --with-gettext --with-readline --with-gmp --enable-intl --enable-soap --enable-sockets --enable-exif --enable-bcmath --enable-mbstring --enable-json --enable-session --enable-opcache --enable-apache2-4handler --enable-embed --enable-pdo --enable-tokenizer --enable-calendar --enable-ctype --with-dom --enable-filter --with-gd --with-mhash --with-iconv --with-libxml --with-mysqli --with-mysqlnd --enable-phar --with-simplexml --enable-zlib --with-openssl --enable-awscrt=shared --enable-parallel=static
  13. Compile php: nmake

Logs/output Output from the configuration through the build phase: attached in txt file error output from php compilation.txt

REMEMBER TO SANITIZE YOUR PERSONAL INFO

Thank you for the help!

Synida commented 1 year ago

I guess, this project was abandoned.

Synida commented 1 year ago

btw can't build it on arch linux either. Build fails around 39%

TingDaoK commented 1 year ago

There are two things from what I tested.

First:

-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe

From your output, cmake is pick x86 msvc compiler. And that's why the link complains about the 32 bit vs 64 bit. And for the reason why it's pick up x86 instead of x64, the best I can guess is that here Cmake default to pick up Win32 for MSVC 15.

The proper fix should be we pick up the expected arch from somewhere and update our cmake script to use. Second optimal fix is to provide an override for user. The worst but quickest fix I used, run the following cmake configure manually before you run Step 13 nmake

cmake.exe -DCMAKE_INSTALL_PREFIX=..\pecl\awscrt\build\install -DCMAKE_PREFIX_PATH=..\pecl\awscrt\build\install -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -H..\pecl\awscrt\crt\aws-crt-ffi -B..\pecl\awscrt\build -A x64 -DBUILD_SHARED_LIBS=OFF

I'll try to make an override option, but it also needs more investigation.

Second:

The build is still not working for windows. Apply my change here to ..\pecl\awscrt\config.w32 before you run step 12 Configure

After that it built successfully for me

TingDaoK commented 1 year ago

For the first issue, I found a less hacky way:

set CMAKE_GENERATOR=Visual Studio 15 2017
set CMAKE_GENERATOR_PLATFORM=x64

And run nmake, it works for me. And I think it's just cmake thing, I can add it to our readme about building windows

TingDaoK commented 1 year ago

The fix has been merged, all the tests were verified working correctly.