Open SharzyL opened 1 year ago
The correct fix might be moving clang-tools out of clangStenv.
clang-tools
is a batch of wrappers of binaries in clang-unwrapped
. Hence the steps might be:
clang-unwrapped
to an extra outputclang-tools
to use the new outputIs there any update on this issue? It's quite frustrating to have to manually add clang-tools
to the PATH just to have a working clangd binary.
I am also struggling with this and have no clue how to get clang-tidy to work
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/take-clang-tools-over-executables-in-llvmpackages-stdenv/39831/2
I'm also affected by this issue. Unwrapped clang tooling should only be provided when we specifically use clang-tools-unwrapped
or something like that.
Another point: Right now, packages using C++20 modules do not build by default, and simply errors out. This is because clang-scan-deps
shipped in the clang package is unwrapped, and cannot find standard library headers. The only one usable is from clang-tools
, which the executables are inaccessible from PATH
since clang executables take over. For nix package using C++20 modules to be usable, clang-scan-deps
needs to be wrapped.
I think it would be reasonable to make them either wrapped by default in clang, or let clang-tools
by prioritized over clang's packages or make clang not ship any tools by default. Either of those three solution would make C++20 modules and LSP to finally work out of the box.
Since a working wrapped clang-tools are becoming required to build some packages, I would recommend making those from the stdenv wrapped by default, and allow users to override it with clang-tools-unwrapped
if needed.
@gracicot Thank you so much. It has been driving me crazy for a couple of days. CXX_SCAN_FOR_MODULES is 'ON' by default in cmake 3.28 (. So it breaks compilation even if you do not use modules in the project.
cmake 3.29 gets populated with current nixpkgs.
with import <nixpkgs> {};
pkgs.mkShell.override { stdenv = pkgs.llvmPackages_18.stdenv; } {
packages = with pkgs; [
cmake
];
}
#include <iostream>
int main()
{
std::cout << "hello world\n";
return 0;
}
> cmake ../ -GNinja
-- The CXX compiler identification is Clang 18.1.4
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/2p36b6gd1sy0s3z952rlylwdm3pari56-clang-wrapper-18.1.4/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.3s)
-- Generating done (0.0s)
> ninja
[1/4] Scanning /home/yukula/Proj/cppcamp/main.cxx for CXX dependencies
FAILED: CMakeFiles/hello.dir/main.cxx.o.ddi
"/nix/store/gyl04ilm9lvzy092a2sh27023d5r1b9r-clang-18.1.4/bin/clang-scan-deps" -format=p1689 -- /nix/store/2p36b6gd1sy0s3z952rlylwdm3pari56-clang-wrapper-18.1.4/bin/clang++ -std=gnu++20 -x c++ /home/yukula/Proj/cppcamp/main.cxx -c -o CMakeFiles/hello.dir/main.cxx.o -MT CMakeFiles/hello.dir/main.cxx.o.ddi -MD -MF CMakeFiles/hello.dir/main.cxx.o.ddi.d > CMakeFiles/hello.dir/main.cxx.o.ddi.tmp && mv CMakeFiles/hello.dir/main.cxx.o.ddi.tmp CMakeFiles/hello.dir/main.cxx.o.ddi
Now if I disable CXX_SCAN_FOR_MODULES:
> cmake ../ -GNinja -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
-- The CXX compiler identification is Clang 18.1.4
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/2p36b6gd1sy0s3z952rlylwdm3pari56-clang-wrapper-18.1.4/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.3s)
-- Generating done (0.0s)
> ninja
[2/2] Linking CXX executable hello
with import <nixpkgs> {};
pkgs.mkShell.override { stdenv = pkgs.llvmPackages_18.stdenv; } {
packages = with pkgs; [
clang-tools_18 #https://github.com/NixOS/nixpkgs/issues/214945
# ...
];
}
@yukula actually, I solved this by adding clang-tools_18
to nativeBuildInputs
and it has worked pretty well for me.
Describe the bug
When working with
clangStdenv
(note thatstdenv
for darwin uses clang), the binaries of clang tools are provided in the path ofclang-unwrapped
. However, these binaries are unwrapped and cannot properly resolve system header paths.If we want to use the wrapped one, they are provided in the package
clang-tools
. But even if we addclang-tools
tonativeBuildInputs
, we still get the unwrapped version, since the path ofclang-tools
is placed afterclang-unwrapped
inPATH
. Is there a clean way to access unwrapped clang tools?Steps To Reproduce
Enter the following nix shell:
It shows
which means
clang-tidy
is the unwrapped version.Expected behavior
There should be a clean way to access the wrapped clang tools.
Additional context
A possible solution is to remove the clang-tool binaries from unwrapped clang. Or any better solution?
Notify maintainers
@Ericson2314 @sternenseemann @dtzWill @primeos
Metadata
"x86_64-linux"
Linux 6.1.6, NixOS, 23.05 (Stoat), 23.05pre-git
yes
yes
nix-env (Nix) 2.12.0
""
""
/nix/store/ld350gbq2w5654yw4q95kxhxp4569zi6-source