summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Bodley <cbodley@redhat.com>2024-09-05 18:28:33 +0200
committerCasey Bodley <cbodley@redhat.com>2024-09-05 19:19:23 +0200
commit926ef939e7dcd729d0537849141748c7fe17c398 (patch)
tree27d2aac51ee670e4de71a111b1db61b051ffded2
parentcmake/crypto: use ExternalProject to build isal crypto library (diff)
downloadceph-926ef939e7dcd729d0537849141748c7fe17c398.tar.xz
ceph-926ef939e7dcd729d0537849141748c7fe17c398.zip
cmake/ec: use ExternalProject to build isal library
Signed-off-by: Casey Bodley <cbodley@redhat.com>
-rw-r--r--cmake/modules/BuildISAL.cmake42
-rw-r--r--src/erasure-code/isa/CMakeLists.txt115
2 files changed, 52 insertions, 105 deletions
diff --git a/cmake/modules/BuildISAL.cmake b/cmake/modules/BuildISAL.cmake
new file mode 100644
index 00000000000..6df15bc5bb8
--- /dev/null
+++ b/cmake/modules/BuildISAL.cmake
@@ -0,0 +1,42 @@
+# use an ExternalProject to build isa-l using its makefile
+function(build_isal)
+ set(isal_BINARY_DIR ${CMAKE_BINARY_DIR}/src/isa-l)
+ set(isal_INSTALL_DIR ${isal_BINARY_DIR}/install)
+ set(isal_INCLUDE_DIR "${isal_INSTALL_DIR}/include")
+ set(isal_LIBRARY "${isal_INSTALL_DIR}/lib/libisal.a")
+
+ # this include directory won't exist until the install step, but the
+ # imported targets need it early for INTERFACE_INCLUDE_DIRECTORIES
+ file(MAKE_DIRECTORY "${isal_INCLUDE_DIR}")
+
+ set(configure_cmd env CC=${CMAKE_C_COMPILER} ./configure --prefix=${isal_INSTALL_DIR})
+ # build a static library with -fPIC that we can link into crypto/compressor plugins
+ list(APPEND configure_cmd --with-pic --enable-static --disable-shared)
+
+ # clear the DESTDIR environment variable from debian/rules,
+ # because it messes with the internal install paths of arrow's bundled deps
+ set(NO_DESTDIR_COMMAND ${CMAKE_COMMAND} -E env --unset=DESTDIR)
+
+ include(ExternalProject)
+ ExternalProject_Add(isal_ext
+ SOURCE_DIR "${PROJECT_SOURCE_DIR}/src/isa-l"
+ CONFIGURE_COMMAND ./autogen.sh COMMAND ${configure_cmd}
+ BUILD_COMMAND ${NO_DESTDIR_COMMAND} make -j3
+ BUILD_IN_SOURCE 1
+ BUILD_BYPRODUCTS ${isal_LIBRARY}
+ INSTALL_COMMAND ${NO_DESTDIR_COMMAND} make install
+ UPDATE_COMMAND ""
+ LOG_CONFIGURE ON
+ LOG_BUILD ON
+ LOG_INSTALL ON
+ LOG_MERGED_STDOUTERR ON
+ LOG_OUTPUT_ON_FAILURE ON)
+
+ # add imported library target ISAL::Crypto
+ add_library(ISAL::ISAL STATIC IMPORTED GLOBAL)
+ add_dependencies(ISAL::ISAL isal_ext)
+ set_target_properties(ISAL::ISAL PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES ${isal_INCLUDE_DIR}
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION ${isal_LIBRARY})
+endfunction()
diff --git a/src/erasure-code/isa/CMakeLists.txt b/src/erasure-code/isa/CMakeLists.txt
index 2ca398ffcb1..6162075cbc8 100644
--- a/src/erasure-code/isa/CMakeLists.txt
+++ b/src/erasure-code/isa/CMakeLists.txt
@@ -1,113 +1,18 @@
-# ISA
-set(isal_src_dir ${CMAKE_SOURCE_DIR}/src/isa-l)
-include_directories(${isal_src_dir}/include)
+# build isa-l from its makefile and expose as target ISAL::ISAL
+include(BuildISAL)
+build_isal()
-if(HAVE_NASM_X64_AVX2)
- set(CMAKE_ASM_FLAGS "-i ${isal_src_dir}/include/ ${CMAKE_ASM_FLAGS}")
- set(isa_srcs
- ${isal_src_dir}/erasure_code/ec_base.c
- ${isal_src_dir}/erasure_code/gf_2vect_dot_prod_sse.asm
- ${isal_src_dir}/erasure_code/gf_3vect_dot_prod_sse.asm
- ${isal_src_dir}/erasure_code/gf_4vect_dot_prod_sse.asm
- ${isal_src_dir}/erasure_code/gf_5vect_dot_prod_sse.asm
- ${isal_src_dir}/erasure_code/gf_6vect_dot_prod_sse.asm
- ${isal_src_dir}/erasure_code/gf_vect_dot_prod_sse.asm
- ${isal_src_dir}/erasure_code/gf_2vect_mad_avx2.asm
- ${isal_src_dir}/erasure_code/gf_3vect_mad_avx2.asm
- ${isal_src_dir}/erasure_code/gf_4vect_mad_avx2.asm
- ${isal_src_dir}/erasure_code/gf_5vect_mad_avx2.asm
- ${isal_src_dir}/erasure_code/gf_6vect_mad_avx2.asm
- ${isal_src_dir}/erasure_code/gf_vect_mad_avx2.asm
- ${isal_src_dir}/erasure_code/ec_highlevel_func.c
- ${isal_src_dir}/erasure_code/gf_2vect_mad_avx.asm
- ${isal_src_dir}/erasure_code/gf_3vect_mad_avx.asm
- ${isal_src_dir}/erasure_code/gf_4vect_mad_avx.asm
- ${isal_src_dir}/erasure_code/gf_5vect_mad_avx.asm
- ${isal_src_dir}/erasure_code/gf_6vect_mad_avx.asm
- ${isal_src_dir}/erasure_code/gf_vect_mad_avx.asm
- ${isal_src_dir}/erasure_code/ec_multibinary.asm
- ${isal_src_dir}/erasure_code/gf_2vect_mad_sse.asm
- ${isal_src_dir}/erasure_code/gf_3vect_mad_sse.asm
- ${isal_src_dir}/erasure_code/gf_4vect_mad_sse.asm
- ${isal_src_dir}/erasure_code/gf_5vect_mad_sse.asm
- ${isal_src_dir}/erasure_code/gf_6vect_mad_sse.asm
- ${isal_src_dir}/erasure_code/gf_vect_mad_sse.asm
- ${isal_src_dir}/erasure_code/gf_2vect_dot_prod_avx2.asm
- ${isal_src_dir}/erasure_code/gf_3vect_dot_prod_avx2.asm
- ${isal_src_dir}/erasure_code/gf_4vect_dot_prod_avx2.asm
- ${isal_src_dir}/erasure_code/gf_5vect_dot_prod_avx2.asm
- ${isal_src_dir}/erasure_code/gf_6vect_dot_prod_avx2.asm
- ${isal_src_dir}/erasure_code/gf_vect_dot_prod_avx2.asm
- ${isal_src_dir}/erasure_code/gf_vect_mul_avx.asm
- ${isal_src_dir}/erasure_code/gf_2vect_dot_prod_avx.asm
- ${isal_src_dir}/erasure_code/gf_3vect_dot_prod_avx.asm
- ${isal_src_dir}/erasure_code/gf_4vect_dot_prod_avx.asm
- ${isal_src_dir}/erasure_code/gf_5vect_dot_prod_avx.asm
- ${isal_src_dir}/erasure_code/gf_6vect_dot_prod_avx.asm
- ${isal_src_dir}/erasure_code/gf_vect_dot_prod_avx.asm
- ${isal_src_dir}/erasure_code/gf_vect_mul_sse.asm
- ${isal_src_dir}/erasure_code/gf_2vect_dot_prod_avx512.asm
- ${isal_src_dir}/erasure_code/gf_2vect_mad_avx512.asm
- ${isal_src_dir}/erasure_code/gf_3vect_dot_prod_avx512.asm
- ${isal_src_dir}/erasure_code/gf_3vect_mad_avx512.asm
- ${isal_src_dir}/erasure_code/gf_4vect_dot_prod_avx512.asm
- ${isal_src_dir}/erasure_code/gf_4vect_mad_avx512.asm
- ${isal_src_dir}/erasure_code/gf_vect_dot_prod_avx512.asm
- ${isal_src_dir}/erasure_code/gf_vect_mad_avx512.asm
- ${isal_src_dir}/raid/raid_base.c
- ${isal_src_dir}/raid/raid_multibinary.asm
- ${isal_src_dir}/raid/xor_check_sse.asm
- ${isal_src_dir}/raid/xor_gen_sse.asm
- ${isal_src_dir}/raid/xor_gen_avx.asm
- ${isal_src_dir}/raid/xor_gen_avx512.asm
- ${isal_src_dir}/raid/pq_check_sse.asm
- ${isal_src_dir}/raid/pq_gen_sse.asm
- ${isal_src_dir}/raid/pq_gen_avx.asm
- ${isal_src_dir}/raid/pq_gen_avx2.asm
- ErasureCodeIsa.cc
- ErasureCodeIsaTableCache.cc
- ErasureCodePluginIsa.cc
- )
-elseif(HAVE_ARMV8_SIMD)
- set(isa_srcs
- ${isal_src_dir}/erasure_code/ec_base.c
- ${isal_src_dir}/erasure_code/aarch64/ec_aarch64_highlevel_func.c
- ${isal_src_dir}/erasure_code/aarch64/ec_aarch64_dispatcher.c
- ${isal_src_dir}/erasure_code/aarch64/gf_2vect_dot_prod_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_2vect_mad_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_3vect_dot_prod_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_3vect_mad_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_4vect_dot_prod_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_4vect_mad_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_5vect_dot_prod_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_5vect_mad_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_6vect_mad_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_vect_dot_prod_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_vect_mad_neon.S
- ${isal_src_dir}/erasure_code/aarch64/gf_vect_mul_neon.S
- ${isal_src_dir}/erasure_code/aarch64/ec_multibinary_arm.S
- ${isal_src_dir}/raid/raid_base.c
- ${isal_src_dir}/raid/aarch64/raid_aarch64_dispatcher.c
- ${isal_src_dir}/raid/aarch64/raid_multibinary_arm.S
- ${isal_src_dir}/raid/aarch64/xor_check_neon.S
- ${isal_src_dir}/raid/aarch64/xor_gen_neon.S
- ${isal_src_dir}/raid/aarch64/pq_check_neon.S
- ${isal_src_dir}/raid/aarch64/pq_gen_neon.S
- ErasureCodeIsa.cc
- ErasureCodeIsaTableCache.cc
- ErasureCodePluginIsa.cc
- )
- set_source_files_properties(
- ${isal_src_dir}/erasure_code/aarch64/ec_multibinary_arm.S
- ${isal_src_dir}/raid/aarch64/raid_multibinary_arm.S
- PROPERTIES COMPILE_FLAGS "-D__ASSEMBLY__"
- )
-endif()
+# ISA
+set(isa_srcs
+ ErasureCodeIsa.cc
+ ErasureCodeIsaTableCache.cc
+ ErasureCodePluginIsa.cc
+)
add_library(ec_isa SHARED
${isa_srcs}
$<TARGET_OBJECTS:erasure_code_objs>)
-target_link_libraries(ec_isa ${EXTRALIBS})
+target_link_libraries(ec_isa ISAL::ISAL ${EXTRALIBS})
set_target_properties(ec_isa PROPERTIES
INSTALL_RPATH "")
install(TARGETS ec_isa DESTINATION ${erasure_plugin_dir})