Skip to content

cmake: only pass --copy-dt-needed-entries to linkers that accept it - #71494

Merged
tchaikov merged 1 commit into
ceph:mainfrom
wjwithagen:wip-clang-copy-dt-needed
Nov 8, 2026
Merged

tchaikov merged 1 commit into
ceph:mainfrom
wjwithagen:wip-clang-copy-dt-needed

Conversation

@wjwithagen

@wjwithagen wjwithagen commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

c6ac71d added -Wl,--copy-dt-needed-entries to work around GNU ld on
Ubuntu 22.04 (https://tracker.ceph.com/issues/70498). The option is
specific to GNU ld; other linkers, such as lld on FreeBSD, Apple's ld
on macOS and lld in MinGW mode, reject it, so linking fails there.

Test the linker once in src/CMakeLists.txt with check_linker_flag()
and guard each use with HAVE_LINK_COPY_DT_NEEDED_ENTRIES.

Suggested-by: Dan van der Ster [email protected]
Signed-off-by: Willem Jan Withagen [email protected]

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.

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

Otherwise LGTM.

Comment thread CMakeLists.txt Resolved
@wjwithagen
wjwithagen force-pushed the wip-clang-copy-dt-needed branch from 5154690 to 186bb53 Compare September 9, 2026 15:19
@wjwithagen
wjwithagen requested a review from batrick September 9, 2026 15:20
@wjwithagen

Copy link
Copy Markdown
Member Author

jenkins test api

@djgalloway

Copy link
Copy Markdown
Contributor

jenkins test make check

@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

@wjwithagen
wjwithagen force-pushed the wip-clang-copy-dt-needed branch from 186bb53 to a305b77 Compare October 13, 2026 09:14
@wjwithagen
wjwithagen requested a review from dvanders October 13, 2026 09:15
@wjwithagen

Copy link
Copy Markdown
Member Author

@dvanders Hi Dan,
I'm replacing here your NOT APPLE with NOT CLANG, since this is a compiler dependancy and not a OS issue perse.
And otherwise I'd be adding another NOT FREEBSD clause.

@dvanders

Copy link
Copy Markdown
Contributor

@wjwithagen agreed it isn't an OS issue, but I don't think it's a compiler one either: it's the linker. Patrick added the flag (c6ac71d, https://tracker.ceph.com/issues/70498) to work around GNU ld on Ubuntu 22.04, and clang on Linux uses that same GNU ld unless told otherwise, so NOT CLANG would drop the workaround for clang builds on Ubuntu. Going the other way, gcc on macOS would now pass a GNU-only flag to Apple's ld.

How about testing the linker directly, once in the top-level CMakeLists.txt:

include(CheckLinkerFlag)
check_linker_flag(CXX "-Wl,--copy-dt-needed-entries" HAVE_LINK_COPY_DT_NEEDED_ENTRIES)

and guarding each use with if(HAVE_LINK_COPY_DT_NEEDED_ENTRIES)? That covers GNU ld, lld, ld64, mold and Windows without listing platforms (check_linker_flag is already used in src/rgw/CMakeLists.txt).

c6ac71d added -Wl,--copy-dt-needed-entries to work around GNU ld on
Ubuntu 22.04 (https://tracker.ceph.com/issues/70498). The option is
specific to GNU ld; other linkers, such as lld on FreeBSD, Apple's ld
on macOS and lld in MinGW mode, reject it, so linking fails there.

Test the linker once in src/CMakeLists.txt with check_linker_flag()
and guard each use with HAVE_LINK_COPY_DT_NEEDED_ENTRIES.

Suggested-by: Kefu Chai <[email protected]>
Suggested-by: Dan van der Ster <[email protected]>
Signed-off-by: Willem Jan Withagen <[email protected]>
@wjwithagen
wjwithagen force-pushed the wip-clang-copy-dt-needed branch from a305b77 to 8b22b95 Compare October 19, 2026 16:06
@wjwithagen wjwithagen changed the title cmake: skip -Wl,--copy-dt-needed-entries when building with clang cmake: only pass --copy-dt-needed-entries to linkers that accept it Oct 19, 2026
@wjwithagen

Copy link
Copy Markdown
Member Author

@dvanders Took your suggestion to make a separate FLAG for this....
And conditionalize the tests with this linking-flag.

@wjwithagen
wjwithagen requested a review from batrick October 19, 2026 16:09

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

Thanks Willem, this is what I had in mind. All 11 uses are now guarded by the one linker check, so it does the right thing with GNU ld (including clang on Linux), lld, ld64 and MinGW without listing platforms.

I checked the probe against Apple's ld (ld-27037): HAVE_LINK_COPY_DT_NEEDED_ENTRIES comes out false there while a flag ld64 does know passes, and make check is green on Linux, where the flag is still used. LGTM.

@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

@tchaikov

tchaikov commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@wjwithagen could you push this change to ceph-ci, so we can verify that it still builds on these builders?

@wjwithagen

Copy link
Copy Markdown
Member Author

@wjwithagen could you push this change to ceph-ci, so we can verify that it still builds on these builders?

Never done that I guess, so not sure how to do that...

@tchaikov

tchaikov commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

it's a repo at https://github.com/ceph/ceph-ci. the branches pushed to it are picked up by jenkins and jenkins builds packages from them with configured builders. see shaman.ceph.com/builds/ceph/

anyway, just pushed to this repo. the build result will show up at https://shaman.ceph.com/builds/ceph/wip-pr-71494-kefu/

@tchaikov
tchaikov merged commit 08f4d0f into ceph:main Nov 8, 2026
20 of 21 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