Open kvark opened 2 years ago
Hi, @kvark. Thanks for the detailed output.
It looks like AFLplusplus
is failing to build.
The part that says llvm-config is not helping us
gets my attention.
Do you have the llvm tools installed? In particular, do you have an llvm-config-13
in your PATH
? (I think current stable Rust requires LLVM 13.)
Hmm, I don't have llvm-config-13
, but I do have llvm-config
:
[nix-shell:/x/code]$ llvm-config --version
13.0.0
Here is one place where things seem to be going wrong: https://github.com/AFLplusplus/AFLplusplus/blob/9321a24e682b5c8bf6278961bd014cb883b87295/GNUmakefile.llvm#L120
Could you please share the output of the following commands:
llvm-config --bindir
ls `llvm-config --bindir`
If clang
is not in the listing produced by the latter, could you try installing it, and then try installing afl.rs again?
That question lead me to the rabbit hole of LLVM and clang configuration on Nix... Sorry to be that user on a strange system!
Found https://discourse.nixos.org/t/how-to-correctly-populate-a-clang-and-llvm-development-environment-using-nix-shell/3864, which is fixed in https://github.com/NixOS/nixpkgs/pull/85489, which got... stalled.
I'm also seeing that my configuration has LIBCLANG_PATH
:
[nix-shell:/x/code]$ echo $LIBCLANG_PATH /nix/store/ny2bcqi3ldjqj0qkk2ry7a61jzx5rm3v-clang-13.0.0-lib/lib
Some other projects facing this issue and solving it by different means, like https://github.com/jacobdufault/cquery/issues/237
At this point, I don't know if it's a purely NixOS issue, or also something to be improved in the AFL build process. I'd love to have some sort of a workaround.
It should be noted that the LLVM-related messages are non-fatal diagnostics, and do not necessarily indicate that LLVM/libclang won't link just fine; the actual fatal error here is due to something unrelated hitting -Werror
, which should not be present on build scripts intended used for general distribution for this reason.
I'd love to have some sort of a workaround.
I don't know a lot about Nix. Could you just put a symlink in place to point to the real clang? E.g.,
ln -s `which clang` `llvm-config --bindir`/clang
Thanks for your comment, @Ralith. I understand your point that -Werror
should not be used in build scripts. But this appears to be in AFLplusplus's build script. So I think we're kind of stuck with it.
The issue could be pursued upstream, and a patched version used in the mean time.
Actually, the -Werror
seems to be coming from here: https://github.com/AFLplusplus/AFLplusplus/blob/9321a24e682b5c8bf6278961bd014cb883b87295/GNUmakefile#L139
@kvark Is it possible you have DEBUG=1
in your environment when you are running cargo install
?
No, echo $DEBUG
says nothing. My shell configuration is here in case it's useful.
I tried cloning https://github.com/AFLplusplus/AFLplusplus and just building it with make
under the same shell. Some warnings are spewed, but I'm not seeing "-Werror" stopping them. It fails with this:
[-] PROGRAM ABORT : Oops, failed to execute '/nix/store/pm454wwwcpa2prhk8qf8s0icbsj2fbxq-llvm-13.0.0/bin/clang' - check your PATH Location : main(), src/afl-cc.c:2146
ln -s
which clang
llvm-config --bindir
/clang
Sorry, I can't do this:
ln: failed to create symbolic link '/nix/store/pm454wwwcpa2prhk8qf8s0icbsj2fbxq-llvm-13.0.0/bin/clang': Read-only file system
Also note that clang is not found by the build regardless of whether I enable clang or not in the shell configuration with this:
nix-shell -p llvmPackages_latest.clang
Sounds like it's trying to bake in the path to the LLVM build and assumes that'll be a suitable prefix for clang, which it isn't. If it just executed clang
and let PATH
do its magic--or alternatively, baked in a path extracted by scanning PATH
at buildtime--this wouldn't be an issue.
I tried cloning https://github.com/AFLplusplus/AFLplusplus and just building it with
make
under the same shell. Some warnings are spewed, but I'm not seeing "-Werror" stopping them. It fails with this:[-] PROGRAM ABORT : Oops, failed to execute '/nix/store/pm454wwwcpa2prhk8qf8s0icbsj2fbxq-llvm-13.0.0/bin/clang' - check your PATH Location : main(), src/afl-cc.c:2146
Could share the log up to that point? Also, afl.rs currently uses commit 9321a24. Could you try with that commit specifically?
Looks relevant to https://github.com/AFLplusplus/AFLplusplus/issues/316, which is claimed to be fixed.
Here is the full log on that revision with gmp
package enabled: make.log
https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/security/aflplusplus/default.nix may also be of interest
@kvark I'll be away for about a week. I can look at this more when I get back. (Though, I hope a solution reveals itself before then.)
Thanks for your help with this, @Ralith.
I've sadly run into this as well on NixOS. Has anyone maybe found a working solution in the meantime?
The problem is that the AFLplusplus makefiles only check whether DEBUG
is set or not. But cargo always sets DEBUG
to true
or false
and so convinces AFLplusplus to build in debug mode with -Werror
set. I've made PR #248 with a minimalistic patch to build.rs
.
The clang and llvm issues seem to be entirely separate. To get a clang build on NixOS I put some dirty hacks into https://github.com/vkleen/zorn/blob/3e18f4444c9390eda6b2e0ec5e23285ecfac0a6e/flake.nix
Essentially, I'm just merging llvm, clang and lld into a single symlinked path hierarchy. Use at your own risk (I'm only hacking this together for development).
FWIW, release 0.12.5 includes @vkleen's #248.
Full log: