build: set CMAKE_VISIBILITY_INLINES_HIDDEN in REDUCE_EXPORTS

This was originally part of the CMake switchover, but was removed
because it was an addition, rather than a port. Add it now.

> This switch declares that the user does not attempt to compare pointers
> to inline functions or methods where the addresses of the two functions
> are taken in different shared objects.

> The effect of this is that GCC may, effectively, mark inline methods
> with __attribute__ ((visibility ("hidden"))) so that they do not appear
> in the export table of a DSO

See https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html.

See also
https://cmake.org/cmake/help/latest/prop_tgt/VISIBILITY_INLINES_HIDDEN.html.

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
This commit is contained in:
fanquake
2026-07-24 18:16:10 +01:00
parent 3a2c52f9d7
commit 3f313a774b

View File

@@ -601,6 +601,7 @@ endif()
if(REDUCE_EXPORTS)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
try_append_linker_flag("-Wl,--exclude-libs,ALL" TARGET core_interface)
try_append_linker_flag("-Wl,-no_exported_symbols" VAR CMAKE_EXE_LINKER_FLAGS)
endif()