https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123052
Bug ID: 123052
Summary: Linking for macOS with gcc breaks clang object files
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: ossman at cendio dot se
Target Milestone: ---
If you try to use gcc to produce binaries for macOS, and one of the object
files used was produced by clang, then the resulting binary is broken.
Specifically, exceptions do not work because the unwinding information is
missing for the clang object file.
The problem stems from PR41260, where gcc adds -no_compact_unwind to the linker
to work around an incompatibility between gcc and the linker.
The second key ingredient is that clang produces compact unwind information for
its objects files, rather than relying on the linker to do that.
These together trigger a buggy corner case in Apple's linker. There is no
compact unwind information output because of -no_compact_unwind. And there is
no DWARF information because ld64 thought it could drop it as the clang object
file already had compact unwind information.
(also note that the target needs to be at least 10.9 for ld64 to have this
behaviour)
We've worked around this by also specifying -keep_dwarf_unwind, which should
restore the original behaviour.
But what is the status of dropping -no_compact_unwind? Compact unwind seems to
be what Apple expects since a long time back.