Repository navigation
cmake: select the linker with CMAKE_LINKER_TYPE - #72620
Conversation
|
jenkins test windows |
|
Added a commit that passes --copy-dt-needed-entries only where the linker accepts it (the libcephfs/fs tests failed to link with lld and mold), and split the doc commit into a grouping commit shared with #71901 plus the linker section. |
|
jenkins test make check |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
jenkins test windows |
|
jenkins test make check |
|
jenkins test make check arm64 |
|
jenkins test api |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
librados now checks whether CMake defines the BFD linker type instead of checking the CMake version: CMake defines linker types for FreeBSD only from 4.2 on, so LINKER_TYPE BFD failed to configure there with 3.29 to 4.1. Without the type it falls back to -fuse-ld=bfd. @wjwithagen, could you check this on FreeBSD? |
I've been offline for a few days, and catching up on my Ceph stuff. And as further remarks:
So I'm not using ld-bfd or gnu-ld, as far as my recollection goes, but that I'll check as well. |
check_linker_flag() caches its result, so a build tree configured with ld.bfd keeps passing the option after switching to lld or mold, which reject it. Unset the cached result before the check. Assisted-by: claude-opus-5-5 Signed-off-by: Dominik Raddatz <[email protected]>
|
jenkins test make check |
tchaikov
left a comment
There was a problem hiding this comment.
we are close. i'd wait for @wjwithagen 's check once the last comment is addressed.
WITH_MOLD only knew mold. Select the linker with CMAKE_LINKER_TYPE (BFD, LLD, MOLD) instead, which CMake handles from 3.29 on; older CMake gets it as -fuse-ld. Drop WITH_MOLD, which is in no release; use -DCMAKE_LINKER_TYPE=MOLD instead. librados always links with ld.bfd where it uses symvers. lld rejects its base-version symvers; mold drops them, so a mold-linked librados exported rados_connect and friends as LIBRADOS_PRIVATE and lost the four compat definitions. That, not --exclude-libs, hid rados_* under mold, so stop disabling --exclude-libs for mold. On FreeBSD, the GNU ld default for Clang now only applies when no linker is selected; it used to override the -fuse-ld of older CMake. Python extensions get the linker through LDFLAGS below CMake 3.29 and through CMAKE_C_USING_LINKER_<TYPE> in LDSHARED from 3.29 on, which replaces the mold case in Distutils. Assisted-by: claude-opus-5-5 Signed-off-by: Dominik Raddatz <[email protected]>
The _rados_* glob added to librados.map for mold exports the 250 internal functions behind the C API. librados now links with ld.bfd wherever it uses symvers, so drop it. Assisted-by: claude-opus-5-5 Signed-off-by: Dominik Raddatz <[email protected]>
Make ccache a subsection of a new "Speeding up local builds" section, so other ways to shorten builds can sit next to it. Assisted-by: claude-opus-5-5 Signed-off-by: Dominik Raddatz <[email protected]>
List the linker first among the build speed-ups: it needs only a package and costs neither disk space nor memory. Assisted-by: claude-opus-5-5 Signed-off-by: Dominik Raddatz <[email protected]>
|
@wjwithagen One more FreeBSD change since my last comment: the Clang block in When you get to it, could you check these on FreeBSD?
Which CMake version do you build with? |
FreeBSD 14 and on have atleast CMake 3.31 |
|
(LONG LONG answer below) Short answer: Oke, perhaps not the answer you are looking for, but none the less: My working tree is in wjwithagen:ceph-freebsd. (https://github.com/wjwithagen/ceph/tree/ceph-freebsd) Note that in so I don't force any other linker than LDD, which is verified in the LINKER vars in: wjw@> /usr/bin/clang++ -v -fPIC -g -DCEPH_DEV -O0 -g -Wno-unused-command-line-argument -Wno-unused-command-line-argument -Wl,--exclude-libs,ALL -Wl,--version-script=/home/wjw/Src/Ceph/wip-pr-test/src/librados/librados.map -fexperimental-library -Xlinker --dependency-file=src/librados/CMakeFiles/librados.dir/link.d -shared -Wl,-soname,librados.so.2 -o lib/librados.so.2.0.0 src/common/CMakeFiles/common_buffer_obj.dir/buffer.cc.o src/librados/CMakeFiles/librados.dir/librados_c.cc.o src/librados/CMakeFiles/librados.dir/librados_cxx.cc.o -L/usr/local/lib -Wl,-rpath,/usr/local/lib:/home/wjw/Src/Ceph/wip-pr-test/build/lib: lib/liblibrados_impl.a lib/libosdc.a lib/libceph-common.so.2 lib/libcls_lock_client.a /usr/local/lib/libcrypto.so /usr/lib/librt.so lib/libcommon_utf8.a lib/libextblkdev.a /usr/local/lib/libboost_thread.so.1.91.0 /usr/local/lib/libboost_atomic.so.1.91.0 /usr/local/lib/libboost_chrono.so.1.91.0 /usr/local/lib/libboost_context.so.1.91.0 /usr/local/lib/libboost_program_options.so.1.91.0 /usr/local/lib/libboost_container.so.1.91.0 /usr/local/lib/libboost_date_time.so.1.91.0 /usr/local/lib/libboost_iostreams.so.1.91.0 /usr/local/lib/libboost_random.so.1.91.0 /usr/local/lib/libboost_regex.so.1.91.0 lib/libfmtd.a /usr/lib/libexecinfo.so -lpthread -lrt wjw@> readelf -V /home/wjw/Src/Ceph/wip-pr-test/build/lib/librados.so.2.0.0 | grep -A6 version_d |
|
jenkins retest this please |
|
@wjwithagen thanks for testing! Your tree differs from the PR in two places: the FreeBSD block no longer adds Could you share your For this PR, checks 1 and 2 from my last comment are still open on the unmodified branch. |
From the last query I think you're are missing the 14_2_0 variants? So perhaps we need to add those (and others to the map? |
|
@wjwithagen thanks! If I read I assume your map edits drop entries for symbols your librados doesn't define. In my test, lld rejected such entries and ld.bfd ignored them. On Linux with Boost 1.87 the That would leave check 1: with the FreeBSD block as in the PR and no |
If you'd specify explicitly to use And like I said, |
|
@wjwithagen thanks! Then the PR leaves the default FreeBSD build as on main: without @tchaikov I think the FreeBSD side is settled. Is anything else missing here? |
|
@Doracly could you push this change to ceph-ci to verify that the tree still builds with this change? |
|
@tchaikov ceph-ci built fff3bd9 on all 8 x86_64 targets, including the debug flavor on CentOS 9, Rocky 10 and Ubuntu 24.04: https://shaman.ceph.com/builds/ceph/wip-doracly-lld-linker/ |
|
thanks! merged. |
Summary
-DCMAKE_LINKER_TYPE=BFD|LLD|MOLDselects the linker and makes lld usable. Of the three, lld links Ceph fastest and with the least CPU and memory (numbers below). It replacesWITH_MOLD, which is in no release and is removed rather than deprecated.CMake handles
CMAKE_LINKER_TYPEfrom 3.29 on; older CMake gets it as-fuse-ld. The Python extensions, which setuptools links, get the same linker either way.The last two commits group the build speed-ups in the developer guide under one section and document the option there, ahead of ccache: it needs only a package and costs neither disk space nor memory. The grouping commit is identical to the one in #71901, so the two PRs merge cleanly in either order.
Fixes to the mold support from #69711
librados_c.cc, so a mold-linked librados exportedrados_connectand friends asLIBRADOS_PRIVATEand lost the four compat definitions; lld rejects them outright. librados now always links with ld.bfd where it uses symvers.--exclude-libs, is what hidrados_*under mold, so the workaround that disabled--exclude-libsfor mold is dropped._rados_*glob added tolibrados.mapmade every build, including ld.bfd ones, export the 250 internal_rados_*functions behind the C API. A separate commit removes it.--copy-dt-needed-entriesin the libcephfs and fs tests#71494 passes the option only where
check_linker_flag()accepts it. That caches its result, so a tree configured with ld.bfd keeps passing the option after switching to lld or mold, which reject it. The first commit unsets the cached result before the check, so it reruns on each configure.Testing
Clang 21 + lld (with crimson) and GCC 15 + mold, Debug, before the rebase onto #71494:
allbuilds; every binary and library loads with all symbols resolved (ldd -r), apart from plugins that take symbols from their hostrados_*versions unchanged, no_rados_*)HEALTH_OK, rados put/get, rbd create, Pythonrados,rbd,cephfsandrgwimport,ceph-dencoder list_typesunittest_*: 252/252 passed with bothBFD,LLD,MOLD, unusable linkerConfiguring one tree (CMake 4.2, Clang 21) with
BFD,LLD,BFDandMOLDin turn passes--copy-dt-needed-entriesto 10, 0, 10 and 0 targets and gives the Python extensions the same linker when building and installing.With mold < 3.0,
ceph-dencoderadditionally needs #73958.Link performance
Clang Debug (
-O0), idle 24-thread machine, outputs on tmpfs, the default 13parallel links:
mold is faster only one link at a time (the vstart set in sequence: mold 5.4 s,
lld 7.0 s, ld.bfd 46 s) and is CPU-bound from four parallel links on.
lld 17 to 21 perform the same. With
-Ogobjects all three link faster(ld.bfd about 2x).
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.