# Clang tooling woes 2

**URL:** https://discourse.nixos.org/t/clang-tooling-woes-2/9640
**Category:** Help
**Created:** [October 25, 2020, 6:21pm UTC](https://discourse.nixos.org/t/clang-tooling-woes-2/9640 "2020-10-25T18:21:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![laduke](https://discourse.nixos.org/user_avatar/discourse.nixos.org/laduke/32/3707_2.png) [@laduke](https://discourse.nixos.org/u/laduke)
#### Post date: [October 25, 2020, 6:21pm UTC](https://discourse.nixos.org/t/clang-tooling-woes-2/9640/1 "2020-10-25T18:21:54Z")

</div>

Hello. [older related thread here](https://discourse.nixos.org/t/clang-tooling-woes-on-nixos/2314/15)

The other thread has some wrapper work-arounds but at the end also suggests maybe it got improved in nix?

I’m trying to get a basic llvm/cmake nix-shell going. It mostly works, but clang-tidy doesn’t know where stuff is.

```
[nix-shell:~/src/cpp/hello]$ cat shell.nix
with import <nixpkgs> {};
clangStdenv.mkDerivation {
name = "env";
nativeBuildInputs = [cmake];
}

[nix-shell:~/src/cpp/hello]$ $CXX src/Hello.cpp

[nix-shell:~/src/cpp/hello]$ clang-tidy src/Hello.cpp
1 error generated.
Error while processing /Users/travis/src/cpp/hello/src/Hello.cpp.
/Users/travis/src/cpp/hello/src/hello.cpp:1:10: error: 'iostream' file not found [clang-diagnostic-error]
#include <iostream>
        ^
Found compiler error(s).

```

I’m new at nix. What approach should I take?  
If anyone has a a little llvm hello world shell.nix repo, that’d be cool.

I was getting mixed signals from discourse about whether to make a new thread or bump the old. Sorry if I chose wrong.

---

<div class="post-metadata">

### Author: ![bjornfor](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@bjornfor](https://discourse.nixos.org/u/bjornfor)
#### Post date: [October 30, 2020, 6:46pm UTC](https://discourse.nixos.org/t/clang-tooling-woes-2/9640/2 "2020-10-30T18:46:48Z")

</div>

(I think creating a new thread and linking to the old one is perfectly fine.)

I’m having problems with clang-tidy from nixpkgs too.

This is what I found so far:

- The clang-tidy you’re running there is the unwrapped one. If you explicitly add `clang-tools` to the `nativeBuildInputs` list you get the wrapped one. (Maybe it’s a packaging bug that we add the unwrapped one implicitly. Why would we ever want that?)
- With the wrapped `clang-tidy` in `$PATH`, it’ll find headers like `<iostream>`.
- The next problem is `cang-tidy` barfs on `#include <cmath>`!

Searching for the `#include <cmath>` issue lead me to [Build failure on clang/libc++ 4.0 · Issue #937 · Andersbakken/rtags · GitHub](https://github.com/Andersbakken/rtags/issues/937#issuecomment-293459813). But so far I’m unable to resolve that. I tried hacks like `export NIX_CFLAGS_COMPILE="-isystem ${libcxx}/include/c++/v1 $NIX_CFLAGS_COMPILE"`, but it didn’t work.

---

<div class="post-metadata">

### Author: ![bjornfor](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@bjornfor](https://discourse.nixos.org/u/bjornfor)
#### Post date: [October 31, 2020, 1:01pm UTC](https://discourse.nixos.org/t/clang-tooling-woes-2/9640/3 "2020-10-31T13:01:06Z")

</div>

Relevant post (and its follow up response):

> [@Nix Friday: C/C++ questions for next stream](https://discourse.nixos.org/t/nix-friday-c-c-questions-for-next-stream/9692/6):
>
> I cannot really formulate the question entirely. I’d like to make better use of the clang tooling in a nix-shell environment where I build stuff using the regular gcc + GNU libstdc++ toolchain and somehow the include paths clash to produce a lot of: In included file: no member named 'signbit' in the global namespace; did you mean '\_\_signbit'?clang(no\_member\_suggest) See: [clang-tools: teach about nix's include path · NixOS/nixpkgs@a10ef1a · GitHub](https://github.com/NixOS/nixpkgs/commit/a10ef1aa4fe62aa97859d24921f501183861b7b6#commitcomment-36463293) Despite me commenting on this I have never rea…

---

<div class="post-metadata">

### Author: ![bjornfor](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@bjornfor](https://discourse.nixos.org/u/bjornfor)
#### Post date: [October 31, 2020, 1:34pm UTC](https://discourse.nixos.org/t/clang-tooling-woes-2/9640/4 "2020-10-31T13:34:33Z")

</div>

Some more interesting stuff: [https://git.0xee.eu/0xee/nix-home/commit/080dd54b2ad0bc902db48f5a459daf0866117669](https://git.0xee.eu/0xee/nix-home/commit/080dd54b2ad0bc902db48f5a459daf0866117669) ← using that fixed it for me!

TODO: Submit PR 😄

---

<div class="post-metadata">

### Author: ![laduke](https://discourse.nixos.org/user_avatar/discourse.nixos.org/laduke/32/3707_2.png) [@laduke](https://discourse.nixos.org/u/laduke)
#### Post date: [October 31, 2020, 6:39pm UTC](https://discourse.nixos.org/t/clang-tooling-woes-2/9640/5 "2020-10-31T18:39:03Z")

</div>

Thanks! Using `clang-tools` is good enough for me for now.

---

<div class="post-metadata">

### Author: ![bjornfor](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@bjornfor](https://discourse.nixos.org/u/bjornfor)
#### Post date: [September 8, 2021, 3:58pm UTC](https://discourse.nixos.org/t/clang-tooling-woes-2/9640/6 "2021-09-08T15:58:34Z")

</div>

I think clang-tidy was fixed in [fix clangd wrapper · NixOS/nixpkgs@782cb7a · GitHub](https://github.com/NixOS/nixpkgs/commit/782cb7aea0e6ca54582483ebc1cf965c0a897f48).
