Skip to content
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

cc-wrapper: adding a cc-wrapper-hook to the cc-wrapper #197937

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

danielbarter
Copy link
Contributor

@danielbarter danielbarter commented Oct 26, 2022

Description of changes

Adding a cc-wrapper-hook to the cc-wrapper. The ld-wrapper already has a post-link-hook. My main motivation for adding this is it will allow us to reliably generate compile_commands.json files which are required for LSP servers to function for C/C++ projects. Existing tools for generating compile_commands.json are unreliable on nixos because they struggle to distinguish between the compiler wrappers and the compilers themselves.

See my earlier PR for an example of how this could be used: #192694. This PR is just the infrastructure part of my earlier PR. Also see the discussion on discourse: https://discourse.nixos.org/t/using-nix-infrastructure-to-reliably-generate-compile-commands-json/21961/20

I am hoping that this smaller PR will be easier to merge!

Things done
  • add cc-wrapper-hook to cc-wrapper.sh.
  • document both cc-wrapper-hook and post-link-hook.
  • 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/)
  • 22.11 Release Notes (or backporting 22.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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 8.has: documentation This PR adds or changes documentation label Oct 26, 2022
@Ericson2314
Copy link
Member

Can you link the PR where post link hook was added?

@danielbarter
Copy link
Contributor Author

Looks like it was added here: #105026

Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

I guess this is OK. Another option is to just manually wrap these packages oneself, so we don't need a hook, but I guess this is fine.

@Ericson2314 Ericson2314 merged commit 0c09b3d into NixOS:staging Oct 28, 2022
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/using-nix-infrastructure-to-reliably-generate-compile-commands-json/21961/21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants