Skip to content
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

Using the llmvPkgs_15.stdenv toolchain #213144

Open
aaronmondal opened this issue Jan 28, 2023 · 6 comments
Open

Using the llmvPkgs_15.stdenv toolchain #213144

aaronmondal opened this issue Jan 28, 2023 · 6 comments
Labels
6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 9.needs: documentation

Comments

@aaronmondal
Copy link
Contributor

Hi @rrbutani. I'm trying to set up the llvmPackages_15 toolchain in a development environment for rules_ll to get a reproducible host compiler.

With a shell.nix like

pkgs.mkShell {
  buildInputs = [
    pkgs.llvmPackages_15.bintools
    pkgs.llvmPackages_15.clang
    pkgs.llvmPackages_15.compiler-rt
    pkgs.llvmPackages_15.libcxx
    pkgs.llvmPackages_15.libcxxabi
    pkgs.llvmPackages_15.libunwind
    pkgs.llvmPackages_15.lld
  ];
}

I'm having some trouble getting this toolchain to work as I want to though 😅 Either this comes from misconfiguration on my end or some issues in the nix package. I'm also finding it rather hard to find documentation on this.

  1. I can't seem to be able to encapsulate the toolchain from its gcc depencencies. First off I think its less than ideal that I'd have to run clang like
clang -stdlib=libc++ -fuse-ld=lld -rtlib=compiler-rt main.cpp

and even then I'm still seeing artifacts of -L/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0 in the linker path. I think invoking clang instead of clang++ for c++ is discouraged anyways, but clang++ does not work with these simpler options.

  1. For some reason clang++ seems to ignore -stdlib=libc++ and the host's /usr/include/c++/v1 leaks into clang++ invocations:
clang++ -stdlib=libc++ main.cpp
In file included from main.cpp:1:
In file included from /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/iostream:39:
In file included from /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/ostream:38:
In file included from /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/ios:42:
In file included from /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/bits/ios_base.h:41:
In file included from /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/bits/locale_classes.h:40:
In file included from /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/string:55:
In file included from /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/bits/basic_string.h:6608:
In file included from /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/ext/string_conversions.h:41:
/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/cstdlib:177:3: error: declaration conflicts with target of using declaration already in scope
  div(long __i, long __j) { return ldiv(__i, __j); }
  ^
/usr/include/c++/v1/stdlib.h:150:41: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
                                        ^
/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/cstdlib:145:11: note: using declaration
  using ::div;
          ^

The Clang docs encourage a pattern like this for encapsulation, but I think it should be possible to default to this behavior on the nix side:

clang++ -nostdinc++ -nostdlib++             \
          -isystem <install>/include/c++/v1 \
          -L <install>/lib                  \
          -Wl,-rpath,<install>/lib          \
          -lc++                             \
          main.cpp
  1. The default linker is ld. This seems be the case for the llvmPackages_15.stdenv as well. Would it be possible to change this default to lld on the nix package side? Otherwise one would have to use -fuse-ld=lld or $LD=ld.lld overrides which I find rather unintuitive on a pure Clang/LLVM toolchain.

  2. A similar issue seems to be true for the bintools. This is how the Make variables currently look like:

AR=ar
NM=nm
STRIP=strip
OBJCOPY=objcopy
OBJDUMP=objdump
RANLIB=ranlib
READELF=readelf

It would be nice if there was an obvious way to make these use their llvm counterparts instead without having to set this manually. I initially thought they were symlinks to the llvm variants already but it turned out that ar --help and llvm-ar --help do in fact point to different tools.

I'm kinda new to nix so I may be overlooking a few things here. It may also be relevant that I'm using Gentoo with the experimental clang profile, which is one of the very few (the only?) linux distros using clang/glibc system toolchain.

@symphorien
Copy link
Member

Note that mkShell uses the default stdenv, which comes with a gcc toolchain. Use llvmPackages_15.stdenv.mkDerivation instead. About lld, I think you may have a look at pkgsLLVM (but maybe this has to do with libc++ vs libstdc++, I'm not sure).

@aaronmondal
Copy link
Contributor Author

aaronmondal commented Jan 28, 2023

@symphorien Overriding the stdenv only seems to affect CC and CXX but not any of the other make variables. It still uses libstdc++, libgcc, libgcc_s etc.

{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d231d18e4aa5e1d00f86b4f484f9e4344538e3ea.tar.gz") {} }:

#pkgs.mkShell.override {
#  stdenv = pkgs.llvmPackages_15.stdenv;
#}

pkgs.llvmPackages_15.stdenv.mkDerivation {
  name = "env";

  buildInputs = [
    pkgs.llvmPackages_15.bintools
    pkgs.llvmPackages_15.clang
    pkgs.llvmPackages_15.compiler-rt
    pkgs.llvmPackages_15.libcxx
    pkgs.llvmPackages_15.libcxxabi
    pkgs.llvmPackages_15.libunwind
    pkgs.llvmPackages_15.lld
    pkgs.which
  ];

  shellHook = ''
echo '#include <iostream>

auto main() -> int {
    std::cout << "Hello" << std::endl;
}' > main.cpp

echo
echo FIRST_INVOCATION
echo

clang++ -v -Wl,--verbose -fuse-ld=lld main.cpp

echo
echo SECOND_INVOCATION
echo

clang++ \
    -v \
    -Wl,--verbose \
    -rtlib=compiler-rt \
    -unwindlib=libunwind \
    -nostdinc++ \
    -nostdlib++ \
    -fuse-ld=lld \
    -isystem /nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include/c++/v1 \
    -l:libc++.a \
    -lc++abi \
    main.cpp
  '';
}

In the above file, when run with nix-shell --pure, the FIRST_INVOCATION shows that basically the entire GCC toolchain is used, except for clang as compiler. The SECOND_INVOCATION seems to change at least the includes and linkage deps to the LLVM variants, but this seems awfully hacky to me.

Note that the additional libcxx include path is needed since only .../include is exported by llvmPackages_15.libcxx, but not the .../include/c++/v1.

Also note that -lc++ seems to be bugged, as it will correctly link libc++ but then raise the bogus error unable to find library -l, regardless of whether the linker is lld or ld.

FIRST_INVOCATION

clang version 15.0.7
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/x4b3ywygnx0cla63wp50cpyhrs92n7lh-clang-15.0.7/bin
Found candidate GCC installation: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0
Found candidate GCC installation: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0
Selected GCC installation: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/nix/store/x4b3ywygnx0cla63wp50cpyhrs92n7lh-clang-15.0.7/bin/clang-15" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-
backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-
errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger
-tuning=gdb -v -fcoverage-compilation-dir=/home/aaron/aaronmondal/rules_ll -nostdsysteminc -resource-dir /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/reso
urce-root -idirafter /nix/store/49zl26cmymymzzh1xqahd6cp1g10l141-glibc-2.35-224-dev/include -isystem /nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/i
nclude -isystem /nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include -isystem /nix/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include -isyst
em /nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include -isystem /nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include -isystem /nix/s
tore/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include -isystem /nix/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include -isystem /nix/store/4z58wqnr
7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include -isystem /nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include -isystem /nix/store/5awygvmavjjasnxp1
q04q106q9x316ax-libcxx-15.0.7-dev/include -isystem /nix/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include -isystem /nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2r
yz-lld-15.0.7-dev/include -isystem /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0 -isystem /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/i
nclude/c++/11.3.0/x86_64-unknown-linux-gnu -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -internal-isystem /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-u
nknown-linux-gnu/11.3.0/../../../../include/c++/11.3.0 -internal-isystem /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../.
./../../include/c++/11.3.0/x86_64-unknown-linux-gnu -internal-isystem /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../.
./../include/c++/11.3.0/backward -internal-isystem /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/include -O2 -Wformat -Wformat-security -Werr
or=format-security -fdeprecated-macro -fdebug-compilation-dir=/home/aaron/aaronmondal/rules_ll -ferror-limit 19 -fwrapv -stack-protector 2 -stack-protector-buffer-size 4 -fgn
uc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /run/user/1000/main-df3b94.o -x c++ main.c
pp
clang -cc1 version 15.0.7 based upon LLVM 15.0.7 default target x86_64-unknown-linux-gnu
ignoring duplicate directory "/nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0"
ignoring duplicate directory "/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/x86_64-unknown-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include
 /nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include
 /nix/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include
 /nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include
 /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0
 /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/include/c++/11.3.0/x86_64-unknown-linux-gnu
 /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../../include/c++/11.3.0/backward
 /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/include
 /nix/store/49zl26cmymymzzh1xqahd6cp1g10l141-glibc-2.35-224-dev/include
End of search list.
 "/nix/store/1clkc48ilspa1snkmpwj3c5k7kfbdga5-llvm-binutils-wrapper-15.0.7/bin/ld.lld" -pie --eh-frame-hdr -m elf_x86_64 -o a.out /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-
glibc-2.35-224/lib/Scrt1.o /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/crti.o /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64-unknown
-linux-gnu/11.3.0/crtbeginS.o -L/nix/store/yvrj6nxc7iyngicpd5d13pzfd6m1vari-libcxx-15.0.7/lib -L/nix/store/rr6bk84i67k8pk7nap0pzfc4pwgsk66w-libcxxabi-15.0.7/lib -L/nix/store/
60258c51xdkhcxlkr2f66armdfsdnb8c-libunwind-15.0.7/lib -L/nix/store/56gi28wli438iyhq39g8kjpbsz04s7s1-lld-15.0.7-lib/lib -L/nix/store/yvrj6nxc7iyngicpd5d13pzfd6m1vari-libcxx-15
.0.7/lib -L/nix/store/rr6bk84i67k8pk7nap0pzfc4pwgsk66w-libcxxabi-15.0.7/lib -L/nix/store/60258c51xdkhcxlkr2f66armdfsdnb8c-libunwind-15.0.7/lib -L/nix/store/56gi28wli438iyhq39
g8kjpbsz04s7s1-lld-15.0.7-lib/lib -L/nix/store/yvrj6nxc7iyngicpd5d13pzfd6m1vari-libcxx-15.0.7/lib -L/nix/store/yvrj6nxc7iyngicpd5d13pzfd6m1vari-libcxx-15.0.7/lib -L/nix/store
/rr6bk84i67k8pk7nap0pzfc4pwgsk66w-libcxxabi-15.0.7/lib -L/nix/store/rr6bk84i67k8pk7nap0pzfc4pwgsk66w-libcxxabi-15.0.7/lib -L/nix/store/60258c51xdkhcxlkr2f66armdfsdnb8c-libunw
ind-15.0.7/lib -L/nix/store/60258c51xdkhcxlkr2f66armdfsdnb8c-libunwind-15.0.7/lib -L/nix/store/56gi28wli438iyhq39g8kjpbsz04s7s1-lld-15.0.7-lib/lib -L/nix/store/56gi28wli438iy
hq39g8kjpbsz04s7s1-lld-15.0.7-lib/lib -L/nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib -L/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64
-unknown-linux-gnu/11.3.0 -L/nix/store/sq78g74zs4sj7n1j5709g9c2pmffx1y8-gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib -L/nix/store/5dr46cz3z9ggvqbxyqfa0zl7lyzj4739-clang-15.0.7
-lib/lib -L/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0 -L/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc
/x86_64-unknown-linux-gnu/11.3.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib -dynamic-linker=/nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.3
5-224/lib/ld-linux-x86-64.so.2 --verbose /run/user/1000/main-df3b94.o -rpath /nix/store/5fnassgf4rm2amqv6z23289v2qmd1xg6-env/lib64 -rpath /nix/store/5fnassgf4rm2amqv6z23289v2
qmd1xg6-env/lib -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/crtendS.o /nix/sto
re/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/crtn.o
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/Scrt1.o
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/crti.o
ld.lld: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/crtbeginS.o
ld.lld: /run/user/1000/main-df3b94.o
ld.lld: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../../lib64/libstdc++.a
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libm.so
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libm.so.6
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libmvec.so.1
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libgcc_s.so
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libgcc_s.so.1
ld.lld: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/libgcc.a
ld.lld: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/libgcc.a
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libc.so
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libc.so.6
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libc_nonshared.a
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/ld-linux-x86-64.so.2
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libgcc_s.so
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libgcc_s.so.1
ld.lld: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/libgcc.a
ld.lld: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/libgcc.a
ld.lld: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/crtendS.o
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/crtn.o

SECOND_INVOCATION

clang version 15.0.7
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/x4b3ywygnx0cla63wp50cpyhrs92n7lh-clang-15.0.7/bin
Found candidate GCC installation: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0
Found candidate GCC installation: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0
Selected GCC installation: /nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/nix/store/x4b3ywygnx0cla63wp50cpyhrs92n7lh-clang-15.0.7/bin/clang-15" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-
backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-
errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger
-tuning=gdb -v -fcoverage-compilation-dir=/home/aaron/aaronmondal/rules_ll -nostdsysteminc -nostdinc++ -resource-dir /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper
-15.0.7/resource-root -isystem /nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include/c++/v1 -idirafter /nix/store/49zl26cmymymzzh1xqahd6cp1g10l141-glibc-2.35-
224-dev/include -isystem /nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include -isystem /nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-de
v/include -isystem /nix/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include -isystem /nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include -isyst
em /nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include -isystem /nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include -isystem /ni
x/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include -isystem /nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include -isystem /nix/store/5q1pkviy
c3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include -isystem /nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include -isystem /nix/store/1zg48f5wh619b3
ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include -isystem /nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -internal-
isystem /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/include -O2 -Wformat -Wformat-security -Werror=format-security -fdeprecated-macro -fdeb
ug-compilation-dir=/home/aaron/aaronmondal/rules_ll -ferror-limit 19 -fwrapv -stack-protector 2 -stack-protector-buffer-size 4 -fgnuc-version=4.2.1 -fcxx-exceptions -fexcepti
ons -fcolor-diagnostics -vectorize-loops -vectorize-slp -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /run/user/1000/main-de9788.o -x c++ main.cpp
clang -cc1 version 15.0.7 based upon LLVM 15.0.7 default target x86_64-unknown-linux-gnu
ignoring duplicate directory "/nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include"
ignoring duplicate directory "/nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include"
#include "..." search starts here:
#include <...> search starts here:
 /nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include/c++/v1
 /nix/store/5q1pkviyc3ppiqqsxq2v2z3ka4qlnba1-compiler-rt-libc-15.0.7-dev/include
 /nix/store/5awygvmavjjasnxp1q04q106q9x316ax-libcxx-15.0.7-dev/include
 /nix/store/1zg48f5wh619b3ya1nz8id7bwcylmlx5-libcxxabi-15.0.7-dev/include
 /nix/store/4z58wqnr7mwp6ssfypad5cl6lrgf2ryz-lld-15.0.7-dev/include
 /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/include
 /nix/store/49zl26cmymymzzh1xqahd6cp1g10l141-glibc-2.35-224-dev/include
End of search list.
 "/nix/store/1clkc48ilspa1snkmpwj3c5k7kfbdga5-llvm-binutils-wrapper-15.0.7/bin/ld.lld" -pie --eh-frame-hdr -m elf_x86_64 -o a.out /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-
glibc-2.35-224/lib/Scrt1.o /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/crti.o /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-roo
t/lib/linux/clang_rt.crtbegin-x86_64.o -L/nix/store/yvrj6nxc7iyngicpd5d13pzfd6m1vari-libcxx-15.0.7/lib -L/nix/store/rr6bk84i67k8pk7nap0pzfc4pwgsk66w-libcxxabi-15.0.7/lib -L/n
ix/store/60258c51xdkhcxlkr2f66armdfsdnb8c-libunwind-15.0.7/lib -L/nix/store/56gi28wli438iyhq39g8kjpbsz04s7s1-lld-15.0.7-lib/lib -L/nix/store/yvrj6nxc7iyngicpd5d13pzfd6m1vari-
libcxx-15.0.7/lib -L/nix/store/rr6bk84i67k8pk7nap0pzfc4pwgsk66w-libcxxabi-15.0.7/lib -L/nix/store/60258c51xdkhcxlkr2f66armdfsdnb8c-libunwind-15.0.7/lib -L/nix/store/56gi28wli
438iyhq39g8kjpbsz04s7s1-lld-15.0.7-lib/lib -L/nix/store/yvrj6nxc7iyngicpd5d13pzfd6m1vari-libcxx-15.0.7/lib -L/nix/store/yvrj6nxc7iyngicpd5d13pzfd6m1vari-libcxx-15.0.7/lib -L/
nix/store/rr6bk84i67k8pk7nap0pzfc4pwgsk66w-libcxxabi-15.0.7/lib -L/nix/store/rr6bk84i67k8pk7nap0pzfc4pwgsk66w-libcxxabi-15.0.7/lib -L/nix/store/60258c51xdkhcxlkr2f66armdfsdnb
8c-libunwind-15.0.7/lib -L/nix/store/60258c51xdkhcxlkr2f66armdfsdnb8c-libunwind-15.0.7/lib -L/nix/store/56gi28wli438iyhq39g8kjpbsz04s7s1-lld-15.0.7-lib/lib -L/nix/store/56gi2
8wli438iyhq39g8kjpbsz04s7s1-lld-15.0.7-lib/lib -L/nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib -L/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib/g
cc/x86_64-unknown-linux-gnu/11.3.0 -L/nix/store/sq78g74zs4sj7n1j5709g9c2pmffx1y8-gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib -L/nix/store/5dr46cz3z9ggvqbxyqfa0zl7lyzj4739-cla
ng-15.0.7-lib/lib -L/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0 -L/nix/store/z1yw9cw97bcdfmxz5wk7j1bycw42r1mw-gcc-11.3.0/
lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib -dynamic-linker=/nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-
glibc-2.35-224/lib/ld-linux-x86-64.so.2 --verbose -l:libc++.a -lc++abi /run/user/1000/main-de9788.o -rpath /nix/store/5fnassgf4rm2amqv6z23289v2qmd1xg6-env/lib64 -rpath /nix/s
tore/5fnassgf4rm2amqv6z23289v2qmd1xg6-env/lib -lm /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/lib/linux/libclang_rt.builtins-x86_64.a --as-
needed -lunwind --no-as-needed -lc /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/lib/linux/libclang_rt.builtins-x86_64.a --as-needed -lunwind
 --no-as-needed /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/lib/linux/clang_rt.crtend-x86_64.o /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-
glibc-2.35-224/lib/crtn.o
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/Scrt1.o
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/crti.o
ld.lld: /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/lib/linux/clang_rt.crtbegin-x86_64.o
ld.lld: /nix/store/yvrj6nxc7iyngicpd5d13pzfd6m1vari-libcxx-15.0.7/lib/libc++.a
ld.lld: /nix/store/rr6bk84i67k8pk7nap0pzfc4pwgsk66w-libcxxabi-15.0.7/lib/libc++abi.so
ld.lld: /run/user/1000/main-de9788.o
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libm.so
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libm.so.6
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libmvec.so.1
ld.lld: /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/lib/linux/libclang_rt.builtins-x86_64.a
ld.lld: /nix/store/60258c51xdkhcxlkr2f66armdfsdnb8c-libunwind-15.0.7/lib/libunwind.so
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libc.so
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libc.so.6
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libc_nonshared.a
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/ld-linux-x86-64.so.2
ld.lld: /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/lib/linux/libclang_rt.builtins-x86_64.a
ld.lld: /nix/store/60258c51xdkhcxlkr2f66armdfsdnb8c-libunwind-15.0.7/lib/libunwind.so
ld.lld: /nix/store/al3wr59nslk87rh72pwvvhyijnljz7m7-clang-wrapper-15.0.7/resource-root/lib/linux/clang_rt.crtend-x86_64.o
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/crtn.o
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libpthread.so
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libpthread.so
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libpthread.so
ld.lld: /nix/store/yzjgl0h6a3qh1mby405428f16xww37h0-glibc-2.35-224/lib/libpthread.so

@symphorien
Copy link
Member

Yes, clangStdenv still uses libstdc++ on linux as otherwise things built with clangStdenv (eg chromium) could not link to libraries built with stdenv (nearly everything). pkgsLLVM is a package set containing packages built with libc++ from stdenv up, and possibly with lld, but I'm not sure. Maybe try pkgsLLVM.stdenv.mkDerivation.

@symphorien
Copy link
Member

Also don't add unwrapped toolchain parts in buildInputs this can only break stuff. The nix way is to provide a modified stdenv, but adding stuff on top of stdenv does not work.

@aaronmondal
Copy link
Contributor Author

Ok I think now I understand a bit better. I guess what I am asking for is something similar to pkgsLLVM.stdenv but, better/explicitly documented, fully LLVM based, including the smaller tools like llvm-ar etc, and compatible with more recent versions of LLVM. The current pkgsLLVM defaults to LLVM11 which is ancient and doesn't cover the entire spectrum of LLVM tools.

Since I feel like I really need this in my life, I'll try to get something like this working, but I have like 2 days of nix experience, so it may take a while until I come up with something usable 😅

@symphorien
Copy link
Member

Ah sorry I meant pkgsLLVM.llvmPackages.stdenv.mkDerivation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 9.needs: documentation
Projects
None yet
Development

No branches or pull requests

3 participants