From acbe860fc5719cd62eca0263d7d05cda621643cf Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 26 Apr 2023 02:44:12 +0000 Subject: [PATCH] Bug 1274334 - Enable STL wrappers on macos. r=firefox-build-system-reviewers,ahochheiden Practically speaking, this doesn't make a huge difference, because libmozglue contains operator new/operator delete overrides. This will enable inlining opportunities, though. It is worth noting that there's equivalent code in js/src/old-configure.in but it's left as is because it is actually no-op at the moment. This will be fixed in bug 1829049. The check for __EXCEPTIONS is replaced with __cpp_exceptions because the former is defined for any type of exception, including ObjC exceptions, while the latter is defined for C++ exceptions only. Differential Revision: https://phabricator.services.mozilla.com/D175976 --- config/gcc-stl-wrapper.template.h | 4 +--- old-configure.in | 10 ++-------- xpcom/tests/gtest/TestSTLWrappers.cpp | 10 ++++++++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/config/gcc-stl-wrapper.template.h b/config/gcc-stl-wrapper.template.h index 943df64ba985..c714977d5dcc 100644 --- a/config/gcc-stl-wrapper.template.h +++ b/config/gcc-stl-wrapper.template.h @@ -8,9 +8,7 @@ #ifndef mozilla_${HEADER}_h #define mozilla_${HEADER}_h -// For some reason, Apple's GCC refuses to honor -fno-exceptions when -// compiling ObjC. -#if defined(__EXCEPTIONS) && __EXCEPTIONS && !(__OBJC__ && __GNUC__ && XP_IOS) +#if defined(__cpp_exceptions) && __cpp_exceptions # error "STL code can only be used with -fno-exceptions" #endif diff --git a/old-configure.in b/old-configure.in index 56ec5441a135..61812158cfee 100644 --- a/old-configure.in +++ b/old-configure.in @@ -597,14 +597,8 @@ MOZ_CXX11 AC_LANG_C -case "${OS_TARGET}" in -Darwin) - ;; -*) - STL_FLAGS="-I${DIST}/stl_wrappers" - WRAP_STL_INCLUDES=1 - ;; -esac +STL_FLAGS="-I${DIST}/stl_wrappers" +WRAP_STL_INCLUDES=1 if test "$MOZ_BUILD_APP" = "tools/crashreporter/injector"; then WRAP_STL_INCLUDES= diff --git a/xpcom/tests/gtest/TestSTLWrappers.cpp b/xpcom/tests/gtest/TestSTLWrappers.cpp index c2762247a9db..31b658f76434 100644 --- a/xpcom/tests/gtest/TestSTLWrappers.cpp +++ b/xpcom/tests/gtest/TestSTLWrappers.cpp @@ -47,13 +47,19 @@ void ShouldAbort() { fputs("TEST-FAIL | TestSTLWrappers.cpp | didn't abort()?\n", stderr); } -#ifdef XP_WIN +#if defined(XP_WIN) || (defined(XP_MACOSX) && !defined(MOZ_DEBUG)) TEST(STLWrapper, DISABLED_ShouldAbortDeathTest) #else TEST(STLWrapper, ShouldAbortDeathTest) #endif { ASSERT_DEATH_IF_SUPPORTED(ShouldAbort(), +#ifdef __GLIBCXX__ + // Only libstdc++ will print this message. "terminate called after throwing an instance of " - "'std::out_of_range'|vector::_M_range_check"); + "'std::out_of_range'|vector::_M_range_check" +#else + "" +#endif + ); }