Skip to content

Commit

Permalink
Fix DBI loading problem on Linux (#82461)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayakael committed Apr 6, 2023
1 parent 4155275 commit 231f88f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
16 changes: 15 additions & 1 deletion src/coreclr/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,21 @@ elseif(CLR_CMAKE_HOST_UNIX)
mscordaccore
)

target_link_libraries(mscordbi ${COREDBI_LIBRARIES})
# Before llvm 16, lld was setting `--undefined-version` by default. The default was
# flipped to `--no-undefined-version` in lld 16, so we will explicitly set it to
# `--undefined-version` for our use-case.
include(CheckLinkerFlag OPTIONAL)
if(COMMAND check_linker_flag)
check_linker_flag(CXX -Wl,--undefined-version LINKER_SUPPORTS_UNDEFINED_VERSION)
if (LINKER_SUPPORTS_UNDEFINED_VERSION)
add_linker_flag(-Wl,--undefined-version)
endif(LINKER_SUPPORTS_UNDEFINED_VERSION)
endif(COMMAND check_linker_flag)

# COREDBI_LIBRARIES is mentioned twice because ld is one pass linker and will not find symbols
# if they are defined after they are used. Having all libs twice makes sure that ld will actually
# find all symbols.
target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})

add_dependencies(mscordbi mscordaccore)

Expand Down
15 changes: 0 additions & 15 deletions src/coreclr/dlls/mscordbi/mscordbi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,3 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
// Defer to the main debugging code.
return DbgDllMain(hInstance, dwReason, lpReserved);
}

#if defined(HOST_LINUX) && defined(TARGET_LINUX)
PALIMPORT HINSTANCE PALAPI DAC_PAL_RegisterModule(IN LPCSTR lpLibFileName);
PALIMPORT VOID PALAPI DAC_PAL_UnregisterModule(IN HINSTANCE hInstance);

HINSTANCE PALAPI PAL_RegisterModule(IN LPCSTR lpLibFileName)
{
return DAC_PAL_RegisterModule(lpLibFileName);
}

VOID PALAPI PAL_UnregisterModule(IN HINSTANCE hInstance)
{
DAC_PAL_UnregisterModule(hInstance);
}
#endif

0 comments on commit 231f88f

Please sign in to comment.