On Fri, Mar 21, 2025 at 9:53 AM aneris via <help-guix@gnu.org> wrote:
>
> Hello Guix,
>
> I have been trying to setup a C++ development environment in Guix,
> however clangd has been very annoying.
>
> The simple hello world in C++
>
> ```
>
> #include <iostream>
>
> int main() {
>
>    std::cout << "Hello World";
>
> }
>
> ```
>
> Has clangd (in Emacs) complaining about the <iostream> line that,
>
> `clang: [unknown-typename] in included file: unknown type name
> _GLIBCXX23_CONSTEXPR`,
>
> followed by it supposedly quitting due to too many errors (it doesn't
> actually quit).
>
> Here is the compile_commands.json generated by cmake
>
> ```
>
> [
>
> {
>
>    "directory": "/home/hikari/opt/cpp/calc/build",
>
>    "command":
> "/gnu/store/l10q8ps24x4d9fdxl3iwpsg5xfs9kgnz-profile/bin/c++
> -std=gnu++20 -o CMakeFiles/calc.dir/src/main.cpp.o -c
> /home/hikari/opt/cpp/calc/src/main.cpp",
>
>    "file": "/home/hikari/opt/cpp/calc/src/main.cpp",
>
>    "output": "CMakeFiles/calc.dir/src/main.cpp.o"
>
> }
>
> ]⏎
>
> ```
>
> And the shell environment I am using
>
> ```
> (specifications->manifest
>    (list "gcc-toolchain"
>          "cmake"
>          "clang"
>          "gdb"
>          "direnv"
>          "bash"
>          "coreutils"
>          "util-linux"
>          "git"
>          "make"))
> ```
>
> Swapping gcc-toolchain out with clang-toolchain and regenerating the
> compile_commands.json doesn't do anything either. Any ideas?

Your manifest builds clang with the default version of gcc-toolchain,
currently gcc@11, so you'll need to replace "gcc-toolchain" with
"gcc-toolchain@11" in your manifest.

It's also possible to use package input rewriting, although this
currently only works up to gcc 13 and clang 18.

And the core-packages-team branch is updating the default to gcc 14,
so today you can run
    guix time-machine --branch=core-packages-team -- shell
--manifest=manifest.scm

And then with the next gcc release we'll be back to package input
rewriting (or if you are not concerned about reproducibility, you can
simply edit a checkout of the Guix codebase).

Reply via email to