Skip to content

llvmPackages_*.clangUseLLVM: add libunwind to lib search path (#201591)#220520

Merged
RaitoBezarius merged 1 commit intoNixOS:stagingfrom
SharzyL:llvm_add_libunwind
Jan 13, 2024
Merged

llvmPackages_*.clangUseLLVM: add libunwind to lib search path (#201591)#220520
RaitoBezarius merged 1 commit intoNixOS:stagingfrom
SharzyL:llvm_add_libunwind

Conversation

@SharzyL
Copy link
Copy Markdown
Contributor

@SharzyL SharzyL commented Mar 10, 2023

Description of changes

resolves #201591

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@SharzyL SharzyL requested a review from matthewbauer as a code owner March 10, 2023 18:08
@ofborg ofborg bot requested review from dtzWill, lovek323 and primeos March 10, 2023 18:22
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Mar 10, 2023
@sternenseemann
Copy link
Copy Markdown
Member

I guess that brings us to the old question of whether clangUseLLVM should be used/usable for anything else but as an implementation detail of how pkgsLLVM.stdenv is bootstrapped. But since it is exposed so prominently it should probably do something, @Ericson2314?

@ghost
Copy link
Copy Markdown

ghost commented Mar 11, 2023

Stale but related #207325.

Copy link
Copy Markdown
Contributor

@pwaller pwaller left a comment

Choose a reason for hiding this comment

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

I think the change is needed to make nix shell nixpkgs#pkgsLLVM.stdenv.cc be a functioning compiler.

On master prior to this patch, clangUseLLVM gives you a functioning compiler if the stdenv is used to build software, but then if you try to use the compiler outside of the stdenv it fails. The reason is that the binutils setup hook propagates libunwind (and other runtimes) into the NIX_LDFLAGS when you're in the stdenv because these packages are specified in extraPackages.

Since -lunwind and friends are a part of the compiler wrapper, it makes sense to me that the -L flags should also be a part of the wrapper, as you have done here.

Just one comment that they'll need conditionalising, I think -L/path/to/unwind should only be added if -lunwind is being added, it might be that the package won't build outside of those scenarios for example.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given that the library is conditional on !isWasm below and targetPlatform.useLLVM, this should probably be along side that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

clang links against libunwind when -unwindlib=libunwind is set. Hence if conditioning on targetPlatform.useLLVM, llvmPackages.clangUseLLVM still cannot find libunwind.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's definitely curious that we gate -lunwind on targetPlatform.useLLVM but not --unwindlib=libunwind.

Tracing back to where the -lunwind was added doesn't reveal any obvious reason for the discrepancy and I'm actually not clear on why the -lunwind was needed in the first place (my understanding is that it's implied). Perhaps there were scenarios where the linker was being invoked directly with the expectation that libunwind would be pulled in?

Regardless, doesn't need to block this PR. Adding this -L in shouldn't hurt.

@pwaller
Copy link
Copy Markdown
Contributor

pwaller commented Oct 14, 2023

cc @reckenrode are you aware of whether this could cause problems on darwin?

@reckenrode
Copy link
Copy Markdown
Contributor

cc @reckenrode are you aware of whether this could cause problems on darwin?

I shouldn’t think so. The only risk would be if it could cause an infinite recursion, but the ofborg eval check should catch that.

@SharzyL
Copy link
Copy Markdown
Contributor Author

SharzyL commented Oct 15, 2023

Rebased the commit and added conditioning on !isWasm now.

@ofborg ofborg bot requested a review from alyssais October 15, 2023 04:54
@ofborg ofborg bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. and removed 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. labels Oct 15, 2023
@SharzyL SharzyL requested a review from pwaller October 31, 2023 16:32
Copy link
Copy Markdown
Contributor

@pwaller pwaller left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me, unfortunately I don't have commit rights. @reckenrode ? @RaitoBezarius ?

Copy link
Copy Markdown
Contributor

@rrbutani rrbutani left a comment

Choose a reason for hiding this comment

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

I think @sternenseemann's question is the right one. It would be nicer to have something other than clangUseLLVM intended for use outside of stdenv but in the interim I think it makes sense to merge this fix.

It would be nice if we could have a test guarding against regressions but that doesn't need to block this PR.

@SharzyL thanks for your patience.

@rrbutani rrbutani added 12.approvals: 2 This PR was reviewed and approved by two persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Oct 31, 2023
@RaitoBezarius
Copy link
Copy Markdown
Member

Apologies for the delay, @SharzyL can you rebase for the conflicts and after that we go for the merge IMHO.

@SharzyL SharzyL force-pushed the llvm_add_libunwind branch from fba2fbb to 810cef7 Compare January 13, 2024 03:18
@SharzyL
Copy link
Copy Markdown
Contributor Author

SharzyL commented Jan 13, 2024

Rebase is complete

@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. and removed 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. labels Jan 13, 2024
@RaitoBezarius RaitoBezarius merged commit 81784c6 into NixOS:staging Jan 13, 2024
@RaitoBezarius
Copy link
Copy Markdown
Member

This probably should not have targeted staging given the low amount of rebuilds, but well, it can wait staging :).

@wegank
Copy link
Copy Markdown
Member

wegank commented Mar 12, 2024

Is the exclusion of LLVM 17 intended in this PR?

@SharzyL
Copy link
Copy Markdown
Contributor Author

SharzyL commented Mar 12, 2024

Probably a omittance during rebase

ghost pushed a commit that referenced this pull request Mar 27, 2024
ghost pushed a commit that referenced this pull request Mar 27, 2024
llvmPackages_17.clangUseLLVM: apply omitted #220520
@rrbutani rrbutani added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants