When building a release version of libcoreclr.so on Linux the LLVM toolchain makes optimizations that result in undefined symbols in libcoreclr.so which causes dlopen(“libcoreclr.so”) to fail at runtime. There were three problematic functions:
1. CQuickMemoryBase<SIZE, INCREMENT>::ReSizeNoThrow(SIZE_T iItems)
2. FixupDispatcherContext(...)
3. CodeGen::inst_set_SV_var(GenTreePtr tree); - this function is marked as inline and has the entire body under “#ifdef DEBUG”.
To fix the problem with ReSizeNoThrow I added the “__attribute__((used))” attribute to the declaration of the function. This attribute is enabled for the llvm toolchain only. For the other two functions I have simply removed ‘inline’ since these functions are not performance critical.
[tfs-changeset: 1412107]
_Alloc<TRUE /*bGrow*/, TRUE /*bThrow*/>(iItems);
}
+#ifdef __llvm__
+ // This makes sure that we will not get an undefined symbol
+ // when building a release version of libcoreclr using LLVM.
+ __attribute__((used))
+#endif // __llvm__
HRESULT ReSizeNoThrow(SIZE_T iItems);
void Shrink(SIZE_T iItems)
* Display a stack frame reference.
*/
-inline
void CodeGen::inst_set_SV_var(GenTreePtr tree)
{
#ifdef DEBUG
// See the comment above for the overloaded version of this function.
-FORCEINLINE void FixupDispatcherContext(DISPATCHER_CONTEXT* pDispatcherContext, CONTEXT* pContext, CONTEXT* pOriginalContext, PEXCEPTION_ROUTINE pUnwindPersonalityRoutine = NULL)
+void FixupDispatcherContext(DISPATCHER_CONTEXT* pDispatcherContext, CONTEXT* pContext, CONTEXT* pOriginalContext, PEXCEPTION_ROUTINE pUnwindPersonalityRoutine = NULL)
{
_ASSERTE(pOriginalContext != NULL);
FixupDispatcherContext(pDispatcherContext, pContext, (LPVOID)::GetIP(pOriginalContext), pUnwindPersonalityRoutine);