Add switch for LTO in Docker image

This commit is contained in:
Ilya Fedin 2022-11-03 23:47:28 +04:00 committed by John Preston
parent 0b2b3416d7
commit da2f1b3d97
3 changed files with 6 additions and 3 deletions

View File

@ -31,7 +31,7 @@ jobs:
run: |
cd Telegram/build/docker/centos_env
poetry install
DEBUG= poetry run gen_dockerfile | docker buildx build -t $IMAGE_TAG -
DEBUG= LTO= poetry run gen_dockerfile | docker buildx build -t $IMAGE_TAG -
- name: Push the Docker image.
if: ${{ github.ref_name == github.event.repository.default_branch }}

View File

@ -44,10 +44,12 @@ RUN mkdir /opt/cmake \
&& rm {{ CMAKE_FILE }}
FROM builder-base AS builder
{%- if LTO %}
ENV AR gcc-ar
ENV RANLIB gcc-ranlib
ENV NM gcc-nm
ENV CFLAGS {% if DEBUG %}-g{% endif %} -Ofast {% if DEBUG %}-flto=auto -ffat-lto-objects{% endif %} -pipe -fPIC -fstack-protector-all -fstack-clash-protection -DNDEBUG -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS
{%- endif %}
ENV CFLAGS {% if DEBUG %}-g{% endif %} -Ofast {% if LTO %}-flto=auto -ffat-lto-objects{% endif %} -pipe -fPIC -fstack-protector-all -fstack-clash-protection -DNDEBUG -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS
ENV CXXFLAGS $CFLAGS
FROM builder AS patches

View File

@ -5,7 +5,8 @@ from jinja2 import Environment, FileSystemLoader
def main():
print(Environment(loader=FileSystemLoader(dirname(__file__))).get_template("Dockerfile").render(
DEBUG=bool(len(environ["DEBUG"])) if "DEBUG" in environ else True
DEBUG=bool(len(environ["DEBUG"])) if "DEBUG" in environ else True,
LTO=bool(len(environ["LTO"])) if "LTO" in environ else True,
))
if __name__ == '__main__':