-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Re-enable support for using the system libunwind #42689
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
Conversation
cc @janvorli |
Consuming via source-build, things look good here:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source-build builds each component (coreclr, libraries, installer) separately and passes a separate set of args. It can skip passing -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND
to libraries. But this seems like a nice to have to make it possible to build all of runtime at once using the main ./build.sh
script in one call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is kind of unfortunate that the main build script only supports single set of cmake args that it pushes to all three sub-parts (coreclr, installer, libraries). It would be nice to enhance it to enable specifying these flags separately for coreclr, installer and libraries so that we don't have to do tricks like this. But for this PR, it is fine as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed #42711 for tracking that
This includes a backport of dotnet/runtime#42689
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo the nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is kind of unfortunate that the main build script only supports single set of cmake args that it pushes to all three sub-parts (coreclr, installer, libraries). It would be nice to enhance it to enable specifying these flags separately for coreclr, installer and libraries so that we don't have to do tricks like this. But for this PR, it is fine as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit - can you please delete the now empty if / endif and move the comment above to the location below where you have placed the libunwind finding?
We can now build runtime against the system libunwind using: ./build.sh -cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND This allows Linux distributions that already ship a compatible version of libunwind library to use that instead of carrying a duplicate in .NET. This provides some benefits to them, including smaller build sizes, slightly faster builds and fewer places to fix any vulnerabilities This functionality was already supported in .NET Core 3.1 and has regressed since. CoreCLR already handles `-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND`, so no changes are needed there. The libraries build doesn't care about this cmake varibale, but cmake itself fails if the variable is not used: EXEC : CMake error : [runtime/src/libraries/Native/build-native.proj] Manually-specified variables were not used by the project: CLR_CMAKE_USE_SYSTEM_LIBUNWIND So libraries just needs to check and ignore this variable. The singlefilehost needs to link against libunwind too. Otherwise the linker fails to resolve symbols, making the build fail: /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `UnwindContextToWinContext(unw_cursor*, _CONTEXT*)': dotnet/runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:176: undefined reference to `_ULx86_64_get_reg' /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:177: undefined reference to `_ULx86_64_get_reg' /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:178: undefined reference to `_ULx86_64_get_reg' /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:179: undefined reference to `_ULx86_64_get_reg' /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:180: undefined reference to `_ULx86_64_get_reg' /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:181: more undefined references to `_ULx86_64_get_reg' follow /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `GetContextPointer(unw_cursor*, ucontext_t*, int, unsigned long**)': runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:227: undefined reference to `_ULx86_64_get_save_loc' /usr/bin/ld: runtime/artifacts/bin/coreclr/Linux.x64.Debug//lib/libcoreclrpal.a(seh.cpp.o): in function `PAL_VirtualUnwind': runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:340: undefined reference to `_ULx86_64_init_local' /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:351: undefined reference to `_ULx86_64_step' /usr/bin/ld: runtime/src/coreclr/src/pal/src/exception/seh-unwind.cpp:360: undefined reference to `_ULx86_64_is_signal_frame' clang-10: error: linker command failed with exit code 1 (use -v to see invocation) Fixes: dotnet#42661
333b6b5
to
5ed5582
Compare
Hello @janvorli! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Thanks for reviewing and merging this! |
This includes a backport of dotnet/runtime#42689
@omajid is this needed for .NET 5 GA? |
We (Red Hat) would definitely like to make use of this feature in .NET 5 GA release. We are using it in 3.1 and this is a regression from .NET Core 3.1 to .NET 5. Ideally we would add it to 5.0 GA (or post GA if GA is absolutely frozen for now). If this doesn't get added to 5.0 GA, we still have some options: we can carry this as a patch in source-build or in our RPM packages. But that gets reviewed less thoroughly and becomes harder to maintain as runtime gets additional fixes. I think we should decide to handle this issue consistently with #42094 and #42415: either all go to 5.0 or none of them go to 5.0 GA. |
@dleeapho thoughts? |
/backport to release/5.0 |
Started backporting to release/5.0: https://github.com/dotnet/runtime/actions/runs/279015832 |
This includes a backport of dotnet/runtime#42689
This includes a backport of dotnet/runtime#42689
You can now build runtime against the system libunwind using:
This allows Linux distributions that already ship a compatible version of libunwind library to use that instead of carrying a duplicate in .NET. This provides some benefits to them, including smaller build sizes, slightly faster builds and fewer places to fix any vulnerabilities
This functionality was already supported in .NET Core 3.1 and has regressed since.
CoreCLR already handles
-DCLR_CMAKE_USE_SYSTEM_LIBUNWIND
, so no changes are needed there.The libraries build doesn't care about this cmake variable, but cmake itself fails if the variable is not used:
So libraries just needs to check and ignore this variable.
The singlefilehost needs to link against libunwind too. Otherwise the linker fails to resolve symbols, making the build fail:
Fixes: #42661