From 0cddac16fb7c810017fe94c5b8569f4858dc7cb7 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 26 Feb 2026 22:00:25 +0000 Subject: [PATCH] Add MinSizeRel support on Linux Allows to build Telegram itself with multi-config generator as well as all dependencies with -Os optimizations --- CMakeLists.txt | 10 ++++++++++ Telegram/build/docker/centos_env/Dockerfile | 5 ++++- Telegram/build/docker/centos_env/gen_dockerfile.py | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc7b239b03..e762a3cd59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,10 @@ include(cmake/validate_special_target.cmake) include(cmake/version.cmake) desktop_app_parse_version(Telegram/build/version) +if (NOT DEFINED CMAKE_CONFIGURATION_TYPES) + set(configuration_types_init 1) +endif() + project(Telegram LANGUAGES C CXX VERSION ${desktop_app_version_cmake} @@ -23,6 +27,12 @@ if (APPLE) enable_language(OBJC OBJCXX) endif() +if (configuration_types_init + AND CMAKE_CONFIGURATION_TYPES + AND NOT MinSizeRel IN_LIST CMAKE_CONFIGURATION_TYPES) + set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES};MinSizeRel" CACHE STRING "" FORCE) +endif() + set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Telegram) get_filename_component(third_party_loc "Telegram/ThirdParty" REALPATH) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index e5ce8f7fe8..40bb23e1d4 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -44,7 +44,7 @@ WORKDIR /usr/src ENV AR=gcc-ar ENV RANLIB=gcc-ranlib ENV NM=gcc-nm -ENV CFLAGS='{% if DEBUG %}-g{% endif %} -O3 {% if LTO %}-flto=auto -ffat-lto-objects{% endif %} -pipe -fPIC -fno-strict-aliasing -fexceptions -fasynchronous-unwind-tables -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fhardened -Wno-hardened' +ENV CFLAGS='{% if DEBUG %}-g{% endif %} {% if MINSIZE %}-Os{% else %}-O3{% endif %} {% if LTO %}-flto=auto -ffat-lto-objects{% endif %} -pipe -fPIC -fno-strict-aliasing -fexceptions -fasynchronous-unwind-tables -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fhardened -Wno-hardened' ENV CXXFLAGS=$CFLAGS ENV LDFLAGS='-static-libstdc++ -static-libgcc -static-libasan -pthread -Wl,--push-state,--no-as-needed,-ldl,--pop-state -Wl,--as-needed -Wl,-z,muldefs' @@ -527,6 +527,9 @@ RUN git clone -b n6.1.1 --depth=1 https://github.com/FFmpeg/FFmpeg.git \ --disable-network \ --disable-autodetect \ --disable-everything \ +{%- if MINSIZE %} + --enable-small \ +{%- endif %} --enable-libdav1d \ --enable-libopenh264 \ --enable-libopus \ diff --git a/Telegram/build/docker/centos_env/gen_dockerfile.py b/Telegram/build/docker/centos_env/gen_dockerfile.py index 0e40b08340..86d27c96e1 100755 --- a/Telegram/build/docker/centos_env/gen_dockerfile.py +++ b/Telegram/build/docker/centos_env/gen_dockerfile.py @@ -11,6 +11,7 @@ def checkEnv(envName, defaultValue): def main(): print(Environment(loader=FileSystemLoader(dirname(__file__))).get_template("Dockerfile").render( DEBUG=checkEnv("DEBUG", True), + MINSIZE=checkEnv("MINSIZE", False), LTO=checkEnv("LTO", True), ASAN=checkEnv("ASAN", False), JOBS=checkEnv("JOBS", ""),