Project

General

Profile

Actions

Bug #81923

open
KB

build: Ubuntu 24.04 debug build fails to link bin/neorados

Bug #81923: build: Ubuntu 24.04 debug build fails to link bin/neorados

Added by Kyle Bader about 1 month ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
build
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):
Tags (freeform):
Merge Commit:
Fixed In:
Released In:
Upkeep Timestamp:

Description

The debug flavor of the Ubuntu 24.04 package build fails to link
bin/neorados with 33 undefined references to librados:

/usr/bin/ld: /tmp/ccoxguml.ltrans12.ltrans.o: in function `librados::v14_2_0::ObjectWriteOperation::~ObjectWriteOperation()':
src/include/rados/librados.hpp:482:(.text+0x665): undefined reference to `librados::v14_2_0::ObjectOperation::~ObjectOperation()'
src/cls/lock/cls_lock_client.cc:61:(.text+0x152e): undefined reference to `librados::v14_2_0::IoCtx::operate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, librados::v14_2_0::ObjectWriteOperation*)'
collect2: error: ld returned 1 exit status
make[3]: *** [src/tools/CMakeFiles/neorados.dir/build.make:133: bin/neorados] Error 1

Cause

libneorados links cls_lock_client, which it does not use. That entry
came with the library in 2019 (src/neorados/CMakeLists.txt). So every
program that links libneorados has libcls_lock_client.a on its link
line, before libstdc++.

In a Debug build, Boost is built without optimization, and
libboost_program_options.a(cmdline.o) calls
std::string::operator[](unsigned long) out of line. At -Og,
cls_lock_client.cc.o has a weak copy of that function. A linker map of
bin/neorados shows the result:

lib/libcls_lock_client.a(cls_lock_client.cc.o)
    boost/lib/libboost_program_options.a(cmdline.o) (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned long))

The linker takes cls_lock_client.cc.o for that one symbol, and the rest
of that object needs librados, which bin/neorados does not link.

Before PR #68593, inline code in osd_types.h gave RADOS.cc.o its own
copy of the function, so the linker never looked in
libcls_lock_client.a. PR #68593 (4c50368d1f3, "osd/osd_types: un-inline
methods to reduce header dependencies") moved that code to osd_types.cc.
Branches that fork main before 2026-10-16 still build this flavor.

Reproducer

We built in an ubuntu:24.04 container, with the dependencies of
install-deps.sh, Debian's flags and CMAKE_BUILD_TYPE=Debug:

CFLAGS/CXXFLAGS="-g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection" 
LDFLAGS="-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro" 
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DWITH_JAEGER=ON -DWITH_LTTNG=ON ... (the options of debian/rules)
ninja bin/neorados
  • main at aaba23a5043: 33 undefined references.
  • The same tree with 4c50368d1f3 reverted: links.
  • The same tree with the fix below: all 109 programs and libraries
    that link libneorados or rbd_internal link, among them bin/neorados,
    ceph_test_librbd, ceph_test_rbd_mirror, rbd-mirror and radosgw.
    Without the rbd_internal part, ceph_test_librbd and
    ceph_test_rbd_mirror fail with undefined references to
    rados::cls::lock functions.

Fix

Remove cls_lock_client from the link libraries of libneorados. Add it
to rbd_internal, which calls rados::cls::lock and got cls_lock_client
only through libneorados. Without that second part, ceph_test_librbd
and ceph_test_rbd_mirror do not link. rgw and the shared librbd link
cls_lock_client themselves.

Affected versions: main (since PR #68593, merged 2026-10-16)

No data to display

Actions

Also available in: PDF Atom