[REQUIRED] Please fill in the following fields:
- Pre-built SDK from the website or open-source from this repo: _____
- Firebase C++ SDK version: 13.9.0
- Problematic Firebase Component: Firestore (Auth, Database, etc.)
- Other Firebase Components in use: (Auth, Database, etc.)
- Platform you are using the C++ SDK on: Mac (Mac, Windows, or Linux)
- Platform you are targeting: desktop (iOS, Android, and/or desktop)
[REQUIRED] Please describe the issue here:
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_DISABLE_AVAILABILITY") |
Since v13.7.0 root CMakeLists.txt adds _LIBCPP_DISABLE_AVAILABILITY to compiler flags.
This disables libc++'s compatibility mechanism based on -mmacosx-version-min, effectively pins its ABI to whatever latest version available on the build environment.
I noticed this when I was trying to build the SDK to target macOS 10.13 or later with C++ exception enabled.
Even if I properly set CMAKE_OSX_DEPLOYMENT_TARGET to CMake, I still got libc++ related link errors when I link the SDK against an app (on libfirebase_firestore.a), because libc++ seems conditionally defines some internal functions based on availability macros (I admittedly don't fully understand how it works)
I genuinely don't see why _LIBCPP_DISABLE_AVAILABILITY is needed here.
My understanding is that it should be used in controlled environment where you can ship appropriate libc++ binaries so it doesn't cause errors with system libc++ installation, which is not the case here I believe.
Overall, I think it would be better to avoid using _LIBCPP_DISABLE_AVAILABILITY so people have less mysterious linktime/runtime errors down the line. _LIBCPP_DISABLE_AVAILABILITY is removed in LLVM 20 so it's going to be removed anyway.
Steps to reproduce:
Sorry I don't have minimal repro I can post here.
- Build the SDK with
CMAKE_OSX_DEPLOYMENT_TARGET set to something like 10.13 and C++ exception enabled.
- Link built SDK agains app which have deployment target set to 10.13 or later.
- Link fails with errors like
Undefined symbol: __cxa_init_primary_exception
Relevant Code:
[REQUIRED] Please fill in the following fields:
[REQUIRED] Please describe the issue here:
firebase-cpp-sdk/CMakeLists.txt
Line 489 in 6ca6e1c
Since v13.7.0 root
CMakeLists.txtadds_LIBCPP_DISABLE_AVAILABILITYto compiler flags.This disables libc++'s compatibility mechanism based on
-mmacosx-version-min, effectively pins its ABI to whatever latest version available on the build environment.I noticed this when I was trying to build the SDK to target macOS 10.13 or later with C++ exception enabled.
Even if I properly set
CMAKE_OSX_DEPLOYMENT_TARGETto CMake, I still got libc++ related link errors when I link the SDK against an app (onlibfirebase_firestore.a), because libc++ seems conditionally defines some internal functions based on availability macros (I admittedly don't fully understand how it works)I genuinely don't see why
_LIBCPP_DISABLE_AVAILABILITYis needed here.My understanding is that it should be used in controlled environment where you can ship appropriate libc++ binaries so it doesn't cause errors with system libc++ installation, which is not the case here I believe.
Overall, I think it would be better to avoid using
_LIBCPP_DISABLE_AVAILABILITYso people have less mysterious linktime/runtime errors down the line._LIBCPP_DISABLE_AVAILABILITYis removed in LLVM 20 so it's going to be removed anyway.Steps to reproduce:
Sorry I don't have minimal repro I can post here.
CMAKE_OSX_DEPLOYMENT_TARGETset to something like10.13and C++ exception enabled.Undefined symbol: __cxa_init_primary_exceptionRelevant Code: