Skip to content

cmake: drop the boost::filesystem dependency - #71926

Merged
tchaikov merged 4 commits into
ceph:mainfrom
tchaikov:wip-drop-boost-filesystem
Sep 28, 2026
Merged

tchaikov merged 4 commits into
ceph:mainfrom
tchaikov:wip-drop-boost-filesystem

Conversation

@tchaikov

@tchaikov tchaikov commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

No first-party code has used boost::filesystem since 71e2027 converted rgw_lua to std::filesystem. The library survived because Boost.Process v1 aliases boost::process::v1::filesystem to it by default, so the two callers of bp::search_path() drag it in: rgw_lua.cc, and ProgressTracker.cc, which is compiled into cephfs-journal-tool, cephfs-table-tool and cephfs-data-scan. cephfs-meta-injection is the one tool in that directory that does not compile ProgressTracker.cc, and the one that never linked the library.

  • Define BOOST_PROCESS_USE_STD_FS so bp::filesystem is std::filesystem, and drop the component requests and link entries. It is set tree-wide rather than per target because it changes the type of bp::filesystem::path in inline code: a binary linking objects built both ways would be an ODR violation.
  • Targets whose translation units reach std::filesystem through Boost.Process link StdFilesystem::filesystem, which supplies -lstdc++fs on toolchains that still need it and is empty elsewhere.
  • The bundled Boost now builds one library fewer. install-deps.sh still installs ceph-libboost-filesystem for the WITH_SYSTEM_BOOST path; that list covers header-only libraries too, so it is left alone.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

Boost.Process v1's POSIX pipe helpers use boost::system::error_code without
including the header that declares it:

  boost/process/v1/detail/posix/pipe_in.hpp:79:  boost::system::error_code ec;
  boost/process/v1/detail/posix/pipe_out.hpp:111: boost::system::error_code ec;

These compile today only because boost/process pulls in boost/filesystem,
whose headers declare boost::system on the way past. Every translation unit
including boost/process therefore depends on an include that has nothing to
do with what it asks for, and loses the declaration the moment that path
changes.

Include the header where it is used instead.

Signed-off-by: Kefu Chai <[email protected]>

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

Targets whose translation units reach std::filesystem through Boost.Process link StdFilesystem::filesystem, which supplies -lstdc++fs on toolchains that still need it and is empty elsewhere.

Do we still care about those toolchains? Looking at https://en.cppreference.com/cpp/filesystem#Notes:

GNU implementation prior to 9.1 requires linking with -lstdc++fs and LLVM implementation prior to LLVM 9.0 requires linking with -lc++fs.

Perhaps StdFilesystem::filesystem could be dropped too?

CephChecks.cmake stops the build if GCC is older than 8.1. But
src/CMakeLists.txt already requires GCC 11 or newer (10 on win32, 13
with crimson). So the old check has no effect.

Signed-off-by: Kefu Chai <[email protected]>
FindStdFilesystem finds the library that provides std::filesystem. It
tries no library, then stdc++fs, then c++fs. Only compilers older than
GCC 9.1 and LLVM 9.0 need a separate library. We need at least GCC 11
or Clang 16, and both have std::filesystem in the standard library. So
the module always picks "no library", and StdFilesystem::filesystem is
an empty target.

Remove the module and all links to it. ceph_test_admin_socket_output
was built only when StdFilesystem was found. It is always found, so
always build the test.

Suggested-by: Ilya Dryomov <[email protected]>
Signed-off-by: Kefu Chai <[email protected]>
Our code has not used boost::filesystem since 71e2027 changed
rgw_lua to std::filesystem. We still link the library because
Boost.Process v1 uses it for boost::process::v1::filesystem by default.
Two files call bp::search_path(): rgw_lua.cc and ProgressTracker.cc.
ProgressTracker.cc is built into cephfs-journal-tool, cephfs-table-tool
and cephfs-data-scan. cephfs-meta-injection does not build it, and it
is the only tool in that directory that never linked the library.

Define BOOST_PROCESS_USE_STD_FS, so bp::filesystem is std::filesystem,
and remove the Boost filesystem component and its link entries. We
define the macro for the whole tree, not per target. It changes the
type of bp::filesystem::path in inline code, so linking objects built
with and without it would violate the ODR.

With our compilers std::filesystem needs no separate library, so we
link nothing in its place. The WITH_RADOSGW_LUA_PACKAGES blocks in the
rgw CMakeLists.txt files only linked Boost::filesystem, so remove them
too.

The bundled Boost now builds one library less. install-deps.sh still
installs ceph-libboost-filesystem for WITH_SYSTEM_BOOST. That list also
has header-only libraries, so leave it as is.

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov
tchaikov force-pushed the wip-drop-boost-filesystem branch from 16f5454 to c7f3a44 Compare September 23, 2026 07:07
@tchaikov
tchaikov requested a review from a team as a code owner September 23, 2026 07:07
@github-actions github-actions Bot added the rbd label Sep 23, 2026
@tchaikov

Copy link
Copy Markdown
Contributor Author

#71999 was inspired the cmake change.

@tchaikov

Copy link
Copy Markdown
Contributor Author

Targets whose translation units reach std::filesystem through Boost.Process link StdFilesystem::filesystem, which supplies -lstdc++fs on toolchains that still need it and is empty elsewhere.

Do we still care about those toolchains? Looking at https://en.cppreference.com/cpp/filesystem#Notes:

Nah. dropped.

GNU implementation prior to 9.1 requires linking with -lstdc++fs and LLVM implementation prior to LLVM 9.0 requires linking with -lc++fs.

Perhaps StdFilesystem::filesystem could be dropped too?

indeed. gone.

@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

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

@anrao19

anrao19 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-09-24-06:02.

@anrao19

anrao19 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-09-24-06:02.

RGW pr testing is completed and approved by @ivancich, more details in : https://tracker.ceph.com/issues/80827
@tchaikov , ACK from RGW

@anrao19 anrao19 added RGW-TESTED testing from rgw completed and removed wip-anrao1-testing labels Sep 28, 2026
@tchaikov
tchaikov merged commit 483d226 into ceph:main Sep 28, 2026
17 checks passed
@tchaikov
tchaikov deleted the wip-drop-boost-filesystem branch September 28, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants