Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llvm] Add explicit visibility macros to YAMLTraits classes #111484

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fsfod
Copy link
Contributor

@fsfod fsfod commented Oct 8, 2024

These symbols need to be exported for llvm-pdbutil when using windows shared library builds.
Exclude the YAML traits declared in llvm-pdbutil so there not declared as dllimported which will causing missing symbol errors for windows shared library builds.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window.

These symbols need to be exported for llvm-pdbutil when using windows shared
library builds.
Exclude the YAML traits declared in llvm-pdbutil so there not declared as
dllimported which will causing missing symbol errors for windows shared
library builds.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window.
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 8, 2024

@llvm/pr-subscribers-llvm-support

@llvm/pr-subscribers-debuginfo

Author: Thomas Fransham (fsfod)

Changes

These symbols need to be exported for llvm-pdbutil when using windows shared library builds.
Exclude the YAML traits declared in llvm-pdbutil so there not declared as dllimported which will causing missing symbol errors for windows shared library builds.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window.


Full diff: https://github.com/llvm/llvm-project/pull/111484.diff

2 Files Affected:

  • (modified) llvm/include/llvm/Support/YAMLTraits.h (+12-3)
  • (modified) llvm/tools/llvm-pdbutil/PdbYaml.h (+11-11)
diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h
index 1d04783753d5cd..bacaec6eccc1e1 100644
--- a/llvm/include/llvm/Support/YAMLTraits.h
+++ b/llvm/include/llvm/Support/YAMLTraits.h
@@ -2079,6 +2079,15 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
   LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(type, true)
 
 #define LLVM_YAML_DECLARE_MAPPING_TRAITS(Type)                                 \
+  namespace llvm {                                                             \
+  namespace yaml {                                                             \
+  template <> struct LLVM_ABI MappingTraits<Type> {                            \
+    static void mapping(IO &IO, Type &Obj);                                    \
+  };                                                                           \
+  }                                                                            \
+  }
+
+#define LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(Type)                        \
   namespace llvm {                                                             \
   namespace yaml {                                                             \
   template <> struct MappingTraits<Type> {                                     \
@@ -2090,7 +2099,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
 #define LLVM_YAML_DECLARE_ENUM_TRAITS(Type)                                    \
   namespace llvm {                                                             \
   namespace yaml {                                                             \
-  template <> struct ScalarEnumerationTraits<Type> {                           \
+  template <> struct LLVM_ABI ScalarEnumerationTraits<Type> {                  \
     static void enumeration(IO &io, Type &Value);                              \
   };                                                                           \
   }                                                                            \
@@ -2099,7 +2108,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
 #define LLVM_YAML_DECLARE_BITSET_TRAITS(Type)                                  \
   namespace llvm {                                                             \
   namespace yaml {                                                             \
-  template <> struct ScalarBitSetTraits<Type> {                                \
+  template <> struct LLVM_ABI ScalarBitSetTraits<Type> {                       \
     static void bitset(IO &IO, Type &Options);                                 \
   };                                                                           \
   }                                                                            \
@@ -2108,7 +2117,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
 #define LLVM_YAML_DECLARE_SCALAR_TRAITS(Type, MustQuote)                       \
   namespace llvm {                                                             \
   namespace yaml {                                                             \
-  template <> struct ScalarTraits<Type> {                                      \
+  template <> struct LLVM_ABI ScalarTraits<Type> {                             \
     static void output(const Type &Value, void *ctx, raw_ostream &Out);        \
     static StringRef input(StringRef Scalar, void *ctxt, Type &Value);         \
     static QuotingType mustQuote(StringRef) { return MustQuote; }              \
diff --git a/llvm/tools/llvm-pdbutil/PdbYaml.h b/llvm/tools/llvm-pdbutil/PdbYaml.h
index 4382e91e209737..d3ec260689b699 100644
--- a/llvm/tools/llvm-pdbutil/PdbYaml.h
+++ b/llvm/tools/llvm-pdbutil/PdbYaml.h
@@ -111,16 +111,16 @@ struct PdbObject {
 }
 }
 
-LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbObject)
-LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::MSFHeaders)
-LLVM_YAML_DECLARE_MAPPING_TRAITS(msf::SuperBlock)
-LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::StreamBlockList)
-LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbInfoStream)
-LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiStream)
-LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbTpiStream)
-LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbPublicsStream)
-LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::NamedStreamMapping)
-LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbModiStream)
-LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiModuleInfo)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(pdb::yaml::PdbObject)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(pdb::yaml::MSFHeaders)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(msf::SuperBlock)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(pdb::yaml::StreamBlockList)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(pdb::yaml::PdbInfoStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(pdb::yaml::PdbDbiStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(pdb::yaml::PdbTpiStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(pdb::yaml::PdbPublicsStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(pdb::yaml::NamedStreamMapping)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(pdb::yaml::PdbModiStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(pdb::yaml::PdbDbiModuleInfo)
 
 #endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants