[PATCH] D115825: Re-apply "Only define LLVM_EXTERNAL_VISIBILITY when building libLLVM dylib"
Ben Langmuir via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 15 12:52:01 PST 2021
benlangmuir created this revision.
benlangmuir added a reviewer: mehdi_amini.
Herald added subscribers: sdasgup3, wenzhicui, wrengr, Chia-hungDuan, dcaballe, cota, teijeong, dexonsmith, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mgorny.
benlangmuir requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: MLIR, LLVM.
With a fix for the MLIR test failure with BUILD_SHARED_LIBS.
Original commit message:
When building LLVM static libraries, we should not make symbols more
visible than CMAKE_CXX_VISIBILITY_PRESET, since the goal may be to have
a purely hidden llvm embedded in another library. Instead, we only
define LLVM_EXTERNAL_VISIBILITY for the dynamic library build (when
LLVM_BUILD_LLVM_DYLIB=YES).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D115825
Files:
llvm/include/llvm/Config/llvm-config.h.cmake
llvm/include/llvm/Support/Compiler.h
mlir/include/mlir/Support/TypeID.h
Index: mlir/include/mlir/Support/TypeID.h
===================================================================
--- mlir/include/mlir/Support/TypeID.h
+++ mlir/include/mlir/Support/TypeID.h
@@ -14,6 +14,7 @@
#ifndef MLIR_SUPPORT_TYPEID_H
#define MLIR_SUPPORT_TYPEID_H
+#include "mlir-c/Support.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/Hashing.h"
@@ -114,7 +115,7 @@
/// TODO: This currently won't work when using DLLs as it requires properly
/// attaching dllimport and dllexport. Fix this when that information is
/// available within LLVM.
-struct LLVM_EXTERNAL_VISIBILITY TypeIDExported {
+struct MLIR_CAPI_EXPORTED TypeIDExported {
template <typename T>
static TypeID get() {
static TypeID::Storage instance;
@@ -151,7 +152,7 @@
namespace mlir { \
namespace detail { \
template <> \
- LLVM_EXTERNAL_VISIBILITY TypeID TypeIDExported::get<CLASS_NAME>(); \
+ MLIR_CAPI_EXPORTED TypeID TypeIDExported::get<CLASS_NAME>(); \
} \
}
@@ -159,7 +160,7 @@
namespace mlir { \
namespace detail { \
template <> \
- LLVM_EXTERNAL_VISIBILITY TypeID TypeIDExported::get<CLASS_NAME>() { \
+ MLIR_CAPI_EXPORTED TypeID TypeIDExported::get<CLASS_NAME>() { \
static TypeID::Storage instance; \
return TypeID(&instance); \
} \
Index: llvm/include/llvm/Support/Compiler.h
===================================================================
--- llvm/include/llvm/Support/Compiler.h
+++ llvm/include/llvm/Support/Compiler.h
@@ -121,12 +121,16 @@
/// On PE/COFF targets, library visibility is the default, so this isn't needed.
///
/// 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.
+/// this attribute will be made public and visible outside the libLLVM dynamic
+/// library.
#if __has_attribute(visibility) && !defined(__MINGW32__) && \
!defined(__CYGWIN__) && !defined(_WIN32)
#define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden")))
-#define LLVM_EXTERNAL_VISIBILITY __attribute__ ((visibility("default")))
+#if defined(LLVM_BUILD_LLVM_DYLIB)
+#define LLVM_EXTERNAL_VISIBILITY __attribute__((visibility("default")))
+#else
+#define LLVM_EXTERNAL_VISIBILITY
+#endif
#else
#define LLVM_LIBRARY_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Index: llvm/include/llvm/Config/llvm-config.h.cmake
===================================================================
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -103,4 +103,7 @@
/* Define if the xar_open() function is supported on this platform. */
#cmakedefine LLVM_HAVE_LIBXAR ${LLVM_HAVE_LIBXAR}
+/* Define if building libLLVM shared library */
+#cmakedefine LLVM_BUILD_LLVM_DYLIB
+
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115825.394643.patch
Type: text/x-patch
Size: 3523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211215/2193a52b/attachment.bin>
More information about the llvm-commits
mailing list