fix(cmake): replace obsolete -s with -Wl,-x on Apple linker#5345
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every Release link on macOS prints:
Apple's linker (ld64 / ld-prime, Xcode 15+) deprecated the
-sflag introduced for size reduction in #5297. The link still strips, but the warning is emitted on every shared library and executable. LLVM'slldaccepts-ssilently — the warning is specific to Apple'sld.Change
Gate the strip flag by platform in cmake/DefinePlatformSpecific.cmake:
-Wl,-x— Apple's documented replacement. Strips local symbols while keeping dynamic exports needed for.dylibs.-sretained, unchanged..pdbfiles. There is no-sequivalent on Windows.Verification
Local rebuild on macOS (Xcode 16, Apple clang) of the Foundation/Util chain:
ld: warning: -s is obsolete— gone.nm libPocoUtil.dylibshows 640 global text symbols, 0 local (lowercase) symbols → strip is effective.Notes
/OPT:REFand/OPT:ICFflags on MSVC are dead-code/folding parallels of-Wl,-dead_strip/--gc-sections/--icf=safe, not of-s. They are MSVC linker defaults for Release already; making them explicit can be a separate follow-up if desired.-swould also pass-Wl,-S(strip debug info) on Apple, but clang on macOS emits DWARF into object files and only collects it into a.dSYMon demand, so the linked output rarely carries debug info;-Wl,-xalone matches the size-reduction goal.