[PATCH] D131661: [llvm] Use hidden visibility when building for MinGW with Clang
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 14:58:21 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c2fb0c73750: [llvm] Use hidden visibility when building for MinGW with Clang (authored by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131661/new/
https://reviews.llvm.org/D131661
Files:
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/include/llvm/Support/Compiler.h
llvm/lib/Target/CMakeLists.txt
Index: llvm/lib/Target/CMakeLists.txt
===================================================================
--- llvm/lib/Target/CMakeLists.txt
+++ llvm/lib/Target/CMakeLists.txt
@@ -22,7 +22,7 @@
# When building shared objects for each target there are some internal APIs
# that are used across shared objects which we can't hide.
if (NOT BUILD_SHARED_LIBS AND NOT APPLE AND
- NOT MINGW AND
+ (NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND
NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
# Set default visibility to hidden, so we don't export all the Target classes
Index: llvm/include/llvm/Support/Compiler.h
===================================================================
--- llvm/include/llvm/Support/Compiler.h
+++ llvm/include/llvm/Support/Compiler.h
@@ -113,8 +113,9 @@
/// LLVM_EXTERNAL_VISIBILITY - classes, functions, and variables marked with
/// this attribute will be made public and visible outside of any shared library
/// they are linked in to.
-#if __has_attribute(visibility) && !defined(__MINGW32__) && \
- !defined(__CYGWIN__) && !defined(_WIN32)
+#if __has_attribute(visibility) && \
+ (!(defined(_WIN32) || defined(__CYGWIN__)) || \
+ (defined(__MINGW32__) && defined(__clang__)))
#define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden")))
#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS)
#define LLVM_EXTERNAL_VISIBILITY __attribute__((visibility("default")))
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -351,8 +351,11 @@
endif()
endif()
-if(NOT WIN32 AND NOT CYGWIN AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
- # MinGW warns if -fvisibility-inlines-hidden is used.
+if((NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX")) AND
+ (NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
+ # GCC for MinGW does nothing about -fvisibility-inlines-hidden, but warns
+ # about use of the attributes. As long as we don't use the attributes (to
+ # override the default) we shouldn't set the command line options either.
# GCC on AIX warns if -fvisibility-inlines-hidden is used and Clang on AIX doesn't currently support visibility.
check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131661.451995.patch
Type: text/x-patch
Size: 2687 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220811/c0f9cfd6/attachment.bin>
More information about the llvm-commits
mailing list