Skip to content

common,auth,msg: fix portability problems a stricter toolchain turns up - #71883

Merged
kamoltat merged 6 commits into
ceph:mainfrom
dvanders:wip-macos-1-portability
Nov 4, 2026
Merged

kamoltat merged 6 commits into
ceph:mainfrom
dvanders:wip-macos-1-portability

Conversation

@dvanders

@dvanders dvanders commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Split out of #71232, which reviewers asked to see in smaller batches.
This is the first of seven; it is based on main and does not depend on
any of the others.

Nothing here is macOS-specific — there is not a single platform
conditional in the series. These are things the tree gets away with under
libstdc++ and a slightly older clang, and which a stricter standard
library or a newer compiler rejects:

  • headers that relied on an include arriving transitively
  • BoundedKeyCounter's nested iterator not satisfying the C++20 iterator
    concepts it is used through
  • SimpleRADOSStriper::truncate declared with a signature the definition
    does not match
  • CachedStackStringStream's cache as a function-local static in a header
  • std::execution::seq passed to an algorithm overload that does not take
    an execution policy

Each is a single self-contained commit. (A seventh, making
platform_errno.h includable from C, was dropped: #71442 made the same
change.)

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

🤖 Generated with Claude Code

Comment thread src/include/platform_errno.h Resolved
@dvanders
dvanders requested a review from tchaikov September 23, 2026 06:15
Comment thread src/include/platform_errno.h Resolved
Comment thread src/common/StackStringStream.h Resolved
Comment thread src/common/io_exerciser/ObjectModel.cc Resolved

@wjwithagen wjwithagen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread src/common/io_exerciser/ObjectModel.cc Resolved

@wjwithagen wjwithagen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works on FreeBSD 14.1 as expected

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

std::exception_ptr and std::string/std::string_view were being used without
including the headers that declare them, which happens to work with libstdc++
because other headers pull them in, but fails with libc++.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
CephxKeyServer.h holds a boost::intrusive_ptr<CephContext>, so
intrusive_ptr_release(CephContext*) has to be visible where the smart
pointer's destructor is instantiated.  Only common_fwd.h was included, which
merely forward declares CephContext, so the lookup succeeded by accident
whenever another header happened to pull ceph_context.h in first.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
const_pointer_iterator adapts the map's const_iterator so that dereferencing
yields a pointer, and inherits everything else - including the increment and
decrement, which therefore return the base iterator rather than this type.
weakly_incrementable requires "{ ++i } -> same_as<I&>", so the adapter is not
an input_iterator, and get_highest()'s std::vector::assign is ill-formed.

libstdc++ never noticed, because its assign() does not go through the
constrained algorithms.  libc++ dispatches to ranges::copy_n, which checks,
and rejects the iterator with a diagnostic pointing deep inside <vector>.

Respell the four operators to return const_pointer_iterator.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
Apple clang emits the thread-local initialization routine of an
`inline static thread_local` data member with non-weak linkage.  Every
other symbol the member generates comes out weak - the guard variable
and both Cache constructors are `weak private external` - but

  __ZTHN23CachedStackStringStream5cacheE

is plain `private external`, so any two translation units that both
instantiate it collide:

  duplicate symbol 'thread-local initialization routine for
  CachedStackStringStream::cache' in:
      SimpleRADOSStriper.cc.o
      libcephsqlite.cc.o

Most link units get away with it because only one of their translation
units touches the cache; libcephsqlite.dylib is built from exactly two
and both log.

Hold the cache as a function-local thread_local inside an inline
accessor instead.  That has the vague linkage the data member was meant
to have, on every compiler, and the initialization routine stops being
emitted as a distinct external symbol altogether.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
The header says `int truncate(size_t size)` and the definition says
`int SimpleRADOSStriper::truncate(uint64_t size)`.  LP64 Linux makes
those one type, so nothing notices; on Darwin size_t is `unsigned long`
and uint64_t is `unsigned long long`, and they are distinct:

  SimpleRADOSStriper.cc:144:25: error: out-of-line definition of
  'truncate' does not match any declaration in 'SimpleRADOSStriper'

Take uint64_t, which the definition already uses and which is what the
rest of the class spells for a position or a size of the striped file -
stat() reports into a uint64_t, and read() and write() take their
offsets as one.  size_t is left for the buffer lengths, which is what it
describes.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
ObjectModel.cc passes std::execution::seq to nine std::generate calls.
libc++ installs <execution>, so the include is satisfied, but it
implements no parallel algorithms and so defines none of the policy
objects:

  error: no member named 'seq' in namespace 'std::execution'

std::execution::seq asks for the algorithm to run on the calling thread,
in the calling thread's order - which is what the overload taking no
policy at all already guarantees.  Dropping the argument therefore keeps
the behaviour identical on every platform, rather than trading anything
away for the sake of one, and the header goes with it as it has no other
use here.

The TBB link in CMakeLists.txt existed only because libstdc++ implements
<execution> with TBB, so drop it too.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
@dvanders
dvanders force-pushed the wip-macos-1-portability branch from a983419 to b32e771 Compare October 5, 2026 22:36
@dvanders
dvanders requested a review from wjwithagen October 5, 2026 22:37

@wjwithagen wjwithagen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for FreeBSD.

@dvanders

dvanders commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath5-testing-20261012.095720-main.

@kamoltat

kamoltat commented Nov 4, 2026

Copy link
Copy Markdown
Member

@kamoltat
kamoltat merged commit 3e05594 into ceph:main Nov 4, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants