Skip to content

Commit 9bdbdd1

Browse files
mstorsjollvmbot
authored andcommitted
[runtimes] Prefer -fvisibility-global-new-delete=force-hidden (llvm#84917)
27ce26b added the new option -fvisibility-global-new-delete=, where -fvisibility-global-new-delete=force-hidden is equivalent to the old option -fvisibility-global-new-delete-hidden. At the same time, the old option was deprecated. Test for and use the new option form first; if unsupported, try using the old form. This avoids warnings in the MinGW builds, if built with Clang 18 or newer. (cherry picked from commit 1f973ef)
1 parent c7eb919 commit 9bdbdd1

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

libcxx/src/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ if (LIBCXX_ENABLE_STATIC)
306306
# then its code shouldn't declare them with hidden visibility. They might
307307
# actually be provided by a shared library at link time.
308308
if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
309-
append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden)
309+
append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete=force-hidden)
310+
if (NOT CXX_SUPPORTS_FVISIBILITY_GLOBAL_NEW_DELETE_EQ_FORCE_HIDDEN_FLAG)
311+
append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden)
312+
endif()
310313
endif()
311314
target_compile_options(cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS})
312315
# _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site

libcxxabi/src/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ if(LIBCXXABI_HERMETIC_STATIC_LIBRARY)
265265
# then its code shouldn't declare them with hidden visibility. They might
266266
# actually be provided by a shared library at link time.
267267
if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
268-
target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fvisibility-global-new-delete-hidden)
268+
target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fvisibility-global-new-delete=force-hidden)
269+
if (NOT CXX_SUPPORTS_FVISIBILITY_GLOBAL_NEW_DELETE_EQ_FORCE_HIDDEN_FLAG)
270+
target_add_compile_flags_if_supported(cxxabi_static_objects PRIVATE -fvisibility-global-new-delete-hidden)
271+
endif()
269272
endif()
270273
# _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in libcxx's
271274
# __config_site too. Define it in the same way here, to avoid redefinition

libunwind/src/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ set_target_properties(unwind_static_objects
201201

202202
if(LIBUNWIND_HIDE_SYMBOLS)
203203
target_add_compile_flags_if_supported(unwind_static_objects PRIVATE -fvisibility=hidden)
204-
target_add_compile_flags_if_supported(unwind_static_objects PRIVATE -fvisibility-global-new-delete-hidden)
204+
target_add_compile_flags_if_supported(unwind_static_objects PRIVATE -fvisibility-global-new-delete=force-hidden)
205+
if (NOT CXX_SUPPORTS_FVISIBILITY_GLOBAL_NEW_DELETE_EQ_FORCE_HIDDEN_FLAG)
206+
target_add_compile_flags_if_supported(unwind_static_objects PRIVATE -fvisibility-global-new-delete-hidden)
207+
endif()
205208
target_compile_definitions(unwind_static_objects PRIVATE _LIBUNWIND_HIDE_SYMBOLS)
206209
endif()
207210

0 commit comments

Comments
 (0)