From: Kefu Chai Date: Wed, 8 Apr 2026 10:35:35 +0000 (+0800) Subject: cmake/erasure-code: provide vendored jerasure as Jerasure::jerasure target X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ebbb3d75300d77cd14959e38f26131281a0b46de;p=ceph.git cmake/erasure-code: provide vendored jerasure as Jerasure::jerasure target 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 --- diff --git a/src/erasure-code/jerasure/CMakeLists.txt b/src/erasure-code/jerasure/CMakeLists.txt index 023ffbf8a37..acd063c5924 100644 --- a/src/erasure-code/jerasure/CMakeLists.txt +++ b/src/erasure-code/jerasure/CMakeLists.txt @@ -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 $ - $ + $) +add_library(Jerasure::jerasure ALIAS jerasure_vendored) + +# ec_jerasure plugin +set(ec_jerasure_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() diff --git a/src/erasure-code/shec/CMakeLists.txt b/src/erasure-code/shec/CMakeLists.txt index e7521542e31..d2ba32d2eb2 100644 --- a/src/erasure-code/shec/CMakeLists.txt +++ b/src/erasure-code/shec/CMakeLists.txt @@ -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 - $ - $ + $ $) 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() diff --git a/src/erasure-code/shec/ErasureCodeShec.cc b/src/erasure-code/shec/ErasureCodeShec.cc index 4146ba59f95..d61ae8804e9 100644 --- a/src/erasure-code/shec/ErasureCodeShec.cc +++ b/src/erasure-code/shec/ErasureCodeShec.cc @@ -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); diff --git a/src/erasure-code/shec/determinant.c b/src/erasure-code/shec/determinant.c index f923e7db0a5..4d962519830 100644 --- a/src/erasure-code/shec/determinant.c +++ b/src/erasure-code/shec/determinant.c @@ -20,7 +20,7 @@ #include #include -#include "jerasure/include/galois.h" +#include "galois.h" void print_matrix(int *mat, int dim) {