Index: libcxxabi/trunk/src/CMakeLists.txt =================================================================== --- libcxxabi/trunk/src/CMakeLists.txt +++ libcxxabi/trunk/src/CMakeLists.txt @@ -206,7 +206,12 @@ if(LIBCXXABI_HERMETIC_STATIC_LIBRARY) append_flags_if_supported(CXXABI_STATIC_LIBRARY_FLAGS -fvisibility=hidden) - append_flags_if_supported(CXXABI_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden) + # If the hermetic library doesn't define the operator new/delete functions + # then its code shouldn't declare them with hidden visibility. They might + # actually be provided by a shared library at link time. + if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) + append_flags_if_supported(CXXABI_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden) + endif() target_compile_options(cxxabi_static PRIVATE ${CXXABI_STATIC_LIBRARY_FLAGS}) target_compile_definitions(cxxabi_static PRIVATE Index: llvm/trunk/utils/gn/secondary/libcxxabi/src/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/libcxxabi/src/BUILD.gn +++ llvm/trunk/utils/gn/secondary/libcxxabi/src/BUILD.gn @@ -116,7 +116,9 @@ public = cxxabi_headers if (libcxxabi_hermetic_static_library) { cflags = [ "-fvisibility=hidden" ] - cflags_cc = [ "-fvisibility-global-new-delete-hidden" ] + if (libcxxabi_enable_new_delete_definitions) { + cflags_cc = [ "-fvisibility-global-new-delete-hidden" ] + } defines = [ "_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS", "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",