Merge bitcoin/bitcoin#35795: build: set CMAKE_VISIBILITY_INLINES_HIDDEN in REDUCE_EXPORTS

3f313a774b build: set CMAKE_VISIBILITY_INLINES_HIDDEN in REDUCE_EXPORTS (fanquake)

Pull request description:

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

  See https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-fvisibility-inlines-hidden:

  > 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 also https://cmake.org/cmake/help/latest/prop_tgt/VISIBILITY_INLINES_HIDDEN.html.

  When building for macOS, this will also enable [`-fvisibility-inlines-hidden-static-local-var`](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fvisibility-inlines-hidden-static-local-var).

ACKs for top commit:
  purpleKarrot:
    ACK 3f313a774b
  151henry151:
    Tested ACK 3f313a774b
  hebasto:
    ACK 3f313a774b.

Tree-SHA512: 98c8f342fa9ac922826bbd3c31766f8f7eff46356db7ccd8199fb2cfc2a9719f0ca18d426f69468f1013c9ea1de90162b5941721e0ecb93e2d770611b029c785
This commit is contained in:
Hennadii Stepanov
2026-07-29 11:14:54 +01:00

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()