From fadc2b1cc2676a21c255c915892b411fcf76de19 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 22 Jan 2026 11:57:37 +0800 Subject: [PATCH] cmake: fix undefined PY_LDFLAGS in distutils_install_cython_module The distutils_install_cython_module() function was using ${PY_LDFLAGS} without defining it, causing the linker to fail with: /opt/rh/gcc-toolset-13/root/usr/libexec/gcc/x86_64-redhat-linux/13/ld: cannot find -lrados: No such file or directory This bug was introduced in commit d22734f6cb0 which changed: set(ENV{LDFLAGS} "-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") to: set(ENV{LDFLAGS} "${PY_LDFLAGS}") However, PY_LDFLAGS was only defined in distutils_add_cython_module(), not in distutils_install_cython_module(). This meant that during the install phase, LDFLAGS was set to an empty string, and the linker couldn't find librados.so and other Ceph libraries in the build directory. The bug was exposed by commit 719b74984605b490f23004eb41583a22c934c5fb which changed rados.pxd to use C preprocessor conditionals (#ifdef BUILD_DOC) instead of Cython's compile-time IF statements. This meant the build now required proper linking during the install phase. Fix by defining PY_LDFLAGS in distutils_install_cython_module(): set(PY_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") This keeps CMAKE_SHARED_LINKER_FLAGS as a space-separated string and appends the library directory flag, avoiding issues with semicolon conversion. Fixes: d22734f6cb0 Signed-off-by: Kefu Chai --- cmake/modules/Distutils.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/modules/Distutils.cmake b/cmake/modules/Distutils.cmake index f3d6c41e7317..76b5fb23d916 100644 --- a/cmake/modules/Distutils.cmake +++ b/cmake/modules/Distutils.cmake @@ -118,6 +118,7 @@ function(distutils_install_cython_module name) get_property(link_launcher GLOBAL PROPERTY RULE_LAUNCH_LINK) set(PY_CC "${compiler_launcher} ${CMAKE_C_COMPILER}") set(PY_LDSHARED "${link_launcher} ${CMAKE_C_COMPILER} -shared") + set(PY_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") cmake_parse_arguments(DU "DISABLE_VTA" "" "" ${ARGN}) if(DU_DISABLE_VTA AND HAS_VTA) set(CFLAG_DISABLE_VTA -fno-var-tracking-assignments) -- 2.47.3