Strip symbols only for non-debug PHP build (#540)

pull/538/head 1.4.31
Michael Voříšek 2022-03-25 10:20:09 +01:00 committed by GitHub
parent 36404177eb
commit 9167ef9b59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 7 deletions

View File

@ -84,6 +84,7 @@ setDistro() {
# - PHP_MAJMINPAT_VERSION: Major-Minor-Patch version, format MMmmpp (example 80001 for PHP 8.0.1) variables containing integers value # - PHP_MAJMINPAT_VERSION: Major-Minor-Patch version, format MMmmpp (example 80001 for PHP 8.0.1) variables containing integers value
# - PHP_MAJDOTMINDOTPAT_VERSION: Major-Minor-Patch version, format M.m.p (example 8.0.1 for PHP 8.0.1) # - PHP_MAJDOTMINDOTPAT_VERSION: Major-Minor-Patch version, format M.m.p (example 8.0.1 for PHP 8.0.1)
# - PHP_THREADSAFE: 1 if PHP is thread-safe (TS), 0 if not thread-safe (NTS) # - PHP_THREADSAFE: 1 if PHP is thread-safe (TS), 0 if not thread-safe (NTS)
# - PHP_DEBUGBUILD: 1 if PHP is debug build (configured with "--enable-debug"), 0 otherwise
# - PHP_BITS: 32 if PHP is compiled for 32-bit, 64 if 64-bit # - PHP_BITS: 32 if PHP is compiled for 32-bit, 64 if 64-bit
# - PHP_EXTDIR: the absolute path where the PHP extensions reside # - PHP_EXTDIR: the absolute path where the PHP extensions reside
setPHPVersionVariables() { setPHPVersionVariables() {
@ -91,8 +92,9 @@ setPHPVersionVariables() {
PHP_MAJMIN_VERSION=$(printf '%s' "$PHP_MAJDOTMINDOTPAT_VERSION" | awk -F. '{print $1*100+$2}') PHP_MAJMIN_VERSION=$(printf '%s' "$PHP_MAJDOTMINDOTPAT_VERSION" | awk -F. '{print $1*100+$2}')
PHP_MAJDOTMIN_VERSION=$(printf '%s' "$PHP_MAJDOTMINDOTPAT_VERSION" | cut -d. -f1-2) PHP_MAJDOTMIN_VERSION=$(printf '%s' "$PHP_MAJDOTMINDOTPAT_VERSION" | cut -d. -f1-2)
PHP_MAJMINPAT_VERSION=$(printf '%s' "$PHP_MAJDOTMINDOTPAT_VERSION" | awk -F. '{print $1*10000+$2*100+$3}') PHP_MAJMINPAT_VERSION=$(printf '%s' "$PHP_MAJDOTMINDOTPAT_VERSION" | awk -F. '{print $1*10000+$2*100+$3}')
PHP_THREADSAFE=$(php -r 'echo ZEND_THREAD_SAFE ? 1 : 0;') PHP_THREADSAFE=$(php -n -r 'echo ZEND_THREAD_SAFE ? 1 : 0;')
PHP_BITS=$(php -r 'echo PHP_INT_SIZE * 8;') PHP_DEBUGBUILD=$(php -n -r 'echo ZEND_DEBUG_BUILD ? 1 : 0;')
PHP_BITS=$(php -n -r 'echo PHP_INT_SIZE * 8;')
PHP_EXTDIR="$(php -d display_errors=stderr -r 'echo realpath(ini_get("extension_dir"));')" PHP_EXTDIR="$(php -d display_errors=stderr -r 'echo realpath(ini_get("extension_dir"));')"
} }
@ -1403,11 +1405,13 @@ postProcessModule() {
printf 'Unable to find the file of the PHP extension "%s"\n' "$1" >&2 printf 'Unable to find the file of the PHP extension "%s"\n' "$1" >&2
return 1 return 1
fi fi
printf 'Removing symbols from %s... ' "$postProcessModule_file" if test $PHP_DEBUGBUILD -ne 1; then
postProcessModule_preSize="$(stat -c %s "$postProcessModule_file")" printf 'Removing symbols from %s... ' "$postProcessModule_file"
strip --strip-all "$postProcessModule_file" postProcessModule_preSize="$(stat -c %s "$postProcessModule_file")"
postProcessModule_postSize="$(stat -c %s "$postProcessModule_file")" strip --strip-all "$postProcessModule_file"
printf 'done (%s bytes saved).\n' "$((postProcessModule_preSize - postProcessModule_postSize))" postProcessModule_postSize="$(stat -c %s "$postProcessModule_file")"
printf 'done (%s bytes saved).\n' "$((postProcessModule_preSize - postProcessModule_postSize))"
fi
return $? return $?
} }