Skip to content

Support libspl build using llvm-libunwind #17230

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

Merged
merged 1 commit into from
Apr 24, 2025
Merged

Conversation

spauka
Copy link
Contributor

@spauka spauka commented Apr 8, 2025

Motivation and Context

This commit adds support for using llvm-libunwind for kernels built using llvm and clang. In particular, some clang versions will link to llvm-libunwind which has some small differences compared to gcc-libunwind that will prevent zfs from building.

Description

The two differences are that the largest register index is given by _LIBUNWIND_HIGHEST_DWARF_REGISTER, we need to check whether the register is a floating point register and the prototype for unw_regname takes the unwind cursor as the first argument.

How Has This Been Tested?

Built and ran zfs on aarch64. Tested the changes to libspl manually using a small test c program, but didn't cause an assertion failure on the loaded module.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Apr 8, 2025
@amotin
Copy link
Member

amotin commented Apr 8, 2025

@spauka checkstyle has failed to build this.

@amotin amotin added the Status: Revision Needed Changes are required for the PR to be accepted label Apr 8, 2025
@github-actions github-actions bot removed the Status: Revision Needed Changes are required for the PR to be accepted label Apr 8, 2025
Copy link
Member

@robn robn left a comment

Choose a reason for hiding this comment

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

This is a great start. I didn't realise there was two different libunwinds, good to know!

I tested locally with libunwind-19, and it seems to do the right thing. It's not working with my gcc unwind, see review comments. I suspect probably it would make more sense to do that test in autoconf, where we can do more complicated tests.

I reckon not too far to go to get it over the line, good stuff!

@robn robn added the Status: Revision Needed Changes are required for the PR to be accepted label Apr 9, 2025
@spauka
Copy link
Contributor Author

spauka commented Apr 9, 2025

Thanks so much for the detailed review. I appreciate your time helping me get started :)

I agree that a configure time check is more appropriate - I'll make the changes and update in the next few days.

@github-actions github-actions bot removed the Status: Revision Needed Changes are required for the PR to be accepted label Apr 12, 2025
This commit adds support for using llvm-libunwind for kernels built
using llvm and clang. The two differences are that the largest register
index is given by _LIBUNWIND_HIGHEST_DWARF_REGISTER, we need to check
whether the register is a floating point register and the prototype
for unw_regname takes the unwind cursor as the first argument.

Signed-off-by: Sebastian Pauka <me@spauka.se>
@spauka
Copy link
Contributor Author

spauka commented Apr 12, 2025

@robn The latest revision moves the test into the configure file, which tests for the _LIBUNWIND_HIGHEST_DWARF_REGISTER definition to detect whether LLVM libunwind is in use.

It builds successfully using both on my system, let me know if there are any other changes you would suggest.

P.S. I read the style guide as suggesting a force-push to maintain a single commit per PR, did I read this correctly?

@tonyhutter
Copy link
Contributor

P.S. I read the style guide as suggesting a force-push to maintain a single commit per PR, did I read this correctly?

Correct - single commits are the easiest to merge and cherry-pick back to point releases. We don't forbid multi-commit PRs though. A PR this small makes sense as a single commit.

@spauka spauka requested a review from robn April 23, 2025 00:10
Copy link
Member

@robn robn left a comment

Choose a reason for hiding this comment

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

Sorry for the delay! This looks really good. I've only done light testing, but it seems to compile and work ok with both kinds of libunwind locally, and on FreeBSD with neither around. Good stuff!

@tonyhutter tonyhutter added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Apr 23, 2025
@amotin amotin merged commit 1b4826b into openzfs:master Apr 24, 2025
20 of 23 checks passed
snajpa pushed a commit to vpsfreecz/zfs that referenced this pull request May 2, 2025
This commit adds support for using llvm-libunwind for kernels built
using llvm and clang. The two differences are that the largest register
index is given by _LIBUNWIND_HIGHEST_DWARF_REGISTER, we need to check
whether the register is a floating point register and the prototype
for unw_regname takes the unwind cursor as the first argument.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Sebastian Pauka <me@spauka.se>
Closes openzfs#17230
robn pushed a commit to robn/zfs that referenced this pull request May 23, 2025
This commit adds support for using llvm-libunwind for kernels built
using llvm and clang. The two differences are that the largest register
index is given by _LIBUNWIND_HIGHEST_DWARF_REGISTER, we need to check
whether the register is a floating point register and the prototype
for unw_regname takes the unwind cursor as the first argument.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Sebastian Pauka <me@spauka.se>
Closes openzfs#17230
(cherry picked from commit 1b4826b)
@robn robn mentioned this pull request May 23, 2025
14 tasks
robn pushed a commit to robn/zfs that referenced this pull request May 24, 2025
This commit adds support for using llvm-libunwind for kernels built
using llvm and clang. The two differences are that the largest register
index is given by _LIBUNWIND_HIGHEST_DWARF_REGISTER, we need to check
whether the register is a floating point register and the prototype
for unw_regname takes the unwind cursor as the first argument.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Sebastian Pauka <me@spauka.se>
Closes openzfs#17230
(cherry picked from commit 1b4826b)
tonyhutter pushed a commit that referenced this pull request May 28, 2025
This commit adds support for using llvm-libunwind for kernels built
using llvm and clang. The two differences are that the largest register
index is given by _LIBUNWIND_HIGHEST_DWARF_REGISTER, we need to check
whether the register is a floating point register and the prototype
for unw_regname takes the unwind cursor as the first argument.

Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Sebastian Pauka <me@spauka.se>
Closes #17230
(cherry picked from commit 1b4826b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants