Problemm:
/usr/bin/ld: _deps/ev-build/libev.a(ev.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Way 1
Solution:
Add
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
So that
/usr/bin/cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DENABLE_CXX_CLANG_TIDY=TRUE -DENABLE_CODE_COVERAGE=TRUE -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -DCMAKE_POSITION_INDEPENDENT_CODE=ON ..
Reference:
https://stackoverflow.com/questions/38296756/what-is-the-idiomatic-way-in-cmake-to-add-the-fpic-compiler-option
readme.md
sudo docker build . -t gfo/cpp-build
sudo docker rm -f cpp-build
sudo docker run --net=host --cap-add sys_ptrace -d --name cpp-build --memory=12g -v "${PWD}/../../../../:/work" gfo/cpp-build tail -F /dev/null
sudo docker exec -it cpp-build bash
mkdir build
cd build
cmake ../ -GNinja -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9
ninja -j12
ninja test
Way 2:
Interpolated
/usr/bin/cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -DTEST_REPORTER=junit ..
/usr/bin/cmake --build . --target all
/usr/bin/cmake --build . --target test
Raw:
CMAKE_BUILD_DIR=cmake-build-dir
CMAKE_EXEC=/usr/bin/cmake
CXX_BUILD_SYSTEM=Ninja
CXX_BUILD_TYPE=Debug
CLANG_TIDY_FLAG=
CODE_COVERAGE_FLAG=-DENABLE_CODE_COVERAGE=TRUE
EXTRA_CMAKE_FLAGS=-DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -DTEST_REPORTER=junit
$ date -R
$ pwd
/builds/subdir/app
$ env | sort
$ mkdir -p ${CMAKE_BUILD_DIR}
$ cd ${CMAKE_BUILD_DIR}
${CMAKE_EXEC} -G"${CXX_BUILD_SYSTEM}" -DCMAKE_BUILD_TYPE=${CXX_BUILD_TYPE} ${CLANG_TIDY_FLAG} ${CODE_COVERAGE_FLAG} ${EXTRA_CMAKE_FLAGS[@]} ..
${CMAKE_EXEC} --build . --target all
${CMAKE_EXEC} --build ${CMAKE_BUILD_DIR} --target test
CoreDump
docker run --privileged <the docker image ID>
setup
sudo sysctl kernel.core_pattern=/var/crash/core.%c.%d.%p.%t.%s.%E
cat /proc/sys/kernel/core_pattern
/var/crash/%E.%p.%t.%s
test
ctest -R "test_name"
repeat test
until ! ctest -R "test_possible_fail"; do echo ...; sleep 1; done