]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: fix undefined PY_LDFLAGS in distutils_install_cython_module 67037/head
authorKefu Chai <k.chai@proxmox.com>
Thu, 22 Jan 2026 03:57:37 +0000 (11:57 +0800)
committerKefu Chai <k.chai@proxmox.com>
Thu, 22 Jan 2026 05:50:22 +0000 (13:50 +0800)
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 <k.chai@proxmox.com>
cmake/modules/Distutils.cmake

index f3d6c41e731749294d4644bd4b26a0664f76f2e8..76b5fb23d91605c221090c64906606b9b462e19a 100644 (file)
@@ -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)