Skip to content

[Bug] Please reconsider use of _LIBCPP_DISABLE_AVAILABILITY #1887

Description

@mocabe

[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.

  1. Build the SDK with CMAKE_OSX_DEPLOYMENT_TARGET set to something like 10.13 and C++ exception enabled.
  2. Link built SDK agains app which have deployment target set to 10.13 or later.
  3. Link fails with errors like Undefined symbol: __cxa_init_primary_exception

Relevant Code:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions