intel / pcm

Intel® Performance Counter Monitor (Intel® PCM)
BSD 3-Clause "New" or "Revised" License
2.83k stars 477 forks source link

Cannot build pcm on arch linux #843

Closed yuyalun-allen closed 1 month ago

yuyalun-allen commented 1 month ago

Hello developers, I'm trying to build and use pcm on my pc with arch linux and intel core 13490f. But I encountered some issues.

I followed the instructions to clone and build, but when excuting cmake --build . ld complained that could not find -lasan. Here is the output:

mkdir build
cd build
cmake ..
cmake --build .
mkdir: created directory 'build'
/home/allen/Applications/pcm/build
-- The C compiler identification is GNU 14.2.1
-- The CXX compiler identification is GNU 14.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- System: Linux-6.11.1-zen1-1-zen
-- Build type: Release
-- initial CMAKE_CXX_FLAGS:
-- initial CMAKE_C_FLAGS:
-- Set LINUX_SYSTEMD=TRUE for a systemd unit file.
-- CMAKE_CXX_FLAGS:  -Wno-unknown-pragmas -DCMAKE_INSTALL_PREFIX="/usr/local" -Wextra -DPCM_USE_PERF -Wl,-z,now
-- CMAKE_C_FLAGS:  -Wno-unknown-pragmas -DCMAKE_INSTALL_PREFIX="/usr/local" -Wextra -DPCM_USE_PERF -Wl,-z,now
-- AddressSanitizer is enabled
-- To disable AddressSanitizer, use -DPCM_NO_ASAN=1 option
-- CMAKE_CXX_FLAGS_RELEASE: -Wall -O3 -rdynamic -fPIE -fstack-protector -D_FORTIFY_SOURCE=2 -ftrapv -fsanitize=address -fwrapv -fno-delete-null-pointer-checks -fno-strict-overflow -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
-- CMAKE_CXX_FLAGS_DEBUG: -Wall -O0 -g -rdynamic -fPIE -fstack-protector -D_FORTIFY_SOURCE=2 -ftrapv -fsanitize=address -fwrapv -fno-delete-null-pointer-checks -fno-strict-overflow -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -Wall -O3 -g -rdynamic -fPIE -fstack-protector -D_FORTIFY_SOURCE=2 -ftrapv -fsanitize=address -fwrapv -fno-delete-null-pointer-checks -fno-strict-overflow -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
-- Found OpenSSL: /usr/lib/libcrypto.so (found version "3.3.2")
-- Detected Linux distribution: arch
-- Using static libasan
-- To use dynamic libasan, use -DPCM_NO_STATIC_LIBASAN=1 option (required for CentOS)
-- Local SIMDJSON exists: /home/allen/Applications/pcm/src/simdjson/singleheader/simdjson.h
-- Compiling with SSL support, requires libssl-dev or openssl-devel or libopenssl-devel or libopenssl-dev package installed
-- To disable SSL support, use -DNO_SSL=1 option
-- OpenSSL version 3.3.2 >= 1.1.1, OpenSSL support enabled
-- Install directory: /usr/local
-- CPACK_GENERATOR is TXZ
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: /home/allen/Applications/pcm/build
[  1%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/bw.cpp.o
[  2%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/cpucounters.cpp.o
[  3%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/debug.cpp.o
[  4%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/mmio.cpp.o
[  5%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/msr.cpp.o
[  7%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/pci.cpp.o
[  8%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/pcm-accel-common.cpp.o
[  9%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/pmt.cpp.o
[ 10%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/threadpool.cpp.o
[ 11%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/topology.cpp.o
[ 12%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/tpmi.cpp.o
[ 14%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/uncore_pmu_discovery.cpp.o
[ 15%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/utils.cpp.o
[ 16%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/dashboard.cpp.o
[ 17%] Building CXX object src/CMakeFiles/PCM_STATIC.dir/resctrl.cpp.o
[ 18%] Linking CXX static library libpcm.a
[ 18%] Built target PCM_STATIC
[ 20%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/bw.cpp.o
[ 21%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/cpucounters.cpp.o
[ 22%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/debug.cpp.o
[ 23%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/mmio.cpp.o
[ 24%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/msr.cpp.o
[ 25%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/pci.cpp.o
[ 27%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/pcm-accel-common.cpp.o
[ 28%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/pmt.cpp.o
[ 29%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/threadpool.cpp.o
[ 30%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/topology.cpp.o
[ 31%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/tpmi.cpp.o
[ 32%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/uncore_pmu_discovery.cpp.o
[ 34%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/utils.cpp.o
[ 35%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/dashboard.cpp.o
[ 36%] Building CXX object src/CMakeFiles/PCM_STATIC_SILENT.dir/resctrl.cpp.o
[ 37%] Linking CXX static library libPCM_STATIC_SILENT.a
[ 37%] Built target PCM_STATIC_SILENT
[ 38%] Building CXX object src/CMakeFiles/PCM_SHARED.dir/pcm-core.cpp.o
[ 40%] Linking CXX shared library ../lib/libpcm.so
[ 40%] Built target PCM_SHARED
[ 41%] Building CXX object src/CMakeFiles/pcm.dir/pcm.cpp.o
[ 42%] Linking CXX executable ../bin/pcm
/usr/bin/ld: cannot find -lasan: No such file or directory
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/pcm.dir/build.make:98: bin/pcm] Error 1
make[1]: *** [CMakeFiles/Makefile2:260: src/CMakeFiles/pcm.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

However, I double checked there is indeed libasan.so on my computer, like this:

ll /usr/lib/libasan.so
lrwxrwxrwx 1 root root 16  9月10日 21:07 /usr/lib/libasan.so -> libasan.so.8.0.0*

how to fix this?

rdementi commented 1 month ago

thank you for reporting this issue. It seems on your system the compilation with the static libasan does not work. To work-around this you can use an alternative option in cmake to disable static linking with libasan:

cmake -DPCM_NO_STATIC_LIBASAN=ON ..
cmake --build .

Additionally, I have just pushed a change into the master branch to detect arch Linux and apply this option automatically. Please check it out.

yuyalun-allen commented 1 month ago

It works! Thanks for your help.