Skip to content

cmake: correct build dependencies that are not present on every platform - #71885

Merged
idryomov merged 7 commits into
ceph:mainfrom
dvanders:wip-macos-3-builddeps
Oct 12, 2026
Merged

idryomov merged 7 commits into
ceph:mainfrom
dvanders:wip-macos-3-builddeps

Conversation

@dvanders

Copy link
Copy Markdown
Contributor

Split out of #71232, which reviewers asked to see in smaller batches.
Based on main; independent of the other six.

Libraries and plugins named on a link line or added to the build
unconditionally, where they are not available, or not built, everywhere:

  • libnbd is required only where rbd-nbd is built
  • the extblkdev vdo and fcm plugins are Linux-specific
  • cephfs-tool names uring::uring whether or not liburing was built
  • osd uses common/ceph_crypto.h without linking OpenSSL
  • compressor/zlib compiles its ISA-L path without checking it was built
  • rgw_common names keyring, which is built only under HAVE_KEYUTILS,
    though keyring.cc is already portable and falls back to
    UnsupportedKeyring
  • ceph_bench_log and ten test binaries name librt and
    -Wl,--copy-dt-needed-entries

On the last two points, and on libnbd: the guards name APPLE rather than
narrowing to LINUX, per review on #71232 — FreeBSD has librt and should
keep linking it. extblkdev is the one place that does name LINUX, and
the commit message says why: libblkid is util-linux', and the top-level
CMakeLists.txt already sets HAVE_BLKID OFF on FreeBSD.

Thanks to @idryomov and @wjwithagen for the review that shaped these.

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

@idryomov idryomov 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.

Ack from the RBD perspective

Comment thread src/tools/cephfs/CMakeLists.txt Resolved
Comment thread CMakeLists.txt Resolved
Comment thread src/test/CMakeLists.txt Resolved
Comment thread src/test/libcephfs/CMakeLists.txt Resolved
Comment thread src/test/fs/CMakeLists.txt Resolved
Comment thread src/rgw/rgw_main.cc Resolved
Comment thread src/extblkdev/CMakeLists.txt Resolved
Comment thread src/common/CMakeLists.txt Resolved
@github-actions

Copy link
Copy Markdown

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

Comment thread src/rgw/CMakeLists.txt Resolved

@adamemerson adamemerson 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.

Approved for RGW.

libnbd is not packaged for macOS or FreeBSD, so requiring it there fails
the configure step.  librbd guards every use of libnbd behind
HAVE_LIBNBD, and rbd-nbd, which does need it, is only built on Linux.
Exclude both alongside Windows.

Suggested-by: Ilya Dryomov <[email protected]>
Suggested-by: Willem Jan Withagen <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
Assisted-by: Claude Opus 5.5 <[email protected]>
fcm includes <blkid/blkid.h>, but it was added to the build unconditionally,
so configuring anywhere without libblkid failed to compile it.  The
top-level CMakeLists.txt sets HAVE_BLKID OFF everywhere but Linux, FreeBSD
included, so key the plugin on that rather than on the platform.

vdo needs nothing Linux-specific to build - it only looks for /sys/kvdo at
run time, and finds nothing where there is none - so it stays in the build
everywhere.

Suggested-by: Willem Jan Withagen <[email protected]>
Assisted-by: claude-code:claude-opus-5.5
Signed-off-by: Dan van der Ster <[email protected]>
The osd library includes common/ceph_crypto.h, which includes
<openssl/evp.h>, but never declared the dependency.  That only works where
OpenSSL happens to sit in a default include path.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
ZlibCompressor.cc guarded its ISA-L paths with a repeated
(__x86_64__ && HAVE_NASM_X64_AVX2) || __aarch64__ || HAVE_RISCV_RVV
condition, and included igzip_lib.h unconditionally.  That is not the
condition CMakeLists.txt uses to decide whether to compile the ISA-L
sources: the x86 branch there also requires HAVE_INTEL_SSE4_1 and is
skipped entirely on APPLE, and the ARM branch keys off HAVE_ARMV8_SIMD
rather than the architecture macro.

Where the two disagree the plugin does not link.  An Intel Mac with
nasm installed is the plainest case: CMake compiles no ISA-L object,
but __x86_64__ && HAVE_NASM_X64_AVX2 holds, so the compressor still
calls isal_deflate().  An aarch64 target whose compiler rejects
-march=armv8-a+simd fails the same way through __aarch64__.

Set have_isal in the branches that actually compile the ISA-L sources
and have them define HAVE_ISAL, then key the compressor off that one
macro, so the code and the build cannot drift apart again.  Where
ISA-L was not built, compressor_zlib_isal=true degrades to plain zlib
with the existing warning.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
…ntry point

rgw_common named keyring and rt on its link line unconditionally.  On
Darwin the keyring target was not built, since it depended on
HAVE_KEYUTILS, and there is no librt.

keyring.cc already includes <keyutils.h> only on Linux, and
Keyring::get_best() returns UnsupportedKeyring elsewhere, so build it
everywhere and make only the keyutils link conditional.  Link librt
through RT_LIBRARY, which CephChecks.cmake finds wherever POSIX timers
need it, and leaves empty elsewhere.

rgw_main.cc called LinuxKeyringSecret::initialize_process_keyring()
unguarded, although it is only defined on Linux.  Guard it the same way,
and elsewhere log at level 0 that the SSE-KMS key cache is disabled,
since that cache needs the kernel keyring.

Suggested-by: Willem Jan Withagen <[email protected]>
Suggested-by: Kefu Chai <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
Assisted-by: Claude Opus 5.5 <[email protected]>
ceph_bench_log linked rt on everything but Windows, but Darwin has no
librt.  Use RT_LIBRARY from CephChecks.cmake, which is empty wherever
librt is not needed.

Suggested-by: Kefu Chai <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
Assisted-by: Claude Opus 5.5 <[email protected]>
The ten target_link_options() calls adding -Wl,--copy-dt-needed-entries
are guarded with if(NOT WIN32), but the flag is GNU ld's.  The comment at
the top of test/libcephfs/CMakeLists.txt records what it is for: GNU ld
refusing to look past the libraries named on the command line and
reporting "DSO missing from command line" for a symbol libcephfs.so needs
from libceph-common.so.

Apple's linker has neither the behaviour nor the option, and says so::

  ld: unknown options: --copy-dt-needed-entries

which fails eight of these test binaries.  Exclude macOS alongside
Windows.  Narrowing to LINUX instead would take FreeBSD with it; the
answer there may well be that it does not want the flag either, its
linker being lld rather than GNU ld, but that is for someone who can run
the build to say.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
@dvanders
dvanders force-pushed the wip-macos-3-builddeps branch from ed06323 to b0424c3 Compare October 1, 2026 22:08

@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

@dvanders

dvanders commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test api

@anrao19

anrao19 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-10-08-10:48.

@anrao19

anrao19 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-10-08-10:48.

pr testing completed and approved by @ivancich, more details in https://tracker.ceph.com/issues/81545.
@dvanders , if further is not needed then this can be merged

@idryomov
idryomov merged commit d9e91fc into ceph:main Oct 12, 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.

6 participants