From db761a79ada63bf556b766f20d89fea7552d09f0 Mon Sep 17 00:00:00 2001 From: Thomas Fransham Date: Tue, 8 Oct 2024 05:55:16 +0100 Subject: [PATCH 1/2] [llvm] Add explicit visibility macros to YAMLTraits classes 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. --- llvm/include/llvm/Support/YAMLTraits.h | 15 ++++++++++++--- llvm/tools/llvm-pdbutil/PdbYaml.h | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 14 deletions(-) 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 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 { \ + static void mapping(IO &IO, Type &Obj); \ + }; \ + } \ + } + +#define LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(Type) \ namespace llvm { \ namespace yaml { \ template <> struct MappingTraits { \ @@ -2090,7 +2099,7 @@ template struct StdMapStringCustomMappingTraitsImpl { #define LLVM_YAML_DECLARE_ENUM_TRAITS(Type) \ namespace llvm { \ namespace yaml { \ - template <> struct ScalarEnumerationTraits { \ + template <> struct LLVM_ABI ScalarEnumerationTraits { \ static void enumeration(IO &io, Type &Value); \ }; \ } \ @@ -2099,7 +2108,7 @@ template struct StdMapStringCustomMappingTraitsImpl { #define LLVM_YAML_DECLARE_BITSET_TRAITS(Type) \ namespace llvm { \ namespace yaml { \ - template <> struct ScalarBitSetTraits { \ + template <> struct LLVM_ABI ScalarBitSetTraits { \ static void bitset(IO &IO, Type &Options); \ }; \ } \ @@ -2108,7 +2117,7 @@ template struct StdMapStringCustomMappingTraitsImpl { #define LLVM_YAML_DECLARE_SCALAR_TRAITS(Type, MustQuote) \ namespace llvm { \ namespace yaml { \ - template <> struct ScalarTraits { \ + template <> struct LLVM_ABI ScalarTraits { \ 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 From face8d3c70bc46c96e2c983b32ec00b20c96261f Mon Sep 17 00:00:00 2001 From: Thomas Fransham Date: Thu, 7 Nov 2024 18:50:29 +0000 Subject: [PATCH 2/2] Rename non exporting traits macro --- llvm/include/llvm/Support/YAMLTraits.h | 2 +- llvm/tools/llvm-pdbutil/PdbYaml.h | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h index bacaec6eccc1e1..403584e52fed3b 100644 --- a/llvm/include/llvm/Support/YAMLTraits.h +++ b/llvm/include/llvm/Support/YAMLTraits.h @@ -2087,7 +2087,7 @@ template struct StdMapStringCustomMappingTraitsImpl { } \ } -#define LLVM_YAML_DECLARE_MAPPING_TRAITS_NOEXPORT(Type) \ +#define LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(Type) \ namespace llvm { \ namespace yaml { \ template <> struct MappingTraits { \ diff --git a/llvm/tools/llvm-pdbutil/PdbYaml.h b/llvm/tools/llvm-pdbutil/PdbYaml.h index d3ec260689b699..21658e9d0e75e4 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_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) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbObject) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::MSFHeaders) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(msf::SuperBlock) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::StreamBlockList) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbInfoStream) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbDbiStream) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbTpiStream) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbPublicsStream) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::NamedStreamMapping) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbModiStream) +LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbDbiModuleInfo) #endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H