Made PHP extension compile with openssl by default (#41)

* Made PHP extension compile with openssl

* Use catchsegv to dump a callstack

* Updated to use aws_crt_crypto_share()

* Much faster builds by making cmake parallel if supported

* Make sure all CRT threads shutdown prior to cleanup

* USE_OPENSSL should be the path to openssldir

* Updated to aws-crt-ffi v0.2.4
This commit is contained in:
Justin Boswell
2021-08-30 13:36:54 -07:00
committed by GitHub
parent 0af673491a
commit 2f8d2ee756
7 changed files with 65 additions and 14 deletions
+26 -8
View File
@@ -37,14 +37,14 @@ jobs:
- name: Install depedencies
run: composer update --no-interaction
- name: Run tests
- name: Build for PHP 5.5
env:
CC: clang
CXX: clang++
run: |
phpize
./configure
make test
make
php-linux-x64:
runs-on: ubuntu-latest
@@ -60,12 +60,30 @@ jobs:
- "7.4"
- "8.0"
steps:
- name: PHP ${{ matrix.version}} Extension
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u awslabs --password-stdin
export DOCKER_IMAGE=docker.pkg.github.com/awslabs/aws-crt-builder/aws-crt-php${{ matrix.version }}-linux-x64:${{ env.BUILDER_VERSION }}
docker pull $DOCKER_IMAGE
docker run --env GITHUB_REF --env LC_ALL=C.UTF-8 $DOCKER_IMAGE --version=${{env.BUILDER_VERSION}} build -p ${{ env.PACKAGE_NAME }} --spec=downstream --skip-install
- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
php-version: ${{matrix.version}}
ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install depedencies
run: composer update --no-interaction
- name: Run tests
env:
CC: clang
CXX: clang++
run: |
phpize
./configure
make
make test
# linux-arm:
@@ -16,3 +16,14 @@ jobs:
with:
# List of extensions to check
extensions: c
check-submodules:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0
- name: Check Submodules
uses: awslabs/aws-crt-builder/.github/actions/check-submodules@main
+17 -2
View File
@@ -7,8 +7,23 @@ ifeq (, $(shell which cmake3))
CMAKE = cmake
endif
CMAKE_CONFIGURE = $(CMAKE) -DCMAKE_INSTALL_PREFIX=$(INT_DIR) -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
CMAKE_BUILD = $(CMAKE) --build
# default to using system OpenSSL, if disabled aws-lc will be used
USE_OPENSSL ?= ON
ifneq (OFF,$(USE_OPENSSL))
CMAKE_USE_OPENSSL=-DUSE_OPENSSL=ON
# if a path was provided, add it to CMAKE_PREFIX_PATH
ifneq (ON,$(USE_OPENSSL))
CMAKE_PREFIX_PATH=-DCMAKE_PREFIX_PATH=$(USE_OPENSSL)
endif
endif
CMAKE_CONFIGURE = $(CMAKE) \
-DCMAKE_INSTALL_PREFIX=$(INT_DIR) \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
$(CMAKE_USE_OPENSSL) \
$(CMAKE_PREFIX_PATH)
CMAKE_BUILD = CMAKE_BUILD_PARALLEL_LEVEL='' $(CMAKE) --build
CMAKE_BUILD_TYPE ?= RelWithDebInfo
CMAKE_TARGET = --config $(CMAKE_BUILD_TYPE) --target install
+1 -1
View File
@@ -13,7 +13,7 @@ if test "$PHP_AWSCRT" != "no"; then
if uname -a | grep -i darwin > /dev/null 2>&1; then
platform_tls_libs=""
else
platform_tls_libs="-ls2n -l:libcrypto.a"
platform_tls_libs="-ls2n -lcrypto"
fi
CRT_LIBPATHS="-L${cwd}/build/install/lib -L${cwd}/build/install/lib64"
CRT_LIBS="-laws-crt-ffi -laws-c-auth -laws-c-http -laws-c-io -laws-c-cal -laws-c-compression -laws-checksums -laws-c-common ${platform_tls_libs}"
+3
View File
@@ -241,6 +241,8 @@ PHP_INI_END()
static PHP_MINIT_FUNCTION(awscrt) {
REGISTER_INI_ENTRIES();
/* prevent s2n from initializing/de-initializing OpenSSL/libcrypto */
aws_crt_crypto_share();
aws_crt_init();
aws_php_thread_queue_init(&s_aws_php_main_thread_queue);
return SUCCESS;
@@ -249,6 +251,7 @@ static PHP_MINIT_FUNCTION(awscrt) {
static PHP_MSHUTDOWN_FUNCTION(awscrt) {
UNREGISTER_INI_ENTRIES();
aws_php_thread_queue_clean_up(&s_aws_php_main_thread_queue);
aws_crt_thread_join_all(0);
aws_crt_clean_up();
return SUCCESS;
}
+6 -2
View File
@@ -2,6 +2,11 @@
set -ex
launcher=
if command -v catchsegv; then
launcher=catchsegv
fi
if [ -z $PHP_BINARY ]; then
PHP_BINARY=$(which php)
fi
@@ -10,5 +15,4 @@ if [ ! -d vendor ]; then
composer update
fi
$PHP_BINARY -c php.ini vendor/bin/phpunit tests --debug
$launcher $PHP_BINARY -c php.ini vendor/bin/phpunit tests --debug