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
clang-tools: teach about nix's include path #73345
Conversation
|
||
export clang=${clang} | ||
substituteAll ${./wrapper} $out/bin/clangd | ||
chmod +x $out/bin/clangd | ||
for tool in \ | ||
clang-apply-replacements \ | ||
clang-check \ | ||
clang-format \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we skip this one from being wrapped?
ae06bf0
to
1240f96
Compare
Might be worth a backport |
1174555
to
5c23507
Compare
Tested with non-trivial C projects and clangd. |
local path | ||
while (( $# )); do | ||
case $1 in | ||
-isystem|-I) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idirafter could also be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed parsing of -I
was wrong anyway, since there can be no space in between. Since we only use -isystem
right now in stdenv, I just simplified the code of the wrapper rather than having a half broken implementation for -I
. -Idirafter
is also not used in nixpkgs.
By translating NIX_CFLAGS_COMPILE to CPATH, all tools will now find c headers properly, when run in a nix-shell.
5c23507
to
a10ef1a
Compare
clang-tools: teach about nix's include path (cherry picked from commit f3759a6)
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/clang-tooling-woes-on-nixos/2314/15 |
Did you ever get around to submitting a change like this? I'm running into what I suspect is the same error at the moment and am wondering how deep I should dig :) |
There is an alternative to @knedlsepp proposal: With https://github.com/NixOS/nixpkgs/pull/85189/files#diff-ae6d7fc8f1059168bd391972ef177c31R40 one could include the platforms native c++ headers. Don't know what the latest state of this is, but @Ericson2314 might know more. |
I don't think I could ever get this working 100%. I only got a local project specific workaround that basically breaks the C-only backend but makes C++ work. :-\ |
I met the same problem recently. It is solved by changing the order of By the way, Would someone modify the wrap or make it working more genericly? |
If it returns an empty string, you might be not in a nix-shell. Make sure that |
@knedlsepp @tazjin This PR should fix your problems with |
I retried it and find the reason. The wrap is always worked under bash, it is not a problem. The one is caused by glibc and libc++ is more important.
|
In our wrapper it should be always bash. So that should be not a problem. |
By translating NIX_CFLAGS_COMPILE to CPATH,
all tools will now find c headers properly,
when run in a nix-shell.
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @