gnuradio / volk

The Vector Optimized Library of Kernels
http://libvolk.org
GNU Lesser General Public License v3.0
548 stars 202 forks source link

cmake doesn't check for cpu_features library being installed #607

Closed MattEttus closed 1 year ago

MattEttus commented 2 years ago

Build fails with the following error if cpu_features not installed, which cmake should check:

Consolidate compiler generated dependencies of target volk_obj [ 88%] Built target volk_obj [ 89%] Linking C shared library libvolk.so /usr/bin/ld: cannot find -lcpu_features collect2: error: ld returned 1 exit status make[2]: [lib/CMakeFiles/volk.dir/build.make:168: lib/libvolk.so.2.5.2] Error 1 make[1]: [CMakeFiles/Makefile2:239: lib/CMakeFiles/volk.dir/all] Error 2 make: *** [Makefile:146: all] Error 2

jdemel commented 2 years ago

Well, CMake should check for cpu_features. Otherwise, this step should fail. In some cases CMake finds a cpu_features version that is not found by the linker. Do you use a custom prefix? I have seen cases where a previously installed cpu_features library was picked up erroneously. i.e. it might help to just delete the cpu_features file in your custom prefix install. I assume cpu_features is a submodule in your case.

mmaroti commented 1 year ago

I have seen this happen as well, and I think this is a bug probably in the cmake files. I think it is reproducible with the following steps:

By the way, the QUIET flag is dangerous, as we have absolutely no feedback what is going on. At least when the library is found we should print out the CpuFeatures_DIR to the console to give some hint to the user what is going on. It would be better to disable looking for the library where it is going to be installed.

jdemel commented 1 year ago

So, the idea would be

Your description sounds like there's a bug in the cpu-features CMake.

mmaroti commented 1 year ago

I am not sure about the fix, but I think the main problem is not in the cpu-features, but in the way cpu_features are discovered and used. Maybe the fix should be somehow disabling the search for the cpu_library in the CMAKE_INSTALL_PREFIX path. I have been playing around with that but not knowledgeable enough about cmake.

jdemel commented 1 year ago

Maybe we should reverse the order of discovery here. Check for a cpu_features submodule first, if not found, search for a system installation.

Playing with the CMAKE_INSTALL_PREFIX behavior seems dangerous. It might have all kinds of side-effects.

jdemel commented 1 year ago

cpu_features v0.9 was just released with this useful CMake option: https://github.com/google/cpu_features/pull/325 Switching to this new version should fix several issues.

  1. The submodule cpu_features is not installed together with VOLK. That might fix the original issue
  2. A VOLK install doesn't require a cpu_features install (we link privately and statically aginst the submodule).