Skip to content

Commit bb4874c

Browse files
committed
Switch CFLAGS to PHP_CFLAGS, so we can keep pie without breaking users
1 parent 35080cc commit bb4874c

4 files changed

+24
-6
lines changed

Dockerfile-alpine.template

+6-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ RUN mkdir -p $PHP_INI_DIR/conf.d
3737
# Enable linker optimization (this sorts the hash buckets to improve cache locality, and is non-default)
3838
# Adds GNU HASH segments to generated executables (this is used if present, and is much faster than sysv hash; in this configuration, sysv hash is also generated)
3939
# https://github.com/docker-library/php/issues/272
40-
ENV CFLAGS="-fstack-protector-strong -fpic -fpie -O2"
41-
ENV CPPFLAGS="$CFLAGS"
42-
ENV LDFLAGS="-Wl,-O1 -Wl,--hash-style=both"
40+
ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2"
41+
ENV PHP_CPPFLAGS="$PHP_CFLAGS"
42+
ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie"
4343

4444
ENV GPG_KEYS %%GPG_KEYS%%
4545

@@ -89,6 +89,9 @@ RUN set -xe \
8989
openssl-dev \
9090
sqlite-dev \
9191
\
92+
&& export CFLAGS="$PHP_CFLAGS" \
93+
CPPFLAGS="$PHP_CPPFLAGS" \
94+
LDFLAGS="$PHP_LDFLAGS" \
9295
&& docker-php-source extract \
9396
&& cd /usr/src/php \
9497
&& ./configure \

Dockerfile-debian.template

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ RUN mkdir -p $PHP_INI_DIR/conf.d
3232
# Enable linker optimization (this sorts the hash buckets to improve cache locality, and is non-default)
3333
# Adds GNU HASH segments to generated executables (this is used if present, and is much faster than sysv hash; in this configuration, sysv hash is also generated)
3434
# https://github.com/docker-library/php/issues/272
35-
ENV CFLAGS="-fstack-protector-strong -fpic -fpie -O2"
36-
ENV CPPFLAGS="$CFLAGS"
37-
ENV LDFLAGS="-Wl,-O1 -Wl,--hash-style=both"
35+
ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2"
36+
ENV PHP_CPPFLAGS="$PHP_CFLAGS"
37+
ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie"
3838

3939
ENV GPG_KEYS %%GPG_KEYS%%
4040

@@ -88,6 +88,9 @@ RUN set -xe \
8888
" \
8989
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
9090
\
91+
&& export CFLAGS="$PHP_CFLAGS" \
92+
CPPFLAGS="$PHP_CPPFLAGS" \
93+
LDFLAGS="$PHP_LDFLAGS" \
9194
&& docker-php-source extract \
9295
&& cd /usr/src/php \
9396
&& ./configure \

docker-php-ext-configure

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/sh
22
set -e
33

4+
# prefer user supplied CFLAGS, but default to our PHP_CFLAGS
5+
: ${CFLAGS:=$PHP_CFLAGS}
6+
: ${CPPFLAGS:=$PHP_CPPFLAGS}
7+
: ${LDFLAGS:=$PHP_LDFLAGS}
8+
export CFLAGS CPPFLAGS LDFLAGS
9+
410
srcExists=
511
if [ -d /usr/src/php ]; then
612
srcExists=1

docker-php-ext-install

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/sh
22
set -e
33

4+
# prefer user supplied CFLAGS, but default to our PHP_CFLAGS
5+
: ${CFLAGS:=$PHP_CFLAGS}
6+
: ${CPPFLAGS:=$PHP_CPPFLAGS}
7+
: ${LDFLAGS:=$PHP_LDFLAGS}
8+
export CFLAGS CPPFLAGS LDFLAGS
9+
410
srcExists=
511
if [ -d /usr/src/php ]; then
612
srcExists=1

0 commit comments

Comments
 (0)