Skip to content

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

Open
sternenseemann wants to merge 2 commits intoNixOS:stagingfrom
sternenseemann:scan-build
Open

llvmPackages_*.clang-unwrapped: make scan-build work#144302
sternenseemann wants to merge 2 commits intoNixOS:stagingfrom
sternenseemann:scan-build

Conversation

@sternenseemann
Copy link
Member

  • 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)
    • 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
  • Fits CONTRIBUTING.md.

@sternenseemann sternenseemann changed the base branch from master to staging November 2, 2021 23:16
@ofborg ofborg bot added the 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. label Nov 2, 2021
@ofborg ofborg bot requested review from 7c6f434c, dtzWill, lovek323 and primeos November 2, 2021 23:32
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. labels Nov 2, 2021
@schuelermine
Copy link
Contributor

Checked build & it works

@sternenseemann
Copy link
Member Author

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

@rrbutani rrbutani mentioned this pull request Nov 14, 2022
92 tasks
@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 8, 2023
@leana8959
Copy link
Contributor

leana8959 commented Dec 5, 2023

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'

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 5, 2023
@ofborg ofborg bot requested review from alyssais and rrbutani December 7, 2023 15:36
@ofborg ofborg bot added 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. and removed 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. labels Dec 7, 2023
@sternenseemann
Copy link
Member Author

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?

@alyssais
Copy link
Member

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.

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 20, 2024
@rrbutani rrbutani added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label May 27, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
@RossComputerGuy
Copy link
Member

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

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 9, 2024
@sternenseemann
Copy link
Member Author

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

@RossComputerGuy
Copy link
Member

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

@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 1, 2025
@cloudripper
Copy link
Contributor

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

@Bradley-Cooley
Copy link

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

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 5, 2025
@RossComputerGuy
Copy link
Member

RossComputerGuy commented Feb 5, 2025

but anything I can do to help?

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

@sternenseemann
Copy link
Member Author

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

Move scan-build-py and its dependencies libear, libscanbuild,
analyze{c++,cc} and intercept-{cc,c++} where they are patchShebanged
without incurring an extra dependency on python for $out.

libear, libscanbuild, libexec/{intercept,analyze}-c* are tracked in
clang/tools/scan-build-py, so I assume they aren't used by anything
else.
This is a conservative take on making scan-build work. It basically
needs two things

- perl, idelly via a patched shebang
- Access to {ccc,c++}-analyzer which is provided easily by moving
  libexec. Patching scan-build to look into $lib would defeat the
  purpose of the separate outputs, of course.

The former is not provided via this change, instead /usr/bin/env and
perl in PATH are required. This is mainly to avoid the closure size
increase of ~100MB caused by perl plus potential bootstrapping trouble
on darwin. (scan-build-py can be made to work without much less problems
since clang-unwrapped.python already depends on python.) We can probably
improve on this by adding scan-build* to clang-tools.
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Feb 5, 2025
@nix-owners nix-owners bot requested a review from RossComputerGuy February 5, 2025 20:10
@sternenseemann
Copy link
Member Author

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…)

@github-actions github-actions bot removed the 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. label Feb 5, 2025
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 2, 2025
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 25, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 4, 2025
@sternenseemann
Copy link
Member Author

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

@nixpkgs-ci nixpkgs-ci bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 19, 2025
@RossComputerGuy
Copy link
Member

Do we still want to do this?

If we want the tools still, sure

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Dec 13, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants