Skip to content

Commit 231f88f

Browse files
committed
Fix DBI loading problem on Linux (#82461)
1 parent 4155275 commit 231f88f

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

src/coreclr/dlls/mscordbi/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,21 @@ elseif(CLR_CMAKE_HOST_UNIX)
100100
mscordaccore
101101
)
102102

103-
target_link_libraries(mscordbi ${COREDBI_LIBRARIES})
103+
# Before llvm 16, lld was setting `--undefined-version` by default. The default was
104+
# flipped to `--no-undefined-version` in lld 16, so we will explicitly set it to
105+
# `--undefined-version` for our use-case.
106+
include(CheckLinkerFlag OPTIONAL)
107+
if(COMMAND check_linker_flag)
108+
check_linker_flag(CXX -Wl,--undefined-version LINKER_SUPPORTS_UNDEFINED_VERSION)
109+
if (LINKER_SUPPORTS_UNDEFINED_VERSION)
110+
add_linker_flag(-Wl,--undefined-version)
111+
endif(LINKER_SUPPORTS_UNDEFINED_VERSION)
112+
endif(COMMAND check_linker_flag)
113+
114+
# COREDBI_LIBRARIES is mentioned twice because ld is one pass linker and will not find symbols
115+
# if they are defined after they are used. Having all libs twice makes sure that ld will actually
116+
# find all symbols.
117+
target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})
104118

105119
add_dependencies(mscordbi mscordaccore)
106120

src/coreclr/dlls/mscordbi/mscordbi.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,3 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
3232
// Defer to the main debugging code.
3333
return DbgDllMain(hInstance, dwReason, lpReserved);
3434
}
35-
36-
#if defined(HOST_LINUX) && defined(TARGET_LINUX)
37-
PALIMPORT HINSTANCE PALAPI DAC_PAL_RegisterModule(IN LPCSTR lpLibFileName);
38-
PALIMPORT VOID PALAPI DAC_PAL_UnregisterModule(IN HINSTANCE hInstance);
39-
40-
HINSTANCE PALAPI PAL_RegisterModule(IN LPCSTR lpLibFileName)
41-
{
42-
return DAC_PAL_RegisterModule(lpLibFileName);
43-
}
44-
45-
VOID PALAPI PAL_UnregisterModule(IN HINSTANCE hInstance)
46-
{
47-
DAC_PAL_UnregisterModule(hInstance);
48-
}
49-
#endif

0 commit comments

Comments
 (0)