Fix undefined symbols in release build of libcoreclr on Linux
authorSergiy Kuryata <sergeyk@microsoft.com>
Sat, 7 Feb 2015 23:16:27 +0000 (15:16 -0800)
committerSergiy Kuryata <sergeyk@microsoft.com>
Sat, 7 Feb 2015 23:16:27 +0000 (15:16 -0800)
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]

src/inc/corhlprpriv.h
src/jit/instr.cpp
src/vm/exceptionhandling.cpp

index bacdfb2..9015071 100644 (file)
@@ -184,6 +184,11 @@ public:
         _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)
index c618fed..84f7d20 100644 (file)
@@ -455,7 +455,6 @@ void                CodeGenInterface::inst_FN(instruction ins, unsigned stk)
  *  Display a stack frame reference.
  */
 
-inline
 void                CodeGen::inst_set_SV_var(GenTreePtr tree)
 {
 #ifdef  DEBUG
index 36dca5e..c46da95 100644 (file)
@@ -4515,7 +4515,7 @@ void FixupDispatcherContext(DISPATCHER_CONTEXT* pDispatcherContext, CONTEXT* pCo
 
 
 // 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);