You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GCC doesn’t support uuid but there are ways to workaround it. IMO, the simplest solution is to use typeinfo stuff from boost. But my test reveals that coreclrpal doesn’t use any external libraries and uuid stuff is heavily embedded into PAL.
@janvorli, did the portable GUID implementation prior to v2.1 release, and removed the build-time and runtime dependencies on libuuid: dotnet/coreclr#16643. Could it be used with MIDL_INTERFACE?
@am11 we don't want to add more external library dependencies again. But I am not sure how the libuuid would help anyways. All it implements is generating uuids, converting between strings and uuids, and comparing uuids.
We don't need to create new guids. The guids are defined on the interfaces and have specific predefined values that external things like profiler or debugger depend on.
What we need here is to attach those guids to interfaces so that we can query a guid for a given interface.
@franksinankaya I am not sure how you envision a technique using the type_index would work. At many places, we are comparing some IID constant / variable to the __uuidof(type). So it seems you'd need to have some dynamic lookup of type_index to IID in addition to what you've suggested. Then you'd need to fill it in with all known interfaces / IIDs.
It seems we cannot avoid explicitly creating a mapping between all interfaces and their respective IIDs, but I think we can do that statically. Here is my idea:
classTypeToIID
{
public:// Default version of the GetIID function for types where the type was not bound to IID using the macro belowtemplate<typename TInterface>
staticIIDGetIID()
{
returnIID_NULL;
}
};
#defineBIND_UUID_OF(T) template<> IID TypeToIID::GetIID<T>() { returnIID_##T; }
#define__uuidof(T) TypeToIID::GetIID<T>()
// For each known interface, we would then need to use the BIND_UUID_OF, as follows:BIND_UUID_OF(IUnknown)
BIND_UUID_OF(ICLRPrivAssembly)
BIND_UUID_OF(ICLRServices)
// etc...
I have started implementing this. Writing an explicit BIND_UUID_OF seemed excessive and unscaling. I think the right solution is to add BIND_UUID_OF to DEFINE_GUID in guiddef.h so that the template also gets instantiated anytime a new GUID is declared.
Issue is that DEFINE_GUID is called with IID_xyz pattern.
I need to convert it to BIND_UUID_OF(xyz)
Is this possible at all? I was looking at constexpr.
Activity
franksinankaya commentedon Feb 21, 2019
@janvorli @jkotas @am11
jkotas commentedon Feb 21, 2019
CoreCLR uses the old fashioned portable way to define GUIDs that was used before the
__uuidofMicrosoft C++ extension was invented.The GUIDs are initialized by compiling the
*_i.cppfiles generated by MIDL compiler: https://github.com/dotnet/coreclr/blob/master/src/inc/CMakeLists.txt#L54MIDL_INTERFACEis a macro from Windows SDK headers that is used in auto-generated code. We would not want to change its shape.franksinankaya commentedon Feb 26, 2019
Another approach is to stub out MIDL_INTERFACE as
#define MIDL_INTERFACE(x) struct
Then,
__uuidof() needs to be something like
#define __uuidof(T) boost::typeindex::type_index(typeid(T))
or
#define __uuidof(T) std::type_index(typeid(T))
Since code is compiled with -nostdinc, what's the best way to implement this?
am11 commentedon Feb 26, 2019
@janvorli, did the portable GUID implementation prior to v2.1 release, and removed the build-time and runtime dependencies on libuuid: dotnet/coreclr#16643. Could it be used with
MIDL_INTERFACE?janvorli commentedon Feb 26, 2019
@am11 we don't want to add more external library dependencies again. But I am not sure how the libuuid would help anyways. All it implements is generating uuids, converting between strings and uuids, and comparing uuids.
am11 commentedon Feb 26, 2019
sorry by
itI meant could thePAL_RandomorCoCreateGuidbe used in case ofMIDL_INTERFACE, not bringing back libuuid :)janvorli commentedon Feb 26, 2019
We don't need to create new guids. The guids are defined on the interfaces and have specific predefined values that external things like profiler or debugger depend on.
What we need here is to attach those guids to interfaces so that we can query a guid for a given interface.
@franksinankaya I am not sure how you envision a technique using the type_index would work. At many places, we are comparing some IID constant / variable to the __uuidof(type). So it seems you'd need to have some dynamic lookup of type_index to IID in addition to what you've suggested. Then you'd need to fill it in with all known interfaces / IIDs.
It seems we cannot avoid explicitly creating a mapping between all interfaces and their respective IIDs, but I think we can do that statically. Here is my idea:
jkotas commentedon Feb 26, 2019
Yes, that should work. @franksinankaya Feel free to use it in your project, but I do not think we would want to complicate CoreCLR PAL with this.
franksinankaya commentedon Apr 2, 2019
I have started implementing this. Writing an explicit BIND_UUID_OF seemed excessive and unscaling. I think the right solution is to add BIND_UUID_OF to DEFINE_GUID in guiddef.h so that the template also gets instantiated anytime a new GUID is declared.
Issue is that DEFINE_GUID is called with IID_xyz pattern.
I need to convert it to BIND_UUID_OF(xyz)
Is this possible at all? I was looking at constexpr.