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

llvmPackages.clangUseLLVM cannot find libunwind.so #201591

Open
SharzyL opened this issue Nov 17, 2022 · 9 comments
Open

llvmPackages.clangUseLLVM cannot find libunwind.so #201591

SharzyL opened this issue Nov 17, 2022 · 9 comments
Labels
0.kind: bug Something is broken 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related

Comments

@SharzyL
Copy link
Contributor

SharzyL commented Nov 17, 2022

Describe the bug

When using llvmPackages.clangUseLLVM to compile, the linker cannot find libunwind.so.

Steps To Reproduce

Steps to reproduce the behavior:

$ echo "int main() { }" > a.c
$ nix shell nixpkgs#llvmPackages.clangUseLLVM -c clang /tmp/a.c
/nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld: cannot find -l:libunwind.so: No such file or directory
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

Expected behavior

The linker should be able to find libunwind and compile successfully.

Additional context

Run with NIX_DEBUG=1 gives the following:

$ NIX_DEBUG=1 nix shell nixpkgs#llvmPackages.clangUseLLVM -c clang a.c
HARDENING: disabled flags: pie pic format stackprotector fortify strictoverflow
extra flags before to /nix/store/39yzdj9a7l8aw317l8la4kp6aalczsq7-clang-11.1.0/bin/clang:
  -Wl\,-dynamic-linker=/nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/ld-linux-x86-64.so.2
  -target
  x86_64-unknown-linux-gnu
original flags to /nix/store/39yzdj9a7l8aw317l8la4kp6aalczsq7-clang-11.1.0/bin/clang:
  a.c
extra flags after to /nix/store/39yzdj9a7l8aw317l8la4kp6aalczsq7-clang-11.1.0/bin/clang:
  -B/nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/
  -idirafter
  /nix/store/4pqv2mwdn88h7xvsm7a5zplrd8sxzvw0-glibc-2.35-163-dev/include
  --gcc-toolchain=/nix/store/1gf2flfqnpqbr1b4p4qz2f72y42bs56r-gcc-11.3.0
  -B/nix/store/fbc6m1s0638pf3vk5wgmcsbap8f04nar-clang-11.1.0-lib/lib
  -rtlib=compiler-rt
  -Wno-unused-command-line-argument
  -B/nix/store/lkckixdqkvwscdr5jf0v07w77lhlm70f-compiler-rt-libc-11.1.0/lib
  --unwindlib=libunwind
  -resource-dir=/nix/store/6bmyzky9i7rd2dp3lxc47rlabrhcl46y-clang-wrapper-11.1.0/resource-root
  -B
  /nix/store/6bmyzky9i7rd2dp3lxc47rlabrhcl46y-clang-wrapper-11.1.0/resource-root/lib
  -B/nix/store/6bmyzky9i7rd2dp3lxc47rlabrhcl46y-clang-wrapper-11.1.0/bin/
  -L/nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib
  -L/nix/store/fbc6m1s0638pf3vk5wgmcsbap8f04nar-clang-11.1.0-lib/lib
HARDENING: disabled flags: relro pie bindnow
extra flags before to /nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld:
  ''
original flags to /nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld:
  --eh-frame-hdr
  -m
  elf_x86_64
  -o
  a.out
  /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/crt1.o
  /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/crti.o
  /nix/store/6bmyzky9i7rd2dp3lxc47rlabrhcl46y-clang-wrapper-11.1.0/resource-root/lib/linux/clang_rt.crtbegin-x86_64.o
  -L/nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib
  -L/nix/store/fbc6m1s0638pf3vk5wgmcsbap8f04nar-clang-11.1.0-lib/lib
  -L/nix/store/1gf2flfqnpqbr1b4p4qz2f72y42bs56r-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0
  -L/nix/store/1gf2flfqnpqbr1b4p4qz2f72y42bs56r-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../../lib64
  -L/nix/store/1gf2flfqnpqbr1b4p4qz2f72y42bs56r-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../..
  -dynamic-linker=/nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/ld-linux-x86-64.so.2
  /tmp/a-804f0d.o
  /nix/store/6bmyzky9i7rd2dp3lxc47rlabrhcl46y-clang-wrapper-11.1.0/resource-root/lib/linux/libclang_rt.builtins-x86_64.a
  --as-needed
  -l:libunwind.so
  --no-as-needed
  -lc
  /nix/store/6bmyzky9i7rd2dp3lxc47rlabrhcl46y-clang-wrapper-11.1.0/resource-root/lib/linux/libclang_rt.builtins-x86_64.a
  --as-needed
  -l:libunwind.so
  --no-as-needed
  /nix/store/6bmyzky9i7rd2dp3lxc47rlabrhcl46y-clang-wrapper-11.1.0/resource-root/lib/linux/clang_rt.crtend-x86_64.o
  /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/crtn.o
extra flags after to /nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld:
  -rpath
  /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib
/nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin/ld: cannot find -l:libunwind.so: No such file or directory
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

It is clear that the path of libunwind is not added to search path. Maybe we should add -L${targetLlvmLibraries.libunwind}/lib in nixSupport.cc-cflags.

clangUseLLVM = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
bintools = bintools';
extraPackages = [
targetLlvmLibraries.libcxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
];
extraBuildCommands = mkExtraBuildCommands cc;
nixSupport.cc-cflags =
[ "-rtlib=compiler-rt"
"-Wno-unused-command-line-argument"
"-B${targetLlvmLibraries.compiler-rt}/lib"
]
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
++ lib.optional
(!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false)
"-lunwind"
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
};

Notify maintainers

@Ericson2314 @primeos

Metadata

  • system: "x86_64-linux"
  • host os: Linux 6.0.8, NixOS, 22.11 (Raccoon), 22.11pre-git
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.11.0
  • channels(root): "nixos-22.05"
  • channels(sharzy): "nixos, nixpkgs"
  • nixpkgs: /home/sharzy/.nix-defexpr/channels/nixpkgs
@pwaller
Copy link
Contributor

pwaller commented Oct 14, 2023

I agree with this fix. I think it the same treatment is also needed for libc++ and libstdc++?

RaitoBezarius added a commit that referenced this issue Jan 13, 2024
llvmPackages_*.clangUseLLVM: add libunwind to lib search path (#201591)
@JustAnotherCodemonkey
Copy link

In spite of the PR, this is still an issue for me:

$ clang -fuse-ld=lld  test.c
ld.lld: error: unable to find library -lunwind
ld.lld: error: unable to find library -lunwind
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

@SharzyL
Copy link
Contributor Author

SharzyL commented Mar 12, 2024

In spite of the PR, this is still an issue for me:

$ clang -fuse-ld=lld  test.c
ld.lld: error: unable to find library -lunwind
ld.lld: error: unable to find library -lunwind
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

How to reproduce this?

@JustAnotherCodemonkey
Copy link

In spite of the PR, this is still an issue for me:

$ clang -fuse-ld=lld  test.c
ld.lld: error: unable to find library -lunwind
ld.lld: error: unable to find library -lunwind
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

How to reproduce this?

Have the following in your configuration.nix for your system packages:

clang-tools
llvmPackages.clangUseLLVM
llvmPackages.bintools

Clang a c file. It gives and error. Clang a c file with -fuse-ld=lld and it gives the above error

@SharzyL
Copy link
Contributor Author

SharzyL commented Mar 17, 2024

Have the following in your configuration.nix for your system packages:

clang-tools
llvmPackages.clangUseLLVM
llvmPackages.bintools

Clang a c file. It gives and error. Clang a c file with -fuse-ld=lld and it gives the above error

@JustAnotherCodemonkey Sorry but I failed to reproduce this, clang compiles without error on my machine. Could you provide the commit of your nixpkgs, the running platform, and a debug trace by running NIX_DEBUG=1 clang -fuse-ld=lld -v a.c.

@JustAnotherCodemonkey
Copy link

JustAnotherCodemonkey commented Mar 18, 2024

Have the following in your configuration.nix for your system packages:

clang-tools
llvmPackages.clangUseLLVM
llvmPackages.bintools

Clang a c file. It gives and error. Clang a c file with -fuse-ld=lld and it gives the above error

@JustAnotherCodemonkey Sorry but I failed to reproduce this, clang compiles without error on my machine. Could you provide the commit of your nixpkgs, the running platform, and a debug trace by running NIX_DEBUG=1 clang -fuse-ld=lld -v a.c.

@SharzyL

$ NIX_DEBUG=1 clang -fuse-ld=lld -v tester.c
HARDENING: disabled flags: pie pic format stackprotector fortify strictoverflow
extra flags before to /nix/store/pw7xsl0b4g7izz8hq2s5zkying2i7a4g-clang-16.0.6/bin/clang:
  -Wl\,-dynamic-linker=/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/ld-linux-x86-64.so.2
  -target
  x86_64-unknown-linux-gnu
original flags to /nix/store/pw7xsl0b4g7izz8hq2s5zkying2i7a4g-clang-16.0.6/bin/clang:
  -fuse-ld=lld
  -v
  tester.c
extra flags after to /nix/store/pw7xsl0b4g7izz8hq2s5zkying2i7a4g-clang-16.0.6/bin/clang:
  -B/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/
  -idirafter
  /nix/store/zzwrkd2n3blr2m5ydm6236kbisvldj73-glibc-2.38-44-dev/include
  --gcc-toolchain=/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0
  -B/nix/store/nzfgg5hbc3v4qisqj0ah9wdrbfszgfin-clang-16.0.6-lib/lib
  -resource-dir=/nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root
  -rtlib=compiler-rt
  -Wno-unused-command-line-argument
  -B/nix/store/8yp6irxxi36xqdfshbqgssv37zcplafy-compiler-rt-libc-16.0.6/lib
  --unwindlib=libunwind
  -B/nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/bin/
  -L/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib
  -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0//lib
  -L/nix/store/l0ydz31lwa97zickpsxj2vmprcigh1m4-gcc-12.3.0-libgcc/lib
  -L/nix/store/nzfgg5hbc3v4qisqj0ah9wdrbfszgfin-clang-16.0.6-lib/lib
clang version 16.0.6
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/pw7xsl0b4g7izz8hq2s5zkying2i7a4g-clang-16.0.6/bin
Found candidate GCC installation: /nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib/gcc/x86_64-unknown-linux-gnu/12.3.0
Found candidate GCC installation: /nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib64/gcc/x86_64-unknown-linux-gnu/12.3.0
Selected GCC installation: /nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib64/gcc/x86_64-unknown-linux-gnu/12.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/nix/store/pw7xsl0b4g7izz8hq2s5zkying2i7a4g-clang-16.0.6/bin/clang-16" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name tester.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -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/sophiaw -nostdsysteminc -resource-dir /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root -idirafter /nix/store/zzwrkd2n3blr2m5ydm6236kbisvldj73-glibc-2.38-44-dev/include -internal-isystem /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/include -Wno-unused-command-line-argument -fdebug-compilation-dir=/home/sophiaw -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/tester-d91761.o -x c tester.c
clang -cc1 version 16.0.6 based upon LLVM 16.0.6 default target x86_64-unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/include
 /nix/store/zzwrkd2n3blr2m5ydm6236kbisvldj73-glibc-2.38-44-dev/include
End of search list.
 "/etc/profiles/per-user/sophiaw/bin/ld.lld" -pie --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -o a.out /nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/Scrt1.o /nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/crti.o /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/clang_rt.crtbegin-x86_64.o -L/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0//lib -L/nix/store/l0ydz31lwa97zickpsxj2vmprcigh1m4-gcc-12.3.0-libgcc/lib -L/nix/store/nzfgg5hbc3v4qisqj0ah9wdrbfszgfin-clang-16.0.6-lib/lib -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib64/gcc/x86_64-unknown-linux-gnu/12.3.0 -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib64/gcc/x86_64-unknown-linux-gnu/12.3.0/../../../../lib64 -dynamic-linker=/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/ld-linux-x86-64.so.2 /tmp/tester-d91761.o /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/libclang_rt.builtins-x86_64.a --as-needed -lunwind --no-as-needed -lc /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/libclang_rt.builtins-x86_64.a --as-needed -lunwind --no-as-needed /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/clang_rt.crtend-x86_64.o /nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/crtn.o
HARDENING: disabled flags: relro pie bindnow
extra flags before to /nix/store/d6ini38wpv8f7ikkzj9bm15fqarfx9q5-llvm-binutils-16.0.6/bin/ld.lld:
  ''
original flags to /nix/store/d6ini38wpv8f7ikkzj9bm15fqarfx9q5-llvm-binutils-16.0.6/bin/ld.lld:
  -pie
  --hash-style=gnu
  --eh-frame-hdr
  -m
  elf_x86_64
  -o
  a.out
  /nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/Scrt1.o
  /nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/crti.o
  /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/clang_rt.crtbegin-x86_64.o
  -L/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib
  -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0//lib
  -L/nix/store/l0ydz31lwa97zickpsxj2vmprcigh1m4-gcc-12.3.0-libgcc/lib
  -L/nix/store/nzfgg5hbc3v4qisqj0ah9wdrbfszgfin-clang-16.0.6-lib/lib
  -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib64/gcc/x86_64-unknown-linux-gnu/12.3.0
  -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib64/gcc/x86_64-unknown-linux-gnu/12.3.0/../../../../lib64
  -dynamic-linker=/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/ld-linux-x86-64.so.2
  /tmp/tester-d91761.o
  /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/libclang_rt.builtins-x86_64.a
  --as-needed
  -lunwind
  --no-as-needed
  -lc
  /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/libclang_rt.builtins-x86_64.a
  --as-needed
  -lunwind
  --no-as-needed
  /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/clang_rt.crtend-x86_64.o
  /nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/crtn.o
extra flags after to /nix/store/d6ini38wpv8f7ikkzj9bm15fqarfx9q5-llvm-binutils-16.0.6/bin/ld.lld:
  -rpath
  /nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib
ld.lld: error: unable to find library -lunwind
ld.lld: error: unable to find library -lunwind
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

How do I get the commit of my nixpkgs? I tried sudo nix-channel --update and it still doesn't work.

@AregevDev
Copy link

AregevDev commented Mar 20, 2024

I'm having the same issue with llvmPackages, both 16 and 17. I am using WSL2

[nixos@nixos:~]$ NIX_DEBUG=1 clang -fuse-ld=lld -v main.c
HARDENING: disabled flags: pie pic format stackprotector fortify strictoverflow
extra flags before to /nix/store/pw7xsl0b4g7izz8hq2s5zkying2i7a4g-clang-16.0.6/bin/clang:
  -Wl\,-dynamic-linker=/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/ld-linux-x86-64.so.2
  -target
  x86_64-unknown-linux-gnu
original flags to /nix/store/pw7xsl0b4g7izz8hq2s5zkying2i7a4g-clang-16.0.6/bin/clang:
  -fuse-ld=lld
  -v
  main.c
extra flags after to /nix/store/pw7xsl0b4g7izz8hq2s5zkying2i7a4g-clang-16.0.6/bin/clang:
  -B/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/
  -idirafter
  /nix/store/zzwrkd2n3blr2m5ydm6236kbisvldj73-glibc-2.38-44-dev/include
  --gcc-toolchain=/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0
  -B/nix/store/nzfgg5hbc3v4qisqj0ah9wdrbfszgfin-clang-16.0.6-lib/lib
  -resource-dir=/nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root
  -rtlib=compiler-rt
  -Wno-unused-command-line-argument
  -B/nix/store/8yp6irxxi36xqdfshbqgssv37zcplafy-compiler-rt-libc-16.0.6/lib
  --unwindlib=libunwind
  -B/nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/bin/
  -L/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib
  -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0//lib
  -L/nix/store/l0ydz31lwa97zickpsxj2vmprcigh1m4-gcc-12.3.0-libgcc/lib
  -L/nix/store/nzfgg5hbc3v4qisqj0ah9wdrbfszgfin-clang-16.0.6-lib/lib
clang version 16.0.6
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/pw7xsl0b4g7izz8hq2s5zkying2i7a4g-clang-16.0.6/bin
Found candidate GCC installation: /nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib/gcc/x86_64-unknown-linux-gnu/12.3.0
Found candidate GCC installation: /nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib64/gcc/x86_64-unknown-linux-gnu/12.3.0
Selected GCC installation: /nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib64/gcc/x86_64-unknown-linux-gnu/12.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/nix/store/pw7xsl0b4g7izz8hq2s5zkying2i7a4g-clang-16.0.6/bin/clang-16" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -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/nixos -nostdsysteminc -resource-dir /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root -idirafter /nix/store/zzwrkd2n3blr2m5ydm6236kbisvldj73-glibc-2.38-44-dev/include -internal-isystem /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/include -Wno-unused-command-line-argument -fdebug-compilation-dir=/home/nixos -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/main-2c50d0.o -x c main.c
clang -cc1 version 16.0.6 based upon LLVM 16.0.6 default target x86_64-unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/include
 /nix/store/zzwrkd2n3blr2m5ydm6236kbisvldj73-glibc-2.38-44-dev/include
End of search list.
 "/run/current-system/sw/bin/ld.lld" -pie --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -o a.out /nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/Scrt1.o /nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/crti.o /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/clang_rt.crtbegin-x86_64.o -L/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0//lib -L/nix/store/l0ydz31lwa97zickpsxj2vmprcigh1m4-gcc-12.3.0-libgcc/lib -L/nix/store/nzfgg5hbc3v4qisqj0ah9wdrbfszgfin-clang-16.0.6-lib/lib -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib64/gcc/x86_64-unknown-linux-gnu/12.3.0 -L/nix/store/fdiknsmnnczx6brsbppyljcs9hqckawk-gcc-12.3.0/lib64/gcc/x86_64-unknown-linux-gnu/12.3.0/../../../../lib64 -L/lib -L/usr/lib -dynamic-linker=/nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/ld-linux-x86-64.so.2 /tmp/main-2c50d0.o /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/libclang_rt.builtins-x86_64.a --as-needed -lunwind --no-as-needed -lc /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/libclang_rt.builtins-x86_64.a --as-needed -lunwind --no-as-needed /nix/store/32wbjm8xlndqkgx4rnk3r699aj8kcfn2-clang-wrapper-16.0.6/resource-root/lib/linux/clang_rt.crtend-x86_64.o /nix/store/1zy01hjzwvvia6h9dq5xar88v77fgh9x-glibc-2.38-44/lib/crtn.o
ld.lld: error: unable to find library -lunwind
ld.lld: error: unable to find library -lunwind
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

Seems like the libunwind isn't included in the library search paths

@AregevDev
Copy link

AregevDev commented Mar 23, 2024

No matter what LLVM package version I use, there's no -L flag to libunwind's location. Manually adding it to the /nix/store location works ofc.

@rrbutani rrbutani added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label May 27, 2024
@pwaller
Copy link
Contributor

pwaller commented Jun 16, 2024

Hey folks, I believe this was fixed in 555c7d1 as @SharzyL was suggesting. At least, I cannot reproduce here on my x86_64-linux. Prior to that commit I get the error you report building a test.c, after that commit, using clang to build something works.

You can test a specific nixpkgs commit using this command, which reports an error (or doesn't show libunwind) if there is an issue.

$ nix eval --json nixpkgs/555c7d1ba153b738356518ab1cfce4342582c3e5#llvmPackages_17.clangUseLLVM.nixSupport.cc-ldflags
["-L/nix/store/w3fpiryzpl7gdfskr754c5gkk3sm8qki-libunwind-17.0.6/lib"]

I think this can be closed, or at least it needs more information about what is being tested precisely (nixpkgs commit in particular).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related
Projects
None yet
Development

No branches or pull requests

5 participants