-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
cquery: init at 2018-03-25 #37890
cquery: init at 2018-03-25 #37890
Conversation
args+=", \"-isystem\", \"${llvmPackages.libcxx}/include/c++/v1\"" | ||
wrapProgram $out/bin/cquery \ | ||
--add-flags "'"'--init={"extraClangArguments": ['"''${args}"']}'"'" |
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.
What happens if --init
is specified twice?
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.
It gets overridden if it is duplicated, but probably test best we can do without custom patches. NIX_CFLAGS_COMPILE
/$NIX_CXXSTDLIB_COMPILE
might be also interesting here?
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.
Sorry I did not test for that. I think it would be best to patch that upstream. I could use jd to merge the options in the meantime, but that would be pretty hacky...
NIX_CFLAGS_COMPILE contains thing that are only needed during build time, so I don't think that should be used.
See my other reply regarding NIX_CXXSTDLIB_COMPILE.
Btw, thank you for taking a look.
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 mean NIX_CFLAGS_COMPILE
could be read at run-time because then developing in a nix shell would just works.
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 see. I'd still like it to be usable outside of nix-shell, though.
Also, reading NIX_CFLAGS_COMPILE at runtime would introduce platform dependent behaviour, and I would rather not provide people with an excuse to avoid creating a compile_commands.json file.
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.
The point is that on nix compile_command.json
is not enough to find all includes.
To give you an example. If you install zlib1g-dev
on ubuntu it will be installed into /usr/include
.
gcc/libclang will search there for includes and find it during compilation.
If you do nix-shell -p zlib
in a project, cc-wrapper from nixpkgs
will add -isystem /nix/store/spxwrxnsf28sq5gdp42xvqac7psvlqya-zlib-1.2.11-dev/include -isystem /nix/store/spxwrxnsf28sq5gdp42xvqac7psvlqya-zlib-1.2.11-dev/include
to $NIX_CFLAGS_COMPILE
and the compiler wrapper around gcc/clang will pick the same variable up.
In both versions the build system don't need to explicitly pass an include argument and they don't do that. So if cquery
does not replicate the same behaviour it will be not very useful except for basic c/c++ project depending on the standard library. Platform specific behavior is fine here. That's the point of packaging.
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 would argue that if a compile_commands.json
does not contain include paths to zlib if its header is included in your compilation unit, then the compilation database is wrong.
Even though the path to /usr/include
is added automatically on other systems does not make it right.
There are better ways to do this, for example cmake solves this through CMAKE_MODULES_PATH
and the findXXX.cmake
modules.
I must admit that classic ./configure; make; make install
style build systems can't easily do that, and getting those dependencies from the NIX_CFLAGS_COMPILE
field would be a viable workaround.
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.
But no real-life project does this correct completely. Take a look at neovim, systemd or llvm - these where just the first random three project I checked. Usually most projects just check if a header file can be found, but do not bother to add the full path - this would require either a cmake module or a pkgconfig file. Not every library/distribution provides this, sometimes they are even broken, that's why many projects add fallbacks to their build system.
src = fetchFromGitHub { | ||
owner = "cquery-project"; | ||
repo = "cquery"; | ||
rev = "e45a9ebbb6d8bfaf8bf1a3135b6faa910afea37e"; |
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.
How about a released version? https://github.com/cquery-project/cquery/releases
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.
The latest release version has a few bugs that have since been fixed. This revision works better (at least in the code bases I tested it with).
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.
ok. releases as it seems progress fast here anyway.
# We need to tell cquery where to find the standard library headers. | ||
args="\"-isystem\", \"${if (stdenv.hostPlatform.libc == "glibc") then stdenv.cc.libc.dev else stdenv.cc.libc}/include\"" | ||
args+=", \"-isystem\", \"${llvmPackages.libcxx}/include/c++/v1\"" |
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.
if llvmPackages.libcxx
is in buildInputs,
$NIX_CXXSTDLIB_COMPILE` should be used instead.
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 tried $NIX_CXXSTDLIB_COMPILE at first, but that starts with the paths to libstdc++ if we don't force libcxxStdenv. In my tests libclang seems to have a few problems with libstdc++, it works flawlessly with libc++.
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.
ok, then.
Use NIX_CFLAGS_COMPILE to find additional include paths.
Thanks! |
seems to not build on darwin: https://hydra.nixos.org/build/72710712/nixlog/1 A patch has been provided upstream: jacobdufault/cquery@4f773f4
|
opened a new PR: #39825 |
Motivation for this change
Add the cquery language server
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)