Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 800941 - app-forensics/aflplusplus does not detect build failure
Summary: app-forensics/aflplusplus does not detect build failure
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Sam James
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-07 00:28 UTC by Hank Leininger
Modified: 2021-09-19 07:28 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log with a GCC-only argument in CFLAGS (aflplusplus-3.13c-r1-bad_CFLAGS-build.log,32.80 KB, text/plain)
2021-07-07 00:28 UTC, Hank Leininger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hank Leininger 2021-07-07 00:28:08 UTC
Reproduced with both aflplusplus-3.12c-r3 and aflplusplus-3.13c-r1, with sys-devel/gcc-10.3.0-r1 and sys-devel/llvm-12.0.0

emerge aflplusplus does not notice (some?) build failures, and proceeds to install/qmerge an incomplete set of files. You end up with no /usr/bin/afl-{cc,c++}, and various dangling symlinks trying to point to those nonexistent files (afl-{clang,clang++,g++,g++-fast,gcc,gcc-fast).

The easy way to reproduce this is how I tripped over it: On a system with GCC as the default compiler, set something in CFLAGS that is supported by/harmless to GCC but not supported by clang. I had -freorder-blocks-and-partition in, for no good reason (since removed).

build log attached, my muddling through follows.

Building upstream out-of-the-box with a non-clang-compatible CFLAGS will cause a failure in building afl-cc right away, because it will use clang by default, which will fail, and GNUmakefile catches that:

GNUmakefile:311
llvm:
        -$(MAKE) -j -f GNUmakefile.llvm
        @test -e afl-cc || { echo "[-] Compiling afl-cc failed. You seem not to have a working compiler." ; exit 1; }

However when emerging on a Gentoo system with gcc as the default compiler, the initial compile of afl-cc succeeds. It is only later when the afl-cc wrapper is tested, that an error occurs. But that is not a fatal error:

GNUmakefile.llvm:457
test_build: $(PROGS)
        @echo "[*] Testing the CC wrapper and instrumentation output..."
        unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; ASAN_OPTIONS=detect_leaks=0 AFL_QUIET=1 AFL_PATH=. AFL_LLVM_LAF_ALL=1 ./afl-cc $(CFLAGS) $(CPPFLAGS) ./test-instr.c -o test-instr $(LDFLAGS)
...

So the result is like:

[*] Testing the CC wrapper and instrumentation output...
unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; ASAN_OPTIONS=detect_leaks=0 AFL_QUIET=1 AFL_PATH=. AFL_LLVM_LAF_ALL=1 ./afl-cc -march=znver2 -freorder-blocks-and-partition -O2 -pipe -msse4.1 -msse4.2 -msse4 -mavx -g -Wno-pointer-sign -Wno-variadic-macros -Wall -Wextra -Wpointer-arith -I include/ -DAFL_PATH=\"/usr/lib64/afl\" -DBIN_PATH=\"/usr/bin\" -DDOC_PATH=\"/usr/share/doc/aflplusplus-3.13c-r1\" -D_FORTIFY_SOURCE=2 -Wall -g -Wno-cast-qual -Wno-variadic-macros -Wno-pointer-sign -I ./include/ -I ./instrumentation/ -DAFL_PATH=\"/usr/lib64/afl\" -DBIN_PATH=\"/usr/bin\" -DLLVM_BINDIR=\"/usr/lib/llvm/12/bin\" -DVERSION=\"++3.13c\" -DLLVM_LIBDIR=\"/usr/lib/llvm/12/lib64\" -DLLVM_VERSION=\"12.0.0\" -Wno-deprecated -DAFL_CLANG_FLTO=\"\" -DAFL_REAL_LD=\"\" -DAFL_CLANG_LDPATH=\"\" -DAFL_CLANG_FUSELD=\"\" -DCLANG_BIN=\"/usr/lib/llvm/12/bin/clang\" -DCLANGPP_BIN=\"/usr/lib/llvm/12/bin/clang++\" -DUSE_BINDIR=1 -Wno-unused-function -fdebug-prefix-map="/var/tmp/portage/app-forensics/aflplusplus-3.13c-r1/work/AFLplusplus-3.13c=llvm_mode"  ./test-instr.c -o test-instr -Wl,-O1 -Wl,--as-needed -ldl -lrt -lm
clang-12: ^[[0;1;31merror: ^[[0m^[[1munknown argument: '-freorder-blocks-and-partition'^[[0m
make[1]: *** [GNUmakefile.llvm:459: test_build] Error 1
make[1]: Leaving directory '/var/tmp/portage/app-forensics/aflplusplus-3.13c-r1/work/AFLplusplus-3.13c'
make: [GNUmakefile:312: llvm] Error 2 (ignored)
make -f GNUmakefile.gcc_plugin
make[1]: Entering directory '/var/tmp/portage/app-forensics/aflplusplus-3.13c-r1/work/AFLplusplus-3.13c'
...

And you end up with the incomplete set of files installed.

If I try to build upstream with 'make CC=gcc CX=g++' I a similar behavior as emerge - initial afl-cc compile using GCC succeeds, but then attempts to use that binary with bad CFLAGS causes errors, which are not caught as fatal by the build system, and 'install'ing skips the bad files but does not report failure. But I don't know if this should actually be reported to upstream, since they'd likely just say we were doing it wrong.

Full build log attached.
Comment 1 Hank Leininger 2021-07-07 00:28:48 UTC
Created attachment 722482 [details]
build.log with a GCC-only argument in CFLAGS
Comment 2 Larry the Git Cow gentoo-dev 2021-09-19 07:28:40 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6e00fd395a9b52480e6d0162f953249811620ad9

commit 6e00fd395a9b52480e6d0162f953249811620ad9
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2021-09-19 07:28:03 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-09-19 07:28:32 +0000

    app-forensics/aflplusplus: detect failure in makefiles
    
    Closes: https://bugs.gentoo.org/800941
    Signed-off-by: Sam James <sam@gentoo.org>

 ...3.14c-r1.ebuild => aflplusplus-3.14c-r2.ebuild} |  2 +-
 ...lplusplus-3.14c-no-ignore-errors-makefile.patch | 62 ++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)