nixpkgs icon indicating copy to clipboard operation
nixpkgs copied to clipboard

llvmPackages_*.clang-unwrapped: make scan-build work

Open sternenseemann opened this issue 4 years ago • 15 comments

  • scan-build and c*-analyzer are written in Perl, so we need to add it as a buildInput, so the interpreter is patched.

  • For scan-build to discover c*-analyzer, the bin and libexec directories need to be in the same prefix. Since this is no big trouble for clang, we can just move the libexec directory from the lib to the out output.

To be tested how this interacts with bootstrapping for macOS and perhaps pkgsLLVM. Additional perl dependency may be a problem in some cases?

Motivation for this change
Things done
  • Built on platform(s)
    • [x] x86_64-linux
    • [ ] aarch64-linux
    • [ ] x86_64-darwin
    • [ ] aarch64-darwin
  • [ ] For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • [ ] Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • [ ] Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • [ ] Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 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
  • [x] Fits CONTRIBUTING.md.

sternenseemann avatar Nov 02 '21 23:11 sternenseemann

Checked build & it works

schuelermine avatar Jun 03 '22 14:06 schuelermine

Unsure whether this creates a problem for darwin in its current form since perl is not in bootstrap-tools I believe?

sternenseemann avatar Jun 03 '22 16:06 sternenseemann

Hello, is there any update on this ? I'm having the same issue as #151367 as of now. Thanks :)

~/repos/NTNU/CSU0013
$ scan-build -V make                                                   (71e23ed)
scan-build: 'ccc-analyzer' does not exist at '/nix/store/a5v30qll5i02vr9y97bk1rdx3mm6kvlm-clang-16.0.6/bin/ccc-analyzer'

leana8959 avatar Dec 05 '23 08:12 leana8959

Can I get some feedback on this (again)? For me there are the following questions:

  • Should we move scan-build to dev instead of bin?
  • What about the closure size with perl included? Would it be better to require the user of scan-build to “bring their own perl” and leave the /usr/bin/env perl shebang unpatched?

sternenseemann avatar Dec 12 '23 13:12 sternenseemann

Haven't had much of a look, but please no unpatched shebangs — it would make it not run in the Nix sandbox, where there's no /usr/bin/env.

alyssais avatar Dec 12 '23 14:12 alyssais

This PR has merge conflicts, has gotten stale, and has CI failures, is this PR still something we want to have done?

RossComputerGuy avatar Aug 09 '24 23:08 RossComputerGuy

Yes, we probably should. It's still an issue that scan-build doesn't work.

sternenseemann avatar Aug 12 '24 21:08 sternenseemann

Alright, any plans on rebasing the PR to resolve the conflicts?

RossComputerGuy avatar Aug 13 '24 06:08 RossComputerGuy

Are there any plans to move forward with this PR? This is still an open issue.

cloudripper avatar Jan 08 '25 17:01 cloudripper

@sternenseemann I'd love to see this land - not a contributor, but anything I can do to help?

Bradley-Cooley avatar Feb 05 '25 18:02 Bradley-Cooley

but anything I can do to help?

Unfortunately not, this PR requires rebasing which @sternenseemann has to do.

RossComputerGuy avatar Feb 05 '25 18:02 RossComputerGuy

I'll try and remember to do it soon, sorry!

sternenseemann avatar Feb 05 '25 18:02 sternenseemann

Redid the entire change on current nixpkgs and also made scan-build-py work (which is trivial). The change for scan-build is more conservative now and relies on an impure perl to avoid closure size concerns. I think we should probably integrate scan-build into clang-tools in the future to solve this. (Or add a perl output to clang, but ugh…)

sternenseemann avatar Feb 05 '25 20:02 sternenseemann

@RossComputerGuy Just found this again… Do we still want to do this?

sternenseemann avatar Aug 19 '25 22:08 sternenseemann

Do we still want to do this?

If we want the tools still, sure

RossComputerGuy avatar Aug 21 '25 01:08 RossComputerGuy