Skip to content

Commit 0011777

Browse files
committed
Integrate static lexbor library into PHP builds for CentOS and Ubuntu Dockerfiles, ensuring proper linking and verification of embedded symbols.
1 parent 324affd commit 0011777

File tree

2 files changed

+77
-5
lines changed

2 files changed

+77
-5
lines changed

.github/workflows/Dockerfile.centos-php-test-zts

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ RUN yum install -y autoconf bison pkgconfig \
4444
# Install mariadb-devel separately (may need different repo or skip if not critical)
4545
RUN yum install -y mariadb-devel || yum install -y mariadb-connector-c-devel || echo "Warning: mariadb-devel not available, continuing without it"
4646

47+
# Build and install lexbor library (STATIC - embedded into libphp.so)
48+
ENV LEXBOR_VERSION=2.4.0
49+
RUN git clone --depth 1 --branch v${LEXBOR_VERSION} https://github.com/lexbor/lexbor.git /tmp/lexbor-src && \
50+
cd /tmp/lexbor-src && \
51+
cmake -S . -B build \
52+
-DCMAKE_BUILD_TYPE=Release \
53+
-DCMAKE_INSTALL_PREFIX=/usr/local \
54+
-DLEXBOR_BUILD_SHARED=OFF \
55+
-DLEXBOR_BUILD_STATIC=ON \
56+
-DLEXBOR_INSTALL_HEADERS=ON && \
57+
cmake --build build && \
58+
cmake --install build && \
59+
echo "Lexbor STATIC library installed:" && \
60+
ls -la /usr/local/lib*/liblexbor* || true && \
61+
ls -la /usr/local/include/lexbor/ || true && \
62+
rm -rf /tmp/lexbor-src
63+
4764
# Fetch and build PHP from source with ZTS
4865
FROM base AS php-build
4966
ARG PHP_SRC_REF
@@ -73,6 +90,16 @@ RUN mkdir -p /usr/local/etc/php/conf.d
7390

7491
# Build PHP with ZTS enabled
7592
RUN ./configure \
93+
COPY --from=base /usr/local/include/lexbor /usr/local/include/lexbor
94+
COPY --from=base /usr/local/lib /usr/local/lib
95+
COPY --from=base /usr/local/lib64 /usr/local/lib64
96+
97+
# Build PHP with ZTS enabled and statically link lexbor
98+
RUN export CFLAGS="-I/usr/local/include" && \
99+
export LDFLAGS="-L/usr/local/lib -L/usr/local/lib64" && \
100+
export LIBS="/usr/local/lib64/liblexbor_static.a" && \
101+
ls -lh /usr/local/lib*/liblexbor* && \
102+
./configure \
76103
--prefix=/usr/local \
77104
--with-config-file-path=/usr/local/lib \
78105
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
@@ -82,6 +109,13 @@ RUN ./configure \
82109
--enable-mbstring \
83110
--enable-pcntl \
84111
--enable-cgi \
112+
--enable-embed \
113+
--enable-dom \
114+
--enable-xml \
115+
--enable-simplexml \
116+
--enable-xmlreader \
117+
--enable-xmlwriter \
118+
--with-xsl \
85119
--with-extra-version="" \
86120
--with-curl \
87121
--with-mysqli \
@@ -103,12 +137,14 @@ RUN cmake -S . -B build \
103137
-DBUILD_HDR=ON && \
104138
cmake --build build && \
105139
cmake --install build && \
106-
ldconfig
140+
ldconfig /usr/local/lib /usr/local/lib64
107141

108142
FROM base AS final
109143

110144
COPY --from=php-build /usr/local /usr/local
111145

146+
RUN ldconfig /usr/local/lib /usr/local/lib64
147+
112148
COPY frankenphp-binary/ /tmp/frankenphp-binary/
113149
RUN if [ -f /tmp/frankenphp-binary/frankenphp ]; then \
114150
cp /tmp/frankenphp-binary/frankenphp /usr/local/bin/frankenphp && \
@@ -123,15 +159,15 @@ RUN EXTENSION_DIR=$(php -i | grep "^extension_dir" | awk '{print $3}') && \
123159
echo "Error: Could not determine extension_dir"; \
124160
exit 1; \
125161
fi && \
126-
mkdir -p "$EXTENSION_DIR" \
162+
mkdir -p "$EXTENSION_DIR" && \
127163
echo "Created extension_dir: $EXTENSION_DIR"
128164

129165
# Verify ZTS is enabled
130166
RUN php -v | grep -q "ZTS" || (echo "ERROR: ZTS not enabled!" && exit 1) && \
131167
php -m | grep -E 'curl|mysqli' >/dev/null
132168

133169
ENV PATH="/usr/local/bin:${PATH}" \
134-
LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH:-}"
170+
LD_LIBRARY_PATH="/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH:-}"
135171

136172
RUN ln -sf /usr/local/bin/php /usr/bin/php && \
137173
ln -sf /usr/local/sbin/php-fpm /usr/sbin/php-fpm || true && \

.github/workflows/Dockerfile.ubuntu-php-test-zts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ RUN ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime && \
3333
echo "${TZ}" > /etc/timezone && \
3434
dpkg-reconfigure -f noninteractive tzdata
3535

36+
ENV LEXBOR_VERSION=2.4.0
37+
RUN git clone --depth 1 --branch v${LEXBOR_VERSION} https://github.com/lexbor/lexbor.git /tmp/lexbor-src && \
38+
cd /tmp/lexbor-src && \
39+
cmake -S . -B build \
40+
-DCMAKE_BUILD_TYPE=Release \
41+
-DCMAKE_INSTALL_PREFIX=/usr/local \
42+
-DLEXBOR_BUILD_SHARED=OFF \
43+
-DLEXBOR_BUILD_STATIC=ON \
44+
-DLEXBOR_INSTALL_HEADERS=ON && \
45+
cmake --build build && \
46+
cmake --install build && \
47+
echo "Lexbor STATIC library installed:" && \
48+
ls -la /usr/local/lib*/liblexbor* || true && \
49+
ls -la /usr/local/include/lexbor/ || true && \
50+
rm -rf /tmp/lexbor-src
51+
3652
# Fetch and build PHP from source with ZTS
3753
FROM base AS php-build
3854
ARG PHP_SRC_REF
@@ -65,8 +81,19 @@ RUN a2dismod mpm_event || true && \
6581
a2dismod mpm_worker || true && \
6682
a2enmod mpm_prefork rewrite cgi cgid || true
6783

84+
# Copy lexbor static library and headers from base stage
85+
COPY --from=base /usr/local/include/lexbor /usr/local/include/lexbor
86+
COPY --from=base /usr/local/lib /usr/local/lib
87+
COPY --from=base /usr/local/lib64 /usr/local/lib64
88+
89+
# Build PHP with ZTS enabled and statically link lexbor
90+
RUN export CFLAGS="-I/usr/local/include" && \
91+
export LDFLAGS="-L/usr/local/lib -L/usr/local/lib64" && \
92+
export LIBS="/usr/local/lib64/liblexbor_static.a" && \
6893
# Build PHP with ZTS enabled
6994
RUN ./configure \
95+
ls -lh /usr/local/lib*/liblexbor* && \
96+
./configure \
7097
--prefix=/usr/local \
7198
--with-config-file-path=/usr/local/lib \
7299
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
@@ -76,6 +103,13 @@ RUN ./configure \
76103
--enable-mbstring \
77104
--enable-pcntl \
78105
--enable-cgi \
106+
--enable-embed \
107+
--enable-dom \
108+
--enable-xml \
109+
--enable-simplexml \
110+
--enable-xmlreader \
111+
--enable-xmlwriter \
112+
--with-xsl \
79113
--with-extra-version="" \
80114
--with-curl \
81115
--with-mysqli \
@@ -97,13 +131,15 @@ RUN cmake -S . -B build \
97131
-DBUILD_HDR=ON && \
98132
cmake --build build && \
99133
cmake --install build && \
100-
ldconfig
134+
ldconfig /usr/local/lib /usr/local/lib64
101135

102136
# Final image with PHP and test infrastructure
103137
FROM base AS final
104138

105139
COPY --from=php-build /usr/local /usr/local
106140

141+
RUN ldconfig /usr/local/lib /usr/local/lib64
142+
107143
COPY frankenphp-binary/ /tmp/frankenphp-binary/
108144
RUN if [ -f /tmp/frankenphp-binary/frankenphp ]; then \
109145
cp /tmp/frankenphp-binary/frankenphp /usr/local/bin/frankenphp && \
@@ -127,7 +163,7 @@ RUN php -v | grep -q "ZTS" || (echo "ERROR: ZTS not enabled!" && exit 1) && \
127163
php -m | grep -E 'curl|mysqli' >/dev/null
128164

129165
ENV PATH="/usr/local/bin:${PATH}" \
130-
LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH:-}"
166+
LD_LIBRARY_PATH="/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH:-}"
131167

132168
RUN ln -sf /usr/local/bin/php /usr/bin/php && \
133169
ln -sf /usr/local/sbin/php-fpm /usr/sbin/php-fpm || true && \

0 commit comments

Comments
 (0)