You are not logged in.
I am trying to fuzz wireshark using afl and its clang-fast instrumentation.
cmake fails immediately when verifying the compiler, but I do not understand what is wrong with the toolchain. Everything works for the related afl-clang toolchain.
How do I debug what is wrong with my configuration?
This is how I run cmake with afl-clang-fast:
$ git clone --single-branch -b wireshark-4.0.4 --depth 1 https://github.com/wireshark/wireshark.git
$ cd wireshark
$ mkdir build && cd build
$ cmake -DBUILD_wireshark=OFF -DCMAKE_C_COMPILER=afl-clang-fast -DCMAKE_CXX_COMPILER=afl-clang-fast++ -DCMAKE_BUILD_TYPE=Debug --debug-trycompile ..
debug trycompile on
-- The C compiler identification is Clang 14.0.6
-- The CXX compiler identification is Clang 14.0.6
-- Detecting C compiler ABI info
CMake Debug Log at /usr/share/cmake/Modules/CMakeDetermineCompilerABI.cmake:57 (try_compile):
Executing try_compile (CMAKE_C_ABI_COMPILED) in:
/tmp/wireshark/build/CMakeFiles/CMakeScratch/TryCompile-sS2Z9K
Call Stack (most recent call first):
/usr/share/cmake/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
CMakeLists.txt:39 (project)
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/afl-clang-fast
CMake Debug Log at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:56 (try_compile):
Executing try_compile (CMAKE_C_COMPILER_WORKS) in:
/tmp/wireshark/build/CMakeFiles/CMakeScratch/TryCompile-bIaDWo
Call Stack (most recent call first):
CMakeLists.txt:39 (project)
-- Check for working C compiler: /usr/bin/afl-clang-fast - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:70 (message):
The C compiler
"/usr/bin/afl-clang-fast"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /tmp/wireshark/build/CMakeFiles/CMakeScratch/TryCompile-bIaDWo
Run Build Command(s):/usr/bin/make -f Makefile cmTC_4e63b/fast && /usr/bin/make -f CMakeFiles/cmTC_4e63b.dir/build.make CMakeFiles/cmTC_4e63b.dir/build
make[1]: Entering directory '/tmp/wireshark/build/CMakeFiles/CMakeScratch/TryCompile-bIaDWo'
Building C object CMakeFiles/cmTC_4e63b.dir/testCCompiler.c.o
/usr/bin/afl-clang-fast -MD -MT CMakeFiles/cmTC_4e63b.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_4e63b.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_4e63b.dir/testCCompiler.c.o -c /tmp/wireshark/build/CMakeFiles/CMakeScratch/TryCompile-bIaDWo/testCCompiler.c
Linking C executable cmTC_4e63b
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4e63b.dir/link.txt --verbose=1
/usr/bin/afl-clang-fast CMakeFiles/cmTC_4e63b.dir/testCCompiler.c.o -o cmTC_4e63b
/usr/lib/afl/afl-llvm-rt.o: file not recognized: file format not recognized
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [CMakeFiles/cmTC_4e63b.dir/build.make:100: cmTC_4e63b] Error 1
make[1]: Leaving directory '/tmp/wireshark/build/CMakeFiles/CMakeScratch/TryCompile-bIaDWo'
make: *** [Makefile:127: cmTC_4e63b/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:39 (project)
-- Configuring incomplete, errors occurred!
See also "/tmp/wireshark/build/CMakeFiles/CMakeOutput.log".
See also "/tmp/wireshark/build/CMakeFiles/CMakeError.log".
And this is the output when running that last command with the suggested -v
$ cd /tmp/wireshark/build/CMakeFiles/CMakeScratch/TryCompile-bIaDWo
$ /usr/bin/afl-clang-fast CMakeFiles/cmTC_4e63b.dir/testCCompiler.c.o -o cmTC_4e63b -v
afl-clang-fast 2.57b by <lszekeres@google.com>
clang version 14.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm14/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
"/usr/bin/ld" -pie --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTC_4e63b /usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../lib64/Scrt1.o /usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1/crtbeginS.o -L/usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib CMakeFiles/cmTC_4e63b.dir/testCCompiler.c.o /usr/lib/afl/afl-llvm-rt.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1/crtendS.o /usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../lib64/crtn.o
/usr/lib/afl/afl-llvm-rt.o: file not recognized: file format not recognized
Related packages I have installed
$ pacman -Q | grep -E 'llvm|gcc|afl'
afl 2.57b-13
gcc 12.2.1-2
gcc-libs 12.2.1-2
lib32-gcc-libs 12.2.1-2
llvm 15.0.7-2
llvm-libs 15.0.7-2
llvm14 14.0.6-3
llvm14-libs 14.0.6-3
Offline