Skip to content

Backfill <experimental/memory_resource> for Xcode 16 compatibility - #9

Merged
steve-baker-cradle merged 2 commits into
mainfrom
xcode-16-compat
Oct 2, 2026
Merged

steve-baker-cradle merged 2 commits into
mainfrom
xcode-16-compat

Conversation

@steve-baker-cradle

Copy link
Copy Markdown
Contributor

Xcode 16's libc++ removed <experimental/memory_resource>. std::pmr is only available in the macOS system libc++ from macOS 14, it compiles cleanly against an older deployment target and then fails to load on older systems with a missing std::__1::pmr::memory_resource vtable.

This implements memory_resource interface and polymorphic_allocator on macOS. Both are header-only, so nothing uses the system C++ library.

memory_resource's destructor is defined inline so the class has no Itanium ABI "key function" - its vtable is emitted into every consuming object file rather than being looked up at load time.

pmr_shim.h authored by Claude. I've reviewed and all looks reasonable. Unit tests pass on Windows/VS2019 and macOS 15/Xcode 16.4.

Xcode 16's libc++ removed <experimental/memory_resource>. std::pmr
is only available in the macOS system libc++ from macOS 14, it compiles
cleanly against an older deployment target and then fails to load on
older systems with a missing std::__1::pmr::memory_resource vtable.

This implements memory_resource interface and polymorphic_allocator on macOS.
Both are header-only, so nothing uses the system C++ library.

memory_resource's destructor is defined inline so the class has no
Itanium ABI "key function" - its vtable is emitted into every consuming
object file rather than being looked up at load time.

@tommaisey tommaisey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had hoped to avoid reimplementing this header, but I think macOS's clang/libc++ versions have backed us into a corner. If this works, then I'm ok with it 👍

@steve-baker-cradle
steve-baker-cradle merged commit 207294b into main Oct 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants