tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

Build of tdcore fails with linker error on windows #2888

Closed vlabella closed 5 months ago

vlabella commented 5 months ago

I am getting the following linker error when building on windows when trying to build the x64 bit version. This is using the latest version of visual studio and openssl 3.3.0 and using link time optimizations /LTO. StackOverflow suggests this maybe caused by allocating too much memory on the stack. Any help would be appreciated

WebPagesManager.cpp mtproto_api.cpp telegram_api.cpp secret_api.cpp GitCommitHash.cpp C:\sandbox\libs\td-master\build-x64\Release\tdcore.lib : fatal error LNK1248: image size (1000E5B33) exceeds maximum allowable size (FFFFFFFF) [C:\sandbox\libs\td-master\build-x64\tdcore.vcxproj] Building Custom Rule C:/sandbox/libs/td-master/benchmark/CMakeLists.txt

levlam commented 5 months ago

What is you MSVC version?

Did you also change some other compiler flags, for example, replaced /Zi with /Z7?

vlabella commented 5 months ago

Here is the version of the compiler

Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33523 for x64 Copyright (C) Microsoft Corporation. All rights reserved.

also

VCToolsVersion=14.39.33519 VisualStudioVersion=17.0 VISUAL_STUDIO_YEAR=2022

I did not change any compiler options in the cmake file.

levlam commented 5 months ago

I did not change any compiler options in the cmake file.

But you have enabled LTO, so you may have changed some other options. Did you use TD_ENABLE_LTO to enable LTO?

levlam commented 5 months ago

I was able to reproduce the issue. It looks like the total amount of code slightly exceeded MSVC implementation limits and LTO build doesn't work anymore. The total amount of the code will continue to grow over time, so the issue can be fixed only by introducing more intermediate projects and static libraries and splitting files between them.

vlabella commented 5 months ago

Its building now for me without LTO. Thanks for the help.

levlam commented 5 months ago

Yes, for now only Release build with LTO is affected. In Debug LTO build tdcore.lib is less than 2 GB, and without LTO it is less than 250 MB.

levlam commented 5 months ago

Fixed in TDLib 1.8.30.