[libcxxabi] [llvm] [llvm] annotate interfaces in Demangle for DLL export (PR #147564)
Andrew Rogers via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 9 09:11:17 PDT 2025
================
@@ -0,0 +1,43 @@
+/*===-- Demangle/Visibility.h - Visibility macros for Demangle --*- C++ -*-===*\
+|* *|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
+|* Exceptions. *|
+|* See https://llvm.org/LICENSE.txt for license information. *|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This header defines visibility macros used for the Demangle library. These *|
+|* macros are used to annotate functions that should be exported as part of a *|
+|* shared library or DLL. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
+#ifndef LLVM_DEMANGLE_VISIBILITY_H
+#define LLVM_DEMANGLE_VISIBILITY_H
+
+#include "llvm/Config/llvm-config.h"
+#include "llvm/Demangle/DemangleConfig.h"
+
+/// DEMANGLE_ABI is the export/visibility macro used to mark symbols delcared in
+/// llvm/Demangle as exported when built as a shared library.
+
+#if !defined(LLVM_ABI_GENERATING_ANNOTATIONS)
+#if defined(LLVM_ENABLE_DEMANGLE_EXPORT_ANNOTATIONS) && \
+ !defined(LLVM_BUILD_STATIC)
+#if defined(_WIN32) && !defined(__MINGW32__)
+#if defined(LLVM_EXPORTS)
+#define DEMANGLE_ABI __declspec(dllexport)
+#else
+#define DEMANGLE_ABI __declspec(dllimport)
+#endif
+#elif __has_attribute(visibility)
+#define DEMANGLE_ABI __attribute__((visibility("default")))
+#endif
+#endif
+#if !defined(DEMANGLE_ABI)
+#define DEMANGLE_ABI
+#endif
+#endif
----------------
andrurogerz wrote:
@compnerd that is what I assumed too, but @nikic's comment here and the copy of `ItaniumDemangle.h` under `libcxxabi` made me think that the real reason we can't have `Demangle` depend on `Support` was because of the `libcxxabi` duplication. Do either of you know who could confirm? I have both changes prepared and tested locally. I would just have to drop the top commit from this PR to go back to the independent `DEMANGLE_ABI` version. Thank you!
https://github.com/llvm/llvm-project/pull/147564
More information about the llvm-commits
mailing list