Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DBI loading problem on Linux #82461

Merged
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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)

Fixes the compilation error and ldd -r libmscordbi.so reports no missing symbols.

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(TARGET_LINUX) && !defined(HOST_WINDOWS)
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