Closed mr-c closed 3 years ago
Can you please try the latest commit (6f421bf) if it compiles now? I will publish a release afterwards.
I have release v4.0.6 with the fix (I hope).
@rvaser That made it better, thanks!
Did the way cpu_features
get compiled change? We are now getting a separate '.so' for that, instead of it being compiled in statically, and this is causing an issue.
I have not updated cpu_features
, only spoa CMakeLists a bit. Let me check.
Version 3.4.0 also generates the .so file for cpu_features
. what is the latest version you have in Debian?
@rvaser We had 3.4.0. Looks like the patch we used to generate a separate shared object in 3.4.0 avoided a separate shared object for cpu_features
.
https://packages.debian.org/sid/amd64/spoa/filelist https://packages.debian.org/sid/amd64/libspoa4.0.0/filelist
Seems my attempted updating of that patch for 4.0.5/4.0.6 missed something: https://salsa.debian.org/med-team/spoa/-/blob/master/debian/patches/shared_and_static.patch
Are you building both static and shared on purpose? If so, the patch does not enable dispatching in static library.
I applied your patch locally, plus target_link_libraries(${PROJECT_NAME}_static cereal)
, and it works fine, i.e. cpu_features
is not a .so
but an .a
.
[Edit] Also, the patch does not add SOVERSION to libspoa.so
.
[Edit2] Here is a part of modified CMakeLists which should do the trick I think:
...
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build all libraries as shared")
option(spoa_optimize_for_native "Build spoa with -march=native" ON)
option(spoa_optimize_for_portability "Build spoa with -msse4.1" OFF)
option(spoa_use_simde "Use SIMDe library for porting vectorized code" OFF)
option(spoa_use_simde_nonvec "Use SIMDe library for nonvectorized code" OFF)
option(spoa_use_simde_openmp "Use SIMDe support for OpenMP SIMD" OFF)
option(spoa_generate_dispatch "Use SIMDe to generate x86 dispatch" OFF)
if (NOT spoa_generate_dispatch)
if (spoa_optimize_for_portability)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
elseif (spoa_optimize_for_native)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif ()
endif ()
if (spoa_use_simde OR
spoa_use_simde_nonvec OR
spoa_use_simde_openmp OR
spoa_generate_dispatch)
add_definitions(-DUSE_SIMDE -DSIMDE_ENABLE_NATIVE_ALIASES)
if (spoa_use_simde_nonvec)
add_definitions(-DSIMDE_NO_NATIVE)
endif ()
if (spoa_use_simde_openmp)
add_definitions(-DSIMDE_ENABLE_OPENMP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp-simd")
endif ()
if (spoa_generate_dispatch)
add_definitions(-DGENERATE_DISPATCH)
endif ()
endif ()
if (NOT TARGET cereal)
add_subdirectory(vendor/cereal EXCLUDE_FROM_ALL)
endif ()
add_library(${PROJECT_NAME} SHARED
src/alignment_engine.cpp
src/graph.cpp
src/sisd_alignment_engine.cpp
src/dispatcher.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor/simde>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor/cpu_features/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(${PROJECT_NAME}
cereal)
# if (BUILD_SHARED_LIBS)
set_property(TARGET ${PROJECT_NAME} PROPERTY SOVERSION "7.0.0")
# endif ()
add_library(${PROJECT_NAME}_static STATIC
src/alignment_engine.cpp
src/graph.cpp
src/sisd_alignment_engine.cpp
src/dispatcher.cpp)
target_include_directories(${PROJECT_NAME}_static PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor/simde>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor/cpu_features/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(${PROJECT_NAME}_static
cereal)
if (spoa_generate_dispatch)
if (NOT TARGET cpu_features)
add_subdirectory(vendor/cpu_features EXCLUDE_FROM_ALL)
endif ()
list(APPEND ARCHITECTURES avx2 sse4.1 sse2)
foreach(arch IN LISTS ARCHITECTURES)
add_library(${PROJECT_NAME}_${arch} OBJECT
src/simd_alignment_engine_dispatch.cpp)
target_include_directories(${PROJECT_NAME}_${arch} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor/simde>
$<INSTALL_INTERFACE:include>)
target_link_libraries(${PROJECT_NAME}_${arch}
cereal)
set_target_properties(${PROJECT_NAME}_${arch} PROPERTIES
COMPILE_FLAGS "-m${arch}")
if (BUILD_SHARED_LIBS)
set_property(TARGET ${PROJECT_NAME}_${arch}
PROPERTY POSITION_INDEPENDENT_CODE ON)
endif ()
endforeach ()
add_dependencies(${PROJECT_NAME}
${PROJECT_NAME}_avx2
${PROJECT_NAME}_sse4.1
${PROJECT_NAME}_sse2)
add_dependencies(${PROJECT_NAME}_static
${PROJECT_NAME}_avx2
${PROJECT_NAME}_sse4.1
${PROJECT_NAME}_sse2)
target_link_libraries(${PROJECT_NAME}
cpu_features)
target_link_libraries(${PROJECT_NAME}_static
cpu_features)
endif ()
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${PROJECT_NAME}_static
DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/spoa
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
...
Hmm.. I'm still getting a ./lib/libcpu_features.so
in the build directory
cd obj-x86_64-linux-gnu && cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_INSTALL_LOCALSTATEDIR=/var -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON -DCMAKE_INSTALL_RUNSTATEDIR=/run -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON "-GUnix Makefiles" -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu -DCMAKE_BUILD_TYPE=Release -Dspoa_build_executable=ON -Dspoa_build_tests=ON -Dspoa_use_simde_nonvec=ON -Dspoa_use_simde_openmp=ON -Dspoa_optimize_for_native=OFF -DBUILD_SHARED_LIBS=ON -Dspoa_generate_dispatch=ON ..
Here's the full log https://gist.github.com/mr-c/4561cebbad557fe97fc70ba34ad5bfff
@rvaser Ah, if I take the -DBUILD_SHARED_LIBS=ON
off the cmake invocation and use your patch it works. Thanks!
Excerpt from the cmake generated
CMakeFiles/spoa.dir/build.make
at line 144Without
-DBUILD_SHARED_LIBS=ON
the build suceedsFull build log:
Debian was depending on this to make a shared library, so this is preventing us from release an updated Debian package of spoa 4.0.5