[PATCH] D100896: [CMake][clang] add_clang_library's functions require default visibility

Jim Radford via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 20 15:26:52 PDT 2021


radford created this revision.
radford added a reviewer: arphaman.
Herald added a subscriber: mgorny.
radford requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Compiling LLVM, as a cmake sub-project that compiles with visibility
hidden, will generate a "cannot export hidden symbol" error because we
require default visibility.  Even though we export using
-Wl,-exported_symbols_list,libclang.exports, if each .cpp file is
compiled with -fvisibility=hidden, then you'll get this warning and
linking will fail. Essentially -exported_symbols_list is not strong
enough to reverse the -fvisibility=hidden.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100896

Files:
  clang/cmake/modules/AddClang.cmake


Index: clang/cmake/modules/AddClang.cmake
===================================================================
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -142,6 +142,7 @@
     endif()
   endforeach()
 
+  set_target_properties(${name} PROPERTIES CXX_VISIBILITY_PRESET default)
   set_target_properties(${name} PROPERTIES FOLDER "Clang libraries")
   set_clang_windows_version_resource_properties(${name})
 endmacro(add_clang_library)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100896.339014.patch
Type: text/x-patch
Size: 471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210420/8b2c5c7c/attachment.bin>


More information about the cfe-commits mailing list