]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake/erasure-code: provide vendored jerasure as Jerasure::jerasure target
authorKefu Chai <k.chai@proxmox.com>
Wed, 8 Apr 2026 10:35:35 +0000 (18:35 +0800)
committerKefu Chai <k.chai@proxmox.com>
Wed, 8 Apr 2026 10:42:19 +0000 (18:42 +0800)
Wrap the vendored jerasure and gf-complete object libraries into a
static library (jerasure_vendored) and expose it via a Jerasure::jerasure
alias target. This prepares for an upcoming WITH_SYSTEM_JERASURE option
that will provide the same target backed by system libraries.

Split jerasure_init.cc (ceph's own galois field initialization glue)
into a separate jerasure_init_objs target, since it is not part of the
jerasure library and must always be built from ceph's source.

Normalize shec's include paths to use bare #include "jerasure.h"
instead of #include "jerasure/include/jerasure.h", consistent with the
jerasure plugin and compatible with both vendored and system headers.

No functional change: ec_jerasure, ec_shec, and their legacy flavor
variants produce identical binaries.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/erasure-code/jerasure/CMakeLists.txt
src/erasure-code/shec/CMakeLists.txt
src/erasure-code/shec/ErasureCodeShec.cc
src/erasure-code/shec/determinant.c

index 023ffbf8a3798fb80ea46a4947f698654dd8a462..acd063c59240ec3b015c99b4de6d6d7ed3846f7b 100644 (file)
@@ -7,6 +7,10 @@ set(jerasure_utils_src
 add_library(jerasure_utils OBJECT ${jerasure_utils_src})
 target_link_libraries(jerasure_utils legacy-option-headers)
 
+# jerasure_init is ceph's own glue code for galois field initialization,
+# not part of the jerasure library itself.
+add_library(jerasure_init_objs OBJECT jerasure_init.cc)
+
 # Set the CFLAGS correctly for gf-complete based on SIMD compiler support
 set(GF_COMPILE_FLAGS)
 if(HAVE_ARMV8_SIMD)
@@ -67,9 +71,9 @@ if(HAVE_ARM_NEON OR HAVE_ARMV8_SIMD)
 endif()
 
 add_library(gf-complete_objs OBJECT ${gf-complete_srcs})
-set_target_properties(gf-complete_objs PROPERTIES 
+set_target_properties(gf-complete_objs PROPERTIES
   COMPILE_FLAGS "${SIMD_COMPILE_FLAGS}")
-set_target_properties(gf-complete_objs PROPERTIES 
+set_target_properties(gf-complete_objs PROPERTIES
   COMPILE_DEFINITIONS "${GF_COMPILE_FLAGS}")
 
 set(jerasure_srcs
@@ -77,21 +81,28 @@ set(jerasure_srcs
   jerasure/src/galois.c
   jerasure/src/jerasure.c
   jerasure/src/liberation.c
-  jerasure/src/reed_sol.c
-  jerasure_init.cc)
-add_library(jerasure_objs OBJECT ${jerasure_srcs}) 
-target_compile_options(jerasure_objs PRIVATE "-Wno-unused-but-set-variable")
+  jerasure/src/reed_sol.c)
+add_library(jerasure_lib_objs OBJECT ${jerasure_srcs})
+target_compile_options(jerasure_lib_objs PRIVATE "-Wno-unused-but-set-variable")
 
-set(ec_jerasure_objs
+# Provide the vendored jerasure + gf-complete as a single static library
+# target, using the same Jerasure::jerasure name that FindJerasure.cmake
+# provides for the system library case.
+add_library(jerasure_vendored STATIC
   $<TARGET_OBJECTS:gf-complete_objs>
-  $<TARGET_OBJECTS:jerasure_objs>
+  $<TARGET_OBJECTS:jerasure_lib_objs>)
+add_library(Jerasure::jerasure ALIAS jerasure_vendored)
+
+# ec_jerasure plugin
+set(ec_jerasure_objs
+  $<TARGET_OBJECTS:jerasure_init_objs>
   $<TARGET_OBJECTS:jerasure_utils>
   $<TARGET_OBJECTS:erasure_code_objs>)
 
 add_library(ec_jerasure SHARED ${ec_jerasure_objs})
 set_target_properties(ec_jerasure PROPERTIES
   INSTALL_RPATH "")
-target_link_libraries(ec_jerasure ${EXTRALIBS})
+target_link_libraries(ec_jerasure Jerasure::jerasure ${EXTRALIBS})
 install(TARGETS ec_jerasure DESTINATION ${erasure_plugin_dir})
 
 # legacy libraries
@@ -100,6 +111,7 @@ foreach(flavor ${jerasure_legacy_flavors})
   add_library(${plugin_name} SHARED ${ec_jerasure_objs})
   set_target_properties(${plugin_name} PROPERTIES
     INSTALL_RPATH "")
+  target_link_libraries(${plugin_name} Jerasure::jerasure)
   install(TARGETS ${plugin_name} DESTINATION ${erasure_plugin_dir})
   add_dependencies(ec_jerasure ${plugin_name})
 endforeach()
index e7521542e31112e36454f0b3da8221ca1493628a..d2ba32d2eb2616196015174f8de163830bca672d 100644 (file)
@@ -3,10 +3,10 @@
 include_directories(.)
 
 set(shec_utils_srcs
-  ${CMAKE_SOURCE_DIR}/src/erasure-code/ErasureCode.cc 
-  ErasureCodePluginShec.cc 
-  ErasureCodeShec.cc 
-  ErasureCodeShecTableCache.cc 
+  ${CMAKE_SOURCE_DIR}/src/erasure-code/ErasureCode.cc
+  ErasureCodePluginShec.cc
+  ErasureCodeShec.cc
+  ErasureCodeShecTableCache.cc
   determinant.c)
 
 add_library(shec_utils OBJECT ${shec_utils_srcs})
@@ -14,14 +14,13 @@ target_link_libraries(shec_utils
   PRIVATE legacy-option-headers)
 
 set(ec_shec_objs
-  $<TARGET_OBJECTS:gf-complete_objs>
-  $<TARGET_OBJECTS:jerasure_objs>
+  $<TARGET_OBJECTS:jerasure_init_objs>
   $<TARGET_OBJECTS:shec_utils>)
 
 add_library(ec_shec SHARED ${ec_shec_objs})
 set_target_properties(ec_shec PROPERTIES
   INSTALL_RPATH "")
-target_link_libraries(ec_shec ${EXTRALIBS})
+target_link_libraries(ec_shec Jerasure::jerasure ${EXTRALIBS})
 install(TARGETS ec_shec DESTINATION ${erasure_plugin_dir})
 
 # legacy libraries
@@ -30,6 +29,7 @@ foreach(flavor ${jerasure_legacy_flavors})
   add_library(${plugin_name} SHARED ${ec_shec_objs})
   set_target_properties(${plugin_name} PROPERTIES
     INSTALL_RPATH "")
+  target_link_libraries(${plugin_name} Jerasure::jerasure)
   install(TARGETS ${plugin_name} DESTINATION ${erasure_plugin_dir})
   add_dependencies(ec_shec ${plugin_name})
 endforeach()
index 4146ba59f951687e59cd7e565f19db848b3afd57..d61ae8804e9f4a71fea3ca9f083825c43c7bf57b 100644 (file)
@@ -28,8 +28,8 @@
 #include "common/strtol.h"
 #include "ErasureCodeShec.h"
 extern "C" {
-#include "jerasure/include/jerasure.h"
-#include "jerasure/include/galois.h"
+#include "jerasure.h"
+#include "galois.h"
 
 extern int calc_determinant(int *matrix, int dim);
 extern int* reed_sol_vandermonde_coding_matrix(int k, int m, int w);
index f923e7db0a52a64cdb6c5a884f7e814743a574f3..4d962519830530981ef21b6ff877032188f761d4 100644 (file)
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "jerasure/include/galois.h"
+#include "galois.h"
 
 void print_matrix(int *mat, int dim)
 {