Skip to content

Commit 723f64b

Browse files
authored
Public LTO visibility for ABI type declarations (#1482)
1 parent 80fa82f commit 723f64b

File tree

5 files changed

+38
-23
lines changed

5 files changed

+38
-23
lines changed

cppwinrt/code_writers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ namespace cppwinrt
763763
{
764764
auto format = R"( template <> struct abi<%>
765765
{
766-
struct WINRT_IMPL_NOVTABLE type : inspectable_abi
766+
struct WINRT_IMPL_ABI_DECL type : inspectable_abi
767767
{
768768
)";
769769

@@ -773,7 +773,7 @@ namespace cppwinrt
773773
{
774774
auto format = R"( template <%> struct abi<%>
775775
{
776-
struct WINRT_IMPL_NOVTABLE type : inspectable_abi
776+
struct WINRT_IMPL_ABI_DECL type : inspectable_abi
777777
{
778778
)";
779779

@@ -814,7 +814,7 @@ namespace cppwinrt
814814
{
815815
auto format = R"( template <%> struct abi<%>
816816
{
817-
struct WINRT_IMPL_NOVTABLE type : unknown_abi
817+
struct WINRT_IMPL_ABI_DECL type : unknown_abi
818818
{
819819
virtual int32_t __stdcall Invoke(%) noexcept = 0;
820820
};

strings/base_abi.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace winrt::impl
33
{
44
template <> struct abi<Windows::Foundation::IUnknown>
55
{
6-
struct WINRT_IMPL_NOVTABLE type
6+
struct WINRT_IMPL_ABI_DECL type
77
{
88
virtual int32_t __stdcall QueryInterface(guid const& id, void** object) noexcept = 0;
99
virtual uint32_t __stdcall AddRef() noexcept = 0;
@@ -15,7 +15,7 @@ namespace winrt::impl
1515

1616
template <> struct abi<Windows::Foundation::IInspectable>
1717
{
18-
struct WINRT_IMPL_NOVTABLE type : unknown_abi
18+
struct WINRT_IMPL_ABI_DECL type : unknown_abi
1919
{
2020
virtual int32_t __stdcall GetIids(uint32_t* count, guid** ids) noexcept = 0;
2121
virtual int32_t __stdcall GetRuntimeClassName(void** name) noexcept = 0;
@@ -27,20 +27,20 @@ namespace winrt::impl
2727

2828
template <> struct abi<Windows::Foundation::IActivationFactory>
2929
{
30-
struct WINRT_IMPL_NOVTABLE type : inspectable_abi
30+
struct WINRT_IMPL_ABI_DECL type : inspectable_abi
3131
{
3232
virtual int32_t __stdcall ActivateInstance(void** instance) noexcept = 0;
3333
};
3434
};
3535

36-
struct WINRT_IMPL_NOVTABLE IAgileObject : unknown_abi {};
36+
struct WINRT_IMPL_ABI_DECL IAgileObject : unknown_abi {};
3737

38-
struct WINRT_IMPL_NOVTABLE IAgileReference : unknown_abi
38+
struct WINRT_IMPL_ABI_DECL IAgileReference : unknown_abi
3939
{
4040
virtual int32_t __stdcall Resolve(guid const& id, void** object) noexcept = 0;
4141
};
4242

43-
struct WINRT_IMPL_NOVTABLE IMarshal : unknown_abi
43+
struct WINRT_IMPL_ABI_DECL IMarshal : unknown_abi
4444
{
4545
virtual int32_t __stdcall GetUnmarshalClass(guid const& riid, void* pv, uint32_t dwDestContext, void* pvDestContext, uint32_t mshlflags, guid* pCid) noexcept = 0;
4646
virtual int32_t __stdcall GetMarshalSizeMax(guid const& riid, void* pv, uint32_t dwDestContext, void* pvDestContext, uint32_t mshlflags, uint32_t* pSize) noexcept = 0;
@@ -50,20 +50,20 @@ namespace winrt::impl
5050
virtual int32_t __stdcall DisconnectObject(uint32_t dwReserved) noexcept = 0;
5151
};
5252

53-
struct WINRT_IMPL_NOVTABLE IGlobalInterfaceTable : unknown_abi
53+
struct WINRT_IMPL_ABI_DECL IGlobalInterfaceTable : unknown_abi
5454
{
5555
virtual int32_t __stdcall RegisterInterfaceInGlobal(void* object, guid const& iid, uint32_t* cookie) noexcept = 0;
5656
virtual int32_t __stdcall RevokeInterfaceFromGlobal(uint32_t cookie) noexcept = 0;
5757
virtual int32_t __stdcall GetInterfaceFromGlobal(uint32_t cookie, guid const& iid, void** object) noexcept = 0;
5858
};
5959

60-
struct WINRT_IMPL_NOVTABLE IStaticLifetime : inspectable_abi
60+
struct WINRT_IMPL_ABI_DECL IStaticLifetime : inspectable_abi
6161
{
6262
virtual int32_t __stdcall unused() noexcept = 0;
6363
virtual int32_t __stdcall GetCollection(void** value) noexcept = 0;
6464
};
6565

66-
struct WINRT_IMPL_NOVTABLE IStaticLifetimeCollection : inspectable_abi
66+
struct WINRT_IMPL_ABI_DECL IStaticLifetimeCollection : inspectable_abi
6767
{
6868
virtual int32_t __stdcall Lookup(void*, void**) noexcept = 0;
6969
virtual int32_t __stdcall unused() noexcept = 0;
@@ -74,23 +74,23 @@ namespace winrt::impl
7474
virtual int32_t __stdcall unused4() noexcept = 0;
7575
};
7676

77-
struct WINRT_IMPL_NOVTABLE IWeakReference : unknown_abi
77+
struct WINRT_IMPL_ABI_DECL IWeakReference : unknown_abi
7878
{
7979
virtual int32_t __stdcall Resolve(guid const& iid, void** objectReference) noexcept = 0;
8080
};
8181

82-
struct WINRT_IMPL_NOVTABLE IWeakReferenceSource : unknown_abi
82+
struct WINRT_IMPL_ABI_DECL IWeakReferenceSource : unknown_abi
8383
{
8484
virtual int32_t __stdcall GetWeakReference(IWeakReference** weakReference) noexcept = 0;
8585
};
8686

87-
struct WINRT_IMPL_NOVTABLE IRestrictedErrorInfo : unknown_abi
87+
struct WINRT_IMPL_ABI_DECL IRestrictedErrorInfo : unknown_abi
8888
{
8989
virtual int32_t __stdcall GetErrorDetails(bstr* description, int32_t* error, bstr* restrictedDescription, bstr* capabilitySid) noexcept = 0;
9090
virtual int32_t __stdcall GetReference(bstr* reference) noexcept = 0;
9191
};
9292

93-
struct WINRT_IMPL_NOVTABLE IErrorInfo : unknown_abi
93+
struct WINRT_IMPL_ABI_DECL IErrorInfo : unknown_abi
9494
{
9595
virtual int32_t __stdcall GetGUID(guid* value) noexcept = 0;
9696
virtual int32_t __stdcall GetSource(bstr* value) noexcept = 0;
@@ -99,7 +99,7 @@ namespace winrt::impl
9999
virtual int32_t __stdcall GetHelpContext(uint32_t* value) noexcept = 0;
100100
};
101101

102-
struct WINRT_IMPL_NOVTABLE ILanguageExceptionErrorInfo2 : unknown_abi
102+
struct WINRT_IMPL_ABI_DECL ILanguageExceptionErrorInfo2 : unknown_abi
103103
{
104104
virtual int32_t __stdcall GetLanguageException(void** exception) noexcept = 0;
105105
virtual int32_t __stdcall GetPreviousLanguageExceptionErrorInfo(ILanguageExceptionErrorInfo2** previous) noexcept = 0;
@@ -109,25 +109,25 @@ namespace winrt::impl
109109

110110
struct ICallbackWithNoReentrancyToApplicationSTA;
111111

112-
struct WINRT_IMPL_NOVTABLE IContextCallback : unknown_abi
112+
struct WINRT_IMPL_ABI_DECL IContextCallback : unknown_abi
113113
{
114114
virtual int32_t __stdcall ContextCallback(int32_t(__stdcall* callback)(com_callback_args*), com_callback_args* args, guid const& iid, int method, void* reserved) noexcept = 0;
115115
};
116116

117-
struct WINRT_IMPL_NOVTABLE IServerSecurity : unknown_abi
117+
struct WINRT_IMPL_ABI_DECL IServerSecurity : unknown_abi
118118
{
119119
virtual int32_t __stdcall QueryBlanket(uint32_t*, uint32_t*, wchar_t**, uint32_t*, uint32_t*, void**, uint32_t*) noexcept = 0;
120120
virtual int32_t __stdcall ImpersonateClient() noexcept = 0;
121121
virtual int32_t __stdcall RevertToSelf() noexcept = 0;
122122
virtual int32_t __stdcall IsImpersonating() noexcept = 0;
123123
};
124124

125-
struct WINRT_IMPL_NOVTABLE IBufferByteAccess : unknown_abi
125+
struct WINRT_IMPL_ABI_DECL IBufferByteAccess : unknown_abi
126126
{
127127
virtual int32_t __stdcall Buffer(uint8_t** value) noexcept = 0;
128128
};
129129

130-
struct WINRT_IMPL_NOVTABLE IMemoryBufferByteAccess : unknown_abi
130+
struct WINRT_IMPL_ABI_DECL IMemoryBufferByteAccess : unknown_abi
131131
{
132132
virtual int32_t __stdcall GetBuffer(uint8_t** value, uint32_t* capacity) noexcept = 0;
133133
};

strings/base_delegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace winrt::impl
109109
}
110110

111111
template <typename R, typename... Args>
112-
struct WINRT_IMPL_NOVTABLE variadic_delegate_abi : unknown_abi
112+
struct WINRT_IMPL_ABI_DECL variadic_delegate_abi : unknown_abi
113113
{
114114
virtual R invoke(Args const& ...) = 0;
115115
};

strings/base_fast_forward.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
#define WINRT_IMPL_FF_NOVTABLE
1111
#endif
1212

13+
#if defined(__clang__) && __has_attribute(__lto_visibility_public__)
14+
#define WINRT_IMPL_FF_PUBLIC __attribute__((lto_visibility_public))
15+
#else
16+
#define WINRT_IMPL_FF_PUBLIC
17+
#endif
18+
1319
#if !defined(WINRT_FAST_ABI_SIZE)
1420
#define WINRT_FAST_ABI_SIZE %
1521
#endif
@@ -36,7 +42,7 @@ namespace winrt::impl
3642
}
3743
};
3844

39-
struct WINRT_IMPL_FF_NOVTABLE inspectable
45+
struct WINRT_IMPL_FF_NOVTABLE WINRT_IMPL_FF_PUBLIC inspectable
4046
{
4147
virtual int32_t __stdcall QueryInterface(guid const& id, void** object) noexcept = 0;
4248
virtual uint32_t __stdcall AddRef() noexcept = 0;
@@ -137,3 +143,4 @@ namespace winrt
137143
#undef WINRT_IMPL_STRING
138144
#undef WINRT_IMPL_STRING_1
139145
#undef WINRT_IMPL_FF_NOVTABLE
146+
#undef WINRT_IMPL_FF_PUBLIC

strings/base_macros.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
#define WINRT_IMPL_NOVTABLE
6262
#endif
6363

64+
#if defined(__clang__) && __has_attribute(__lto_visibility_public__)
65+
#define WINRT_IMPL_PUBLIC __attribute__((lto_visibility_public))
66+
#else
67+
#define WINRT_IMPL_PUBLIC
68+
#endif
69+
70+
#define WINRT_IMPL_ABI_DECL WINRT_IMPL_NOVTABLE WINRT_IMPL_PUBLIC
71+
6472
#if defined(__clang__)
6573
#define WINRT_IMPL_HAS_DECLSPEC_UUID __has_declspec_attribute(uuid)
6674
#elif defined(_MSC_VER)

0 commit comments

Comments
 (0)