Skip to content

[libcxx, libcxxabi, libunwind] Prefer -fvisibility-global-new-delete=force-hidden #84917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion libcxx/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ if (LIBCXX_ENABLE_STATIC)
# then its code shouldn't declare them with hidden visibility. They might
# actually be provided by a shared library at link time.
if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden)
append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete=force-hidden)
if (NOT CXX_SUPPORTS_FVISIBILITY_GLOBAL_NEW_DELETE_EQ_FORCE_HIDDEN_FLAG)
append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden)
endif()
endif()
target_compile_options(cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS})
# _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site
Expand Down
5 changes: 4 additions & 1 deletion libcxxabi/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ if(LIBCXXABI_HERMETIC_STATIC_LIBRARY)
# 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)
target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fvisibility-global-new-delete-hidden)
target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fvisibility-global-new-delete=force-hidden)
if (NOT CXX_SUPPORTS_FVISIBILITY_GLOBAL_NEW_DELETE_EQ_FORCE_HIDDEN_FLAG)
target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fvisibility-global-new-delete-hidden)
endif()
endif()
# _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in libcxx's
# __config_site too. Define it in the same way here, to avoid redefinition
Expand Down
5 changes: 4 additions & 1 deletion libunwind/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ set_target_properties(unwind_static_objects

if(LIBUNWIND_HIDE_SYMBOLS)
target_add_compile_flags_if_supported(unwind_static_objects PRIVATE -fvisibility=hidden)
target_add_compile_flags_if_supported(unwind_static_objects PRIVATE -fvisibility-global-new-delete-hidden)
target_add_compile_flags_if_supported(unwind_static_objects PRIVATE -fvisibility-global-new-delete=force-hidden)
if (NOT CXX_SUPPORTS_FVISIBILITY_GLOBAL_NEW_DELETE_EQ_FORCE_HIDDEN_FLAG)
target_add_compile_flags_if_supported(unwind_static_objects PRIVATE -fvisibility-global-new-delete-hidden)
endif()
target_compile_definitions(unwind_static_objects PRIVATE _LIBUNWIND_HIDE_SYMBOLS)
endif()

Expand Down