Uh oh!
There was an error while loading. Please reload this page.
Fix DBI loading problem on Linux - #82461
Conversation
Part of PR dotnet#81573 needed to be undone to build libmscordbi.so without any undefined symbols from the DAC. The DAC_PAL_RegisterModule, etc. stubs I recommended didn't work and DBI could not be loaded by SOS because of missing exports. The double pass at the libraries from the `target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})` cmake file needed to be restored. The stubs were not needed after that.
am11
commented
Feb 22, 2023
@mikem8361, unfortunately it breaks clang 16 build. It's currently in rc3 stage (scheduled to be released on March 7): # host environment: bash on ubuntu 20.04 amd64
$ docker build - -t dotnet-prereq-clang16 <<EOFFROM amd64/ubuntuRUN apt update; apt install -y cmake curl wget software-properties-common gnupg liblttng-ust-dev libkrb5-dev libicu-dev libssl-dev libz-dev; \ curl -sSL https://apt.llvm.org/llvm.sh | bash -s - 16 allEOF
$ docker run --rm -v$(pwd):/runtime dotnet-prereq-clang16 /runtime/src/coreclr/build-runtime.sh
# snip
[ 85%] Linking CXX shared library libclrjit.so
[ 85%] Building CXX object jit/CMakeFiles/clrjit_win_x86_x64.dir/lir.cpp.o
ld.lld: error: version script assignment of 'V1.0' to symbol 'PAL_RegisterModule' failed: symbol not defined
ld.lld: error: version script assignment of 'V1.0' to symbol 'PAL_UnregisterModule' failed: symbol not defined
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [dlls/mscordbi/CMakeFiles/mscordbi.dir/build.make:187: dlls/mscordbi/libmscordbi.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:4537: dlls/mscordbi/CMakeFiles/mscordbi.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 85%] Building CXX object jit/CMakeFiles/clrjit_unix_x64_x64.dir/lsra.cpp.o
[ 85%] Building CXX object jit/CMakeFiles/clrjit_win_x64_x64.dir/emitxarch.cpp.o
...
make: *** [Makefile:136: all] Error 2
/
Failed to build "CoreCLR component".Do you see another way to satisfy both lld-16 and SOS? |
am11
commented
Feb 22, 2023
With main the build succeeds and ldd resolves all symbols: $ docker run --rm -v$(pwd):/runtime dotnet-prereq-clang16 \
ldd /runtime/artifacts/bin/coreclr/linux.x64.Debug/libmscordbi.so
linux-vdso.so.1 (0x00007ffda470a000)
libmscordaccore.so => /runtime/artifacts/bin/coreclr/linux.x64.Debug/libmscordaccore.so (0x00007fdd66eec000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fdd66cbb000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fdd66bd4000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fdd66bb4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdd6698c000)
/lib64/ld-linux-x86-64.so.2 (0x00007fdd677db000) |
mikem8361
commented
Feb 22, 2023
I think you need the -r to show the undefined symbols. |
hoyosjs
commented
Feb 22, 2023
We might have to merge this while we figure out next steps. It would block upstack repos from debugging. |
mikem8361
commented
Feb 22, 2023
I have no idea why this is happening with clang 16 and not older versions. Like Juan said it is breaking SOS, VS debugging and our debugger testing. We should merge this and figure out the clang 16 issue. |
am11
left a comment
There was a problem hiding this comment.
Figured out a way to make both worlds happy.
| @@ -100,7 +100,10 @@ elseif(CLR_CMAKE_HOST_UNIX) | |||
| mscordaccore | |||
| ) | |||
There was a problem hiding this comment.
| # 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.
Part of PR #81573 needed to be undone to build libmscordbi.so without any undefined symbols from the DAC. The DAC_PAL_RegisterModule, etc. stubs I recommended didn't work and DBI could not be loaded by SOS (and I assume other debuggers) because of missing exports.
The double pass at the libraries from the
target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})cmake file needed to be restored. The stubs were not needed after that.Before the changes:
When I build the latest main I locally I get even more undefines before this fix: