Skip to content

Commit cb29f5c

Browse files
authored
Use Link Time Optimization during compilation (#153)
* Use Link Time Optimization during compilation Resolves #152 Uses the cc and ld options from the Ubuntu build. https://gcc.gnu.org/wiki/LinkTimeOptimization * Update readme.md
1 parent 3475299 commit cb29f5c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ARG NGINX_USER_UID=100
2525
ARG NGINX_GROUP_GID=101
2626

2727
# https://nginx.org/en/docs/http/ngx_http_v3_module.html
28+
# https://nginx.org/en/docs/configure.html
2829
ARG CONFIG="\
2930
--build=$NGINX_COMMIT \
3031
--prefix=/etc/nginx \
@@ -176,11 +177,14 @@ RUN \
176177
&& mv /usr/src/njs/build/njs /usr/sbin/njs \
177178
&& echo "njs v$(njs -v)"
178179

180+
# https://github.com/macbre/docker-nginx-http3/issues/152
181+
ARG CC_OPT='-g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects'
182+
ARG LD_OPT='-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto'
179183
RUN \
180184
echo "Building nginx ..." \
181185
&& mkdir -p /var/run/nginx/ \
182186
&& cd /usr/src/nginx-$NGINX_VERSION \
183-
&& ./auto/configure $CONFIG \
187+
&& ./auto/configure $CONFIG --with-cc-opt="$CC_OPT" --with-ld-opt="$LD_OPT" \
184188
&& make -j"$(getconf _NPROCESSORS_ONLN)"
185189

186190
RUN \
@@ -213,8 +217,8 @@ ARG NGINX_COMMIT
213217
ARG NGINX_USER_UID
214218
ARG NGINX_GROUP_GID
215219

216-
ENV NGINX_VERSION $NGINX_VERSION
217-
ENV NGINX_COMMIT $NGINX_COMMIT
220+
ENV NGINX_VERSION=$NGINX_VERSION
221+
ENV NGINX_COMMIT=$NGINX_COMMIT
218222

219223
COPY --from=base /var/run/nginx/ /var/run/nginx/
220224
COPY --from=base /tmp/runDeps.txt /tmp/runDeps.txt

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ configure arguments:
8282
--add-module=/usr/src/headers-more-nginx-module-0.37
8383
--add-module=/usr/src/njs/nginx
8484
--add-dynamic-module=/usr/src/ngx_http_geoip2_module
85+
--with-cc-opt='-g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects'
86+
--with-ld-opt='-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto'
8587
8688
$ docker run -it macbre/nginx-http3 njs -v
8789
0.8.6

0 commit comments

Comments
 (0)