Skip to content

OSX: linker omits zone.o when statically linking jemalloc #708

@tamird

Description

@tamird

In my testing, the macOS linker always omits zone.o when linking statically. See cockroachdb/cockroach#15275 where we ran into this after switching to jemalloc's native build system.

I believe this is at least a documentation issue, since anyone statically linking jemalloc on macOS is probably not getting zone registration in their binary.

EDIT: the below was found to be a red herring, but remains for posterity.

We observed an issue where jemalloc was not being called from our C++ code in CockroachDB.

For context, we are (ab)using the Go build system to link jemalloc, rocksdb, and other non-Go libraries into CockroachDB. A consequence of this is that those libraries are linked statically.

For reasons I don't fully understand, the dynamic linker on OSX behaves in such a way that when libc++ is dynamically linked, the C++ operators new and delete do not call jemalloc as I would expect, instead apparently using the system allocator. The problem is not observed when linking jemalloc dynamically.

cc @petermattis @bdarnell @benesch @a-robinson

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions