Skip to content

Commit a4a65ee

Browse files
committed
Improve build flags for extensions
1 parent 54107d5 commit a4a65ee

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

scripts/build.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,16 @@ get_buildflags() {
4646
echo "$flags"
4747
}
4848

49-
# Function to build PHP.
50-
build_php() {
51-
echo "::group::$1"
52-
SAPI=$1
53-
49+
# Function to configure flags
50+
configure_flags() {
5451
# Set and export FLAGS
5552
CFLAGS="$(get_buildflags CFLAGS "$lto") $(getconf LFS_CFLAGS)"
5653
CFLAGS=$(echo "$CFLAGS" | sed -E 's/-Werror=implicit-function-declaration//g')
5754
CFLAGS="$CFLAGS -DOPENSSL_SUPPRESS_DEPRECATED"
5855

5956
CPPFLAGS="$(get_buildflags CPPFLAGS "$lto")"
6057
CXXFLAGS="$(get_buildflags CXXFLAGS "$lto")"
61-
LDFLAGS="$(get_buildflags LDFLAGS "$lto") -Wl,-z,now -Wl,--as-needed"
58+
LDFLAGS="$(get_buildflags LDFLAGS "$lto") -Wl,--as-needed"
6259

6360
if [[ "$PHP_VERSION" =~ 5.6|7.[0-4]|8.0 ]]; then
6461
EXTRA_CFLAGS="-fpermissive -Wno-deprecated -Wno-deprecated-declarations"
@@ -83,6 +80,14 @@ build_php() {
8380
export DEB_HOST_MULTIARCH
8481
export ICU_CXXFLAGS
8582
export SED
83+
}
84+
85+
# Function to build PHP.
86+
build_php() {
87+
echo "::group::$1"
88+
SAPI=$1
89+
90+
configure_flags
8691

8792
# Export inputs
8893
export INSTALL_ROOT

scripts/install-extension.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ tar xf "/tmp/$extension.tar.gz" -C /tmp
3131
cd /tmp/"$(basename "$repo")"-"${tag/\//-}" || exit 1
3232
fi
3333
export SED=$(command -v sed)
34+
ORIG_CFLAGS=$CFLAGS
35+
ORIG_LDFLAGS=$LDFLAGS
36+
configure_flags
3437
patch_"${extension}" 2>/dev/null || true
3538
phpize
3639
./configure "--with-php-config=/usr/bin/php-config" "${params[@]}"
@@ -39,4 +42,6 @@ tar xf "/tmp/$extension.tar.gz" -C /tmp
3942
# shellcheck disable=SC2097
4043
# shellcheck disable=SC2098
4144
INSTALL_ROOT="$INSTALL_ROOT" make install DESTDIR="$INSTALL_ROOT"
45+
export CFLAGS=$ORIG_CFLAGS
46+
export LDFLAGS=$ORIG_LDFLAGS
4247
)

scripts/patch-extensions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ configure_imagick() {
1414
echo "MagickWand not found — install libmagickwand-dev" >&2
1515
exit 1
1616
fi
17-
export CPPFLAGS="$(pkg-config --cflags "$PKG_WAND")"
18-
export LDFLAGS="$(pkg-config --libs "$PKG_WAND")"
17+
export CPPFLAGS="$CPPFLAGS $(pkg-config --cflags "$PKG_WAND")"
18+
export LDFLAGS="$LDFLAGS $(pkg-config --libs "$PKG_WAND")"
1919
}
2020

2121
# Function to patch imagick source.

0 commit comments

Comments
 (0)