Repository navigation
chore: remove legacy STLPort and obsolete pre-C++11/VS2013 shims - #1958
Conversation
There was a problem hiding this comment.
Code Review
This pull request removes support for STLPort and legacy C++03 workarounds across the codebase, simplifying type traits, threading, and optional implementations to use modern C++ standard library features directly. Feedback on these changes highlights a potential self-move-assignment bug in Optional::operator= that could cause self-destruction, and a buffer size in Variant::AsString that is too small to safely format large double values without truncation.
Integration test with FLAKINESS (succeeded after retry)Requested by @AustinBenoit on commit 54f23e2
Add flaky tests to go/fpl-cpp-flake-tracker |
- Delete dead STLPort-only app/src/thread_pthread.cc and duplicate firebase_app_pthread_thread_test target; mark Thread move operations noexcept. - Simplify common.h, type_traits.h, optional.h, variant.cc, and callback.h by removing _STLPORT_VERSION / STLPORT / _MSC_VER <= 1800 fallbacks while keeping FIREBASE_USE_MOVE_OPERATORS and FIREBASE_USE_STD_FUNCTION defined for public header compatibility. - Use alignas(T) unsigned char buffer in Optional<T> to avoid C++23 std::aligned_storage deprecation warnings, and inherit is_char / is_integer from integral_constant with unit test coverage in type_traits_test.cc. - Remove unreachable non-std::function RunTransaction(DoTransaction) overload, dead non-move #else branches, unused AUTH_STATIC_ASSERT / vs2013 script case, and obsolete STLPort Doxygen @note blocks.
111b4d8 to
737248e
Compare
| // reporting __cplusplus to be 199711L, so explicitly check for that. | ||
| // Also, stlport doesn't implement std::move(). | ||
| #if (__cplusplus >= 201103L || _MSC_VER >= 1600) && !defined(_STLPORT_VERSION) | ||
| #define FIREBASE_USE_MOVE_OPERATORS |
There was a problem hiding this comment.
I wonder if we need these anymore, since they are always being defined now.
There was a problem hiding this comment.
Good catch — we don't need them anymore, and every remaining check (~73 files across app, auth, database, functions, and storage) is a positive #if/#ifdef. Added a TODO(b/582384770) note here in c8ed6e6 and filed b/582384770 to unwrap and remove them in a dedicated follow-up PR so this diff stays focused.
Description
Removes dead STLPort (
_STLPORT_VERSION/STLPORT) and obsolete pre-C++11 / pre-VS2015 (_MSC_VER <= 1800) compatibility shims left over after STLPort support was dropped in Firebase C++ SDK v8.0.0 (#407, #510), Androidgnustlwas dropped in v9.0.0 (#889), and the build baseline moved to C++17 (CMAKE_CXX_STANDARD 17).Summary of Changes
app/src/thread*,app/CMakeLists.txt,app/tests/CMakeLists.txt):app/src/thread_pthread.ccand the duplicatefirebase_app_pthread_thread_testtarget.firebase::Threadto wrapstd::threadunconditionally, markedThread(Thread&&)andThread::operator=(Thread&&)asnoexcept, and cleaned up stale pthread-specific comments.common.h,type_traits.h,optional.h,callback.h,variant.cc):_STLPORT_VERSIONand_MSC_VER <= 1800preprocessor branches inapp/src/include/firebase/internal/common.h, while keepingFIREBASE_USE_MOVE_OPERATORSandFIREBASE_USE_STD_FUNCTIONunconditionally defined for source/SWIG compatibility with public headers checking#if defined(...).std::tr1namespace switching inapp/src/include/firebase/internal/type_traits.hwithstd::aliases; inheritedfirebase::is_charandfirebase::is_integerfromintegral_constant, made both cv-qualifier invariant (std::remove_cv), guardedchar8_ton__cpp_char8_t, and added unit test coverage inapp/tests/type_traits_test.cc.FIREBASE_ALIGNED_STORAGE/std::aligned_storage(deprecated in C++23) inapp/src/optional.hwithalignas(T) unsigned char buffer_[sizeof(T)]andstd::launderaccessors.CallbackVariadicfallback inapp/src/callback.hand legacy_snprintf/INT64FORMATworkarounds inapp/src/variant.ccandauth/src/auth.ccin favor ofstd::snprintfand<cinttypes>(PRId64).auth/,database/,firestore/,messaging/,remote_config/,storage/,testing/,build_scripts/):#if !defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)DatabaseReference::RunTransaction(DoTransaction, bool)overload and stale STLPort Doxygen@notes indatabase_reference.h,database_reference.cc,transaction.h, andfuture.h(note: this overload was never compiled intolibfirebase_databaseon any non-STLPort build;typedef ... DoTransactionis retained so plain function pointers continue binding toRunTransaction(DoTransactionFunction, bool)and SWIG bindings are unchanged).#elsebranches, STLPort test skip macros (SKIP_TEST_IF_USING_STLPORT),CreateMapCopySTLPort workaround, unusedAUTH_STATIC_ASSERT, and unusedvs2013/stl=c++cases inbuild_scripts/desktop/get_variant.sh.Testing
Tested Locally (Linux x64 Workstation)
-DFIREBASE_CPP_BUILD_TESTS=ON -DFIREBASE_USE_LINUX_CXX11_ABI=ON) and ranctestserially — 104/104 test targets passed (including the newfirebase_app_type_traits_test,firebase_app_optional_test,firebase_app_cpp11_thread_test,firebase_app_variant_test,firebase_app_future_test,firebase_auth_desktop_test,firebase_rtdb_common_database_reference_test, andfirebase_storage_desktop_utils_test).0warnings/errors) of modified headers and sources underg++ 15.2andclang++-19across-std=c++17,-std=c++20,-std=c++20 -fno-char8_t, and-std=c++23with-Wall -Wextra -Wpedantic -Wdeprecated-declarations -Werror, plus-O2 -fsanitize=address,undefinedharnesses forOptional<T>,Thread,Variant,CallbackStdFunction, andtype_traits.h.aarch64-linux-android24-clang++(NDK r23b and NDK r28b,-fno-exceptions) with zero errors.swig -c++ -csharp(SWIG 4.4.1) across all 10firebase-unity-sdk.imodules comparingorigin/mainvs this branch — 0 byte differences in generated.csand_wrap.cxxoutputs.python3 scripts/format_code.py -git_diff --noformat_file -verbose(0files needing formatting), Doxygen 1.15.0 againstdocs/Doxyfile(0warnings in touched headers), andbash scripts/gha/check_copyright.sh -g(passed).Not Tested Locally (Covered by GitHub Actions CI)
tests-requested: fullintegration tests on this PR to validate all platforms end-to-end.Type of Change
Place an
xthe applicable box:Notes
Release Notessection ofrelease_build_files/readme.md.