Skip to content

fix(cmake): replace obsolete -s with -Wl,-x on Apple linker#5345

Merged
matejk merged 1 commit into
mainfrom
fix/cmake-macos-strip-link-option
May 6, 2026
Merged

fix(cmake): replace obsolete -s with -Wl,-x on Apple linker#5345
matejk merged 1 commit into
mainfrom
fix/cmake-macos-strip-link-option

Conversation

@matejk
Copy link
Copy Markdown
Contributor

@matejk matejk commented May 6, 2026

Problem

Every Release link on macOS prints:

ld: warning: -s is obsolete

Apple's linker (ld64 / ld-prime, Xcode 15+) deprecated the -s flag introduced for size reduction in #5297. The link still strips, but the warning is emitted on every shared library and executable. LLVM's lld accepts -s silently — the warning is specific to Apple's ld.

Change

Gate the strip flag by platform in cmake/DefinePlatformSpecific.cmake:

  • Apple: -Wl,-x — Apple's documented replacement. Strips local symbols while keeping dynamic exports needed for .dylibs.
  • Other Unix (GCC/Clang on Linux/BSD): -s retained, unchanged.
  • MSVC: intentionally no change. PE binaries do not carry a strippable symbol table — debug info lives in separate .pdb files. There is no -s equivalent on Windows.

Verification

Local rebuild on macOS (Xcode 16, Apple clang) of the Foundation/Util chain:

  • ld: warning: -s is obsolete — gone.
  • nm libPocoUtil.dylib shows 640 global text symbols, 0 local (lowercase) symbols → strip is effective.
  • Util test suite: OK (244 tests).

Notes

  • Out of scope: the /OPT:REF and /OPT:ICF flags 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.
  • Bit-for-bit equivalence to GNU -s would also pass -Wl,-S (strip debug info) on Apple, but clang on macOS emits DWARF into object files and only collects it into a .dSYM on demand, so the linked output rarely carries debug info; -Wl,-x alone matches the size-reduction goal.

@matejk matejk added this to the Release 1.15.3 milestone May 6, 2026
@matejk matejk merged commit 4e6ef00 into main May 6, 2026
52 checks passed
@matejk matejk deleted the fix/cmake-macos-strip-link-option branch May 6, 2026 10:22
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.

1 participant