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

Fix building with Xcode 15 #2606

Closed vincentneo closed 1 year ago

vincentneo commented 1 year ago

Fix #2604. Have yet to have the time to fully test this; will do test things out again fully tomorrow. Currently seeing good signs as was able to clear the first few files that failed to compile previously.

Will remain draft for now until I make sure things are alright.

Believe issue is due to:

Several incidental transitive includes have been removed from libc++. Those includes are removed based on the language version used. If you see errors related to missing std:: entities in your code after upgrading, ensure you have all required includes. (source: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Deprecations)

vincentneo commented 1 year ago

Tested things out today:

The additional line to include c++ headers were not necessary for macOS/iOS/tvOS, only needed for watchOS, hence, in 2b57554, only watchOS builds will include. (That said, there is also no harm adding the include)

With this, TDLib compiles fine for watchOS, when paired with Xcode 15's toolchain.

levlam commented 1 year ago

If you see errors related to missing std:: entities in your code after upgrading, ensure you have all required includes. (source: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Deprecations)

The issue is about include search paths and not actual includes in the code, so the mentioned change isn't related. The actual cause of the issue needs to be investigated. It is possible that build for watchOS has ever been broken. Appropriate diagnostics were added to libc++ only a year ago in https://reviews.llvm.org/D131441, and hence could have appeared only in Xcode 15.

We use in tdutils

target_include_directories(tdutils SYSTEM PRIVATE ${ZLIB_INCLUDE_DIR})

to be able to include zlib headers, so /usr/include/ is definitely added to search path for tdutils and this breaks include path order expected by libc++. But search path for C++ headers is supposed to be added and searched first by the C++ compiler itself. It can find the C++ headers, so it should be able to correctly find included by them headers. Therefore, this looks like a toolchain bug and running clang++ -v for iOS and watchOS toolchains should show the difference in built-in include paths and the cause of the issue.

Nevertheless, the proposed patch should mask the issue for the current Xcode toolchain, and will be accepted.