Open Whovian9369 opened 10 months ago
This doesn't seem to be specific to llvmPackages_17
, as replacing it with llvmPackages_16
doesn't help.
You need llvmPackages_17.libcxxStdenv.mkDerivation
, because Redumper hardcodes -stdlib=libc++
inside CMakeLists.txt
when it detects that Clang is used as a C++ compiler.
Thanks, I'll test that for my specific issue. I'll leave this open as I'm personally unsure if it is "enough" to close as user error.
I just tried it myself and it doesn't help. But I found this related upstream bug: https://github.com/llvm/llvm-project/issues/61006
You need
llvmPackages_17.libcxxStdenv.mkDerivation
, because Redumper hardcodes-stdlib=libc++
insideCMakeLists.txt
when it detects that Clang is used as a C++ compiler.
Can you please elaborate on the hardcoding part? Is there a better way to specify a C++ runtime library?
I ran into this precise problem while also trying to package redumper
myself yesterday and running into a brick wall.
The issue linked by @hmenke suggests specifying the includes manually, but I wouldn't know how to do that on NixOS (and with my extremely minimal cmake/gcc/clang knowledge). Did you manage to get this working @Whovian9369? Is there anything @superg can do to help us with this?
Did you manage to get this working @Whovian9369?
Haven't tried anything more since, no. If you want to talk about this at all and use Discord, please feel free to send me a friend request on Discord, @romatthe !
This seems to be a nix issue with the wrapper. The same llvm packages end up working on ubuntu.
I just tested this, and it seems to still be occurring when using: llvmPackages_18.stdenv.mkDerivation
, nativeBuildInputs = [ cmake ninja clang_18 ];
Said log: 27naig5iqc1d71hss2ybghd2lxg3sx9k-redumper-git-371.drv.log
Even compiling something simple like a hello world through cmake doesn't work when you use libcxx llvm stdenv, it seems to be a problem with the dependency scanner. You can work around it by manually specifying the headers in the build flags but that is awful.
Possible related issues: https://github.com/NixOS/nixpkgs/issues/277564 https://github.com/NixOS/nixpkgs/issues/191152
cc @qyriad because i know you were complaining about the cc wrapper assuming libstdc++ on non-macOS.
cc @RossComputerGuy
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/clang-cannot-locate-c-std-headers/51095/1
I think I figured out the problem. I had to explicitly pass includes for glibc
's include dir and a C++ stdlib impl header directory. Using NIX_CFLAGS_COMPILE
or other similar arguments was not good enough. This might mean that we will have to wrap clang-scan-deps
.
There's already a wrapped clang-scan-deps
in llvmPackages.clang-tools
. Adding it to nativeBuildInputs
fixes the issue.
Seems I'm late to the redumper
packaging party.
@leo60228 am I to understand that you are able to build it? As below my clangStdenv still has library path issues (same if I use GNU ld)
Running phase: buildPhase
[1/190] Scanning /build/source/generate_offsets.cc for CXX dependencies
warning: argument unused during compilation: '-fuse-ld=lld'
warning: argument unused during compilation: '-stdlib=libc++'
[3/190] Building CXX object CMakeFiles/generate_offsets.dir/generate_offsets.cc.o
clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
clang++: warning: argument unused during compilation: '-stdlib=libc++' [-Wunused-command-line-argument]
[12/190] Linking CXX executable generate_offsets/Threads.c.oK
FAILED: generate_offsets
: && /nix/store/4rz4z2bkb68vwbdxcwq0jxh2fyhhiqkh-clang-wrapper-18.1.8/bin/clang++ -fuse-ld=lld -O2 -g -DNDEBUG -stdlib=libc++ -static CMakeFiles/generate_offsets.dir/generate_offsets.cc.o -o generate_offsets && :
ld.lld: error: unable to find library -lc++
ld.lld: error: unable to find library -lm
ld.lld: error: unable to find library -lc
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
error: builder for '/nix/store/w50715li5j8rdv7yv51gdm92fqyw4swa-redumper-415.drv' failed with exit code 1;
last 10 log lines:
> clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
> clang++: warning: argument unused during compilation: '-stdlib=libc++' [-Wunused-command-line-argument]
> [12/190] Linking CXX executable generate_offsets/Threads.c.oK
> FAILED: generate_offsets
> : && /nix/store/4rz4z2bkb68vwbdxcwq0jxh2fyhhiqkh-clang-wrapper-18.1.8/bin/clang++ -fuse-ld=lld -O2 -g -DNDEBUG -stdlib=libc++ -static CMakeFiles/generate_offsets.dir/generate_offsets.cc.o -o generate_offsets && :
> ld.lld: error: unable to find library -lc++
> ld.lld: error: unable to find library -lm
> ld.lld: error: unable to find library -lc
> clang++: error: linker command failed with exit code 1 (use -v to see invocation)
> ninja: build stopped: subcommand failed.
For full logs, run 'nix log /nix/store/w50715li5j8rdv7yv51gdm92fqyw4swa-redumper-415.drv'.
Describe the bug
When trying to build some software, build is unable to complete due to missing headers.
Steps To Reproduce
Steps to reproduce the behavior:
clang_17
andllvmPackages_17.stdenv.mkDerivation
on project that requires it.nix build
.Expected behavior
clang
to find the std headers.Additional context
I've been trying to build Redumper for my own testing, and have been unable to build it successfully. Here is a log of the build, with
NIX_CFLAGS_COMPILE="-v"
: 061glri5zp3s9rlis00vyj9pcbpcqd2x-redumper-build_297.drv.logClick to open derivation used for testing:
```nix { lib , llvmPackages_17 , fetchFromGitHub , cmake , ninja , clang_17 , build_type ? "Release" # Typical values include `Debug`, `Release`, `RelWithDebInfo` and `MinSizeRel` # Usually set to "Release" for GitHub Actions use, so that's what it's set to by default here. }: llvmPackages_17.stdenv.mkDerivation rec { pname = "redumper"; version = "build_297"; src = fetchFromGitHub { owner = "superg"; repo = "redumper"; rev = version; hash = "sha256-AOuWkdFT8e/aEvvORcAtLHPFgRUzFsZ86VIddEOyts4="; }; nativeBuildInputs = [ cmake ninja clang_17 # Should alias to `llvmPackages_17.clang` ]; env.NIX_CFLAGS_COMPILE = "-v"; env.gh_run_version = "297"; cmakeFlags = [ "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" "-DREDUMPER_CLANG_LINK_OPTIONS=-static" "-DREDUMPER_VERSION_BUILD=$gh_run_version" ]; meta = with lib; { description = "Low level CD dumper utility"; homepage = "https://github.com/superg/redumper"; license = licenses.gpl3Only; maintainers = with maintainers; [ whovian9369 ]; mainProgram = "redumper"; platforms = platforms.all; }; } ```Notify maintainers
@dtzWill @Ericson2314 @lovek323 @primeos @alyssais @RaitoBezarius @rrbutani @sternenseemann
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Add a :+1: reaction to issues you find important.