Skip to content

Instantly share code, notes, and snippets.

@mcandre
Last active September 24, 2021 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcandre/f03cbbf6def5a85b61a33dbd1602de17 to your computer and use it in GitHub Desktop.
Save mcandre/f03cbbf6def5a85b61a33dbd1602de17 to your computer and use it in GitHub Desktop.
cmake build error log
$ conan install -s compiler.cppstd=17 -s compiler=clang -s compiler.version=7.0 --build missing .
Configuration:
[settings]
arch=armv7
arch_build=armv7
build_type=Release
compiler=clang
compiler.cppstd=17
compiler.version=7.0
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
Version ranges solved
Version range '>=4.3.0 <5.0' required by 'conanfile.txt' resolved to 'nanobench/4.3.5' in local cache
conanfile.txt: Installing package
Requirements
nanobench/4.3.5 from 'conancenter' - Cache
Packages
nanobench/4.3.5:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache
Installing (downloading, building) binaries...
nanobench/4.3.5: Already installed!
conanfile.txt: Generator cmake created conanbuildinfo.cmake
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Aggregating env generators
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
$ cmake .
-- Conan: Adjusting output directories
-- Conan: Using cmake targets configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /home/pi/go/src/github.com/mcandre/swiper
-- Conan: Checking correct version: 7.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/go/src/github.com/mcandre/swiper
$ VERBOSE=1 cmake --build . --config Release
/usr/bin/cmake -S/home/pi/go/src/github.com/mcandre/swiper -B/home/pi/go/src/github.com/mcandre/swiper --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/pi/go/src/github.com/mcandre/swiper/CMakeFiles /home/pi/go/src/github.com/mcandre/swiper/CMakeFiles/progress.marks
/usr/bin/make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/pi/go/src/github.com/mcandre/swiper'
/usr/bin/make -f CMakeFiles/bench-swiper-instrument.dir/build.make CMakeFiles/bench-swiper-instrument.dir/depend
make[2]: Entering directory '/home/pi/go/src/github.com/mcandre/swiper'
cd /home/pi/go/src/github.com/mcandre/swiper && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper/CMakeFiles/bench-swiper-instrument.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/go/src/github.com/mcandre/swiper'
/usr/bin/make -f CMakeFiles/bench-swiper-instrument.dir/build.make CMakeFiles/bench-swiper-instrument.dir/build
make[2]: Entering directory '/home/pi/go/src/github.com/mcandre/swiper'
make[2]: Nothing to be done for 'CMakeFiles/bench-swiper-instrument.dir/build'.
make[2]: Leaving directory '/home/pi/go/src/github.com/mcandre/swiper'
[ 25%] Built target bench-swiper-instrument
/usr/bin/make -f CMakeFiles/swiper.profraw.dir/build.make CMakeFiles/swiper.profraw.dir/depend
make[2]: Entering directory '/home/pi/go/src/github.com/mcandre/swiper'
cd /home/pi/go/src/github.com/mcandre/swiper && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper/CMakeFiles/swiper.profraw.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/go/src/github.com/mcandre/swiper'
/usr/bin/make -f CMakeFiles/swiper.profraw.dir/build.make CMakeFiles/swiper.profraw.dir/build
make[2]: Entering directory '/home/pi/go/src/github.com/mcandre/swiper'
/usr/bin/cmake -E env LLVM_PROFILE_FILE=swiper.profraw /home/pi/go/src/github.com/mcandre/swiper/bin/bench-swiper-instrument 00071B030141
Warning, results might be unstable:
* CPU frequency scaling enabled: CPU 0 between 600.0 and 1,500.0 MHz
* CPU governor is 'ondemand' but should be 'performance'
* Turbo is enabled, CPU frequency will fluctuate
Recommendations
* Use 'pyperf system tune' before benchmarking. See https://github.com/psf/pyperf
| ns/op | op/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 58.25 | 17,166,768.10 | 0.0% | 11.67 | `crack`
make[2]: Leaving directory '/home/pi/go/src/github.com/mcandre/swiper'
[ 25%] Built target swiper.profraw
/usr/bin/make -f CMakeFiles/swiper.profdata.dir/build.make CMakeFiles/swiper.profdata.dir/depend
make[2]: Entering directory '/home/pi/go/src/github.com/mcandre/swiper'
cd /home/pi/go/src/github.com/mcandre/swiper && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper/CMakeFiles/swiper.profdata.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/go/src/github.com/mcandre/swiper'
/usr/bin/make -f CMakeFiles/swiper.profdata.dir/build.make CMakeFiles/swiper.profdata.dir/build
make[2]: Entering directory '/home/pi/go/src/github.com/mcandre/swiper'
llvm-profdata merge -output swiper.profdata swiper.profraw
make[2]: Leaving directory '/home/pi/go/src/github.com/mcandre/swiper'
[ 25%] Built target swiper.profdata
/usr/bin/make -f CMakeFiles/bench-swiper.dir/build.make CMakeFiles/bench-swiper.dir/depend
make[2]: Entering directory '/home/pi/go/src/github.com/mcandre/swiper'
cd /home/pi/go/src/github.com/mcandre/swiper && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper /home/pi/go/src/github.com/mcandre/swiper/CMakeFiles/bench-swiper.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/go/src/github.com/mcandre/swiper'
/usr/bin/make -f CMakeFiles/bench-swiper.dir/build.make CMakeFiles/bench-swiper.dir/build
make[2]: Entering directory '/home/pi/go/src/github.com/mcandre/swiper'
[ 33%] Building CXX object CMakeFiles/bench-swiper.dir/src/cmd/bench-swiper/main.cpp.o
/usr/bin/cmake -E __run_co_compile --tidy="clang-tidy;-header-filter=/home/pi/go/src/github.com/mcandre/swiper" --source=/home/pi/go/src/github.com/mcandre/swiper/src/cmd/bench-swiper/main.cpp -- /usr/bin/c++ -I/home/pi/go/src/github.com/mcandre/swiper/include -isystem /home/pi/.conan/data/nanobench/4.3.5/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -O3 -Werror -std=c++17 -fno-exceptions -Wextra -Wall -pedantic -Weffc++ -Wmost -flto -fprofile-use=swiper.profdata -o CMakeFiles/bench-swiper.dir/src/cmd/bench-swiper/main.cpp.o -c /home/pi/go/src/github.com/mcandre/swiper/src/cmd/bench-swiper/main.cpp
/home/pi/go/src/github.com/mcandre/swiper/src/cmd/bench-swiper/main.cpp:12:10: error: 'nanobench.h' file not found [clang-diagnostic-error]
#include <nanobench.h>
^
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "/home/pi/go/src/github.com/mcandre/swiper/src/cmd/bench-swiper/main.cpp"
No compilation database found in /home/pi/go/src/github.com/mcandre/swiper/src/cmd/bench-swiper or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
6511 warnings and 1 error generated.
Error while processing /home/pi/go/src/github.com/mcandre/swiper/src/cmd/bench-swiper/main.cpp.
Suppressed 6511 warnings (6511 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).
make[2]: *** [CMakeFiles/bench-swiper.dir/build.make:63: CMakeFiles/bench-swiper.dir/src/cmd/bench-swiper/main.cpp.o] Error 1
make[2]: Leaving directory '/home/pi/go/src/github.com/mcandre/swiper'
make[1]: *** [CMakeFiles/Makefile2:228: CMakeFiles/bench-swiper.dir/all] Error 2
make[1]: Leaving directory '/home/pi/go/src/github.com/mcandre/swiper'
make: *** [Makefile:95: all] Error 2
$ find ~/.conan -name nanobench.h
/home/pi/.conan/data/nanobench/4.3.5/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/nanobench.h
$ cmake --version
cmake version 3.16.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ conan --version
Conan version 1.40.2
$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
@mcandre
Copy link
Author

mcandre commented Sep 24, 2021

For comparison, this has worked fine on Ubuntu 20.04 Focal Fossa. Somehow, conan cmake integration is breaking on Raspberry Pi.

@mcandre
Copy link
Author

mcandre commented Sep 24, 2021

Able to reproduce the same error behavior in a debian:buster Docker container. The problem is not specific to ARM. It may be an artifact of the old development tools in the Debian Buster base which Raspberry Pi uses for the current stable RaspbiOS release.

Something appears to be wrong in how clang v7 handles PGO compilation units.

diff --git a/home/pi/Downloads/a.txt b/home/pi/Downloads/b.txt                                                                                     
index 8938c83..a51e470 100644
--- a/home/pi/Downloads/a.txt
+++ b/home/pi/Downloads/b.txt
@@ -1 +1 @@
/usr/bin/cmake -E __run_co_compile --tidy="clang-tidy;-header-filter=/home/pi/go/src/github.com/mcandre/swiper" --source=/home/pi/go/src/github.com/mcandre/swiper/src/cmd/bench-swiper/main.cpp -- /usr/bin/c++   -I/home/pi/go/src/github.com/mcandre/swiper/include -isystem /home/pi/.conan/data/nanobench/4.3.5/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include  -O3 -Werror -std=c++17 -fno-exceptions -Wextra -Wall -pedantic -Weffc++ -Wmost   [--fprofile-generate-]{+-flto -fprofile-use=swiper.profdata+} -o [-CMakeFiles/bench-swiper-instrument.dir/src/cmd/bench-swiper/main.cpp.o-]{+CMakeFiles/bench-swiper.dir/src/cmd/bench-swiper/main.cpp.o+} -c /home/pi/go/src/github.com/mcandre/swiper/src/cmd/bench-swiper/main.cpp

@mcandre
Copy link
Author

mcandre commented Sep 24, 2021

Temporarily disabling PGO locally.

This reveals a similar header not found error for swiper/swiper.hpp.

Perhaps clang v7 is very strict about compiler flag order.

@mcandre
Copy link
Author

mcandre commented Sep 24, 2021

Looks to be clang-tidy v7 that throws up. When tidy is disabled, then the include errors go away.

@mcandre
Copy link
Author

mcandre commented Sep 24, 2021

omg and now clang v7 is segfaulting!

$ /usr/bin/c++ -v -Wl,-v    -O3 -Werror -std=c++17 -fno-exceptions -Wextra -Wall -pedantic -Weffc++ -Wmost  -flto -fprofile-use=swiper.profdata CMakeFiles/bench-swiper.dir/src/cmd/bench-swiper/main.cpp.o CMakeFiles/bench-swiper.dir/src/swiper.cpp.o  -o bin/bench-swiper
clang version 7.0.1-8+rpi3+deb10u2 (tags/RELEASE_701/final)                                                                                        
Target: armv6k-unknown-linux-gnueabihf                                                                                                             
Thread model: posix                                                                                                                                
InstalledDir: /usr/bin                                                                                                                             
Found candidate GCC installation: /usr/bin/../lib/gcc/arm-linux-gnueabihf/4.9                                                                      
Found candidate GCC installation: /usr/bin/../lib/gcc/arm-linux-gnueabihf/4.9.4                                                                    
Found candidate GCC installation: /usr/bin/../lib/gcc/arm-linux-gnueabihf/5                                                                        
Found candidate GCC installation: /usr/bin/../lib/gcc/arm-linux-gnueabihf/5.5.0                                                                    
Found candidate GCC installation: /usr/bin/../lib/gcc/arm-linux-gnueabihf/6                                                                        
Found candidate GCC installation: /usr/bin/../lib/gcc/arm-linux-gnueabihf/6.5.0                                                                    
Found candidate GCC installation: /usr/bin/../lib/gcc/arm-linux-gnueabihf/7                                                                        
Found candidate GCC installation: /usr/bin/../lib/gcc/arm-linux-gnueabihf/7.3.0                                                                    
Found candidate GCC installation: /usr/bin/../lib/gcc/arm-linux-gnueabihf/8                                                                        
Found candidate GCC installation: /usr/lib/gcc/arm-linux-gnueabihf/4.9                                                                             
Found candidate GCC installation: /usr/lib/gcc/arm-linux-gnueabihf/4.9.4                                                                           
Found candidate GCC installation: /usr/lib/gcc/arm-linux-gnueabihf/5                                                                               
Found candidate GCC installation: /usr/lib/gcc/arm-linux-gnueabihf/5.5.0                                                                           
Found candidate GCC installation: /usr/lib/gcc/arm-linux-gnueabihf/6                                                                               
Found candidate GCC installation: /usr/lib/gcc/arm-linux-gnueabihf/6.5.0                                                                           
Found candidate GCC installation: /usr/lib/gcc/arm-linux-gnueabihf/7                                                                               
Found candidate GCC installation: /usr/lib/gcc/arm-linux-gnueabihf/7.3.0                                                                           
Found candidate GCC installation: /usr/lib/gcc/arm-linux-gnueabihf/8                                                                               
Selected GCC installation: /usr/bin/../lib/gcc/arm-linux-gnueabihf/8                                                                               
Candidate multilib: .;@m32                                                                                                                         
Selected multilib: .;@m32                                                                                                                          
 "/usr/bin/ld" -X --hash-style=both --build-id --eh-frame-hdr -m armelf_linux_eabi -dynamic-linker /lib/ld-linux-armhf.so.3 -o bin/bench-swiper /usr/bin/../lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crt1.o /usr/bin/../lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crti.o /usr/bin/../lib/gcc/arm-linux-gnueabihf/8/crtbegin.o -L/usr/bin/../lib/gcc/arm-linux-gnueabihf/8 -L/usr/bin/../lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf -L/usr/bin/../lib/gcc/arm-linux-gnueabihf/8/../../../../lib -L/usr/lib/llvm-7/bin/../lib -L/lib/arm-linux-gnueabihf -L/lib/../lib -L/usr/lib/arm-linux-gnueabihf -L/usr/lib/../lib -L/usr/lib/arm-linux-gnueabihf/../../lib -L/usr/bin/../lib/gcc/arm-linux-gnueabihf/8/../../.. -L/usr/lib/llvm-7/bin/../lib -L/lib -L/usr/lib -plugin /usr/lib/llvm-7/bin/../lib/LLVMgold.so -plugin-opt=mcpu=mpcore -plugin-opt=O3 -v CMakeFiles/bench-swiper.dir/src/cmd/bench-swiper/main.cpp.o CMakeFiles/bench-swiper.dir/src/swiper.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/arm-linux-gnueabihf/8/crtend.o /usr/bin/../lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crtn.o                   
GNU ld (GNU Binutils for Raspbian) 2.31.1
clang: error: unable to execute command: Segmentation fault
clang: error: linker command failed due to signal (use -v to see invocation)

@mcandre
Copy link
Author

mcandre commented Sep 24, 2021

Perhaps the debian buster LLVM toolchain is corrupting target triples. I'm seeing slightly different architecture names used at different stages of compilation.

@mcandre
Copy link
Author

mcandre commented Sep 24, 2021

Finally, libfuzzer is not available out of the box for Debian Buster / RaspbiOS clang & llvm.

Placing some cmake guards around PGO, tidy, and libfuzzer. Now swiper is able to build and run with the Debian Buster / RaspbiOS stable clang toolchain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment