From 4cb7c0b98234d221da91926332dc739c829085f4 Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Thu, 23 May 2024 20:06:00 -0700 Subject: [PATCH] don't use prefixed jemalloc with rocksdb This is causing build failures on Mac: > In file included from /tmp/nix-build-rocksdb-static-aarch64-apple-darwin-9.1.1.drv-0/source/memory/memory_allocator.cc:8: > In file included from /tmp/nix-build-rocksdb-static-aarch64-apple-darwin-9.1.1.drv-0/source/memory/jemalloc_nodump_allocator.h:11: > /tmp/nix-build-rocksdb-static-aarch64-apple-darwin-9.1.1.drv-0/source/port/jemalloc_helper.h:63:36: warning: unknown attribute '_rjem_malloc' ignored [-Wunknown-attributes] > mallocx(size_t, int) JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1) > ^~~~~~ > /nix/store/3bix0kzy670dyhhizri3dwb1qfj3sdpa-jemalloc-static-aarch64-apple-darwin-5.3.0/include/jemalloc/jemalloc.h:412:18: note: expanded from macro 'malloc' > # define malloc je_malloc > ^~~~~~~~~ > /nix/store/3bix0kzy670dyhhizri3dwb1qfj3sdpa-jemalloc-static-aarch64-apple-darwin-5.3.0/include/jemalloc/jemalloc.h:75:21: note: expanded from macro 'je_malloc' > # define je_malloc _rjem_malloc > ^~~~~~~~~~~~ > /nix/store/3bix0kzy670dyhhizri3dwb1qfj3sdpa-jemalloc-static-aarch64-apple-darwin-5.3.0/include/jemalloc/jemalloc.h:183:43: note: expanded from macro 'JEMALLOC_ATTR' > # define JEMALLOC_ATTR(s) __attribute__((s)) Full build log at . This is likely fixable with patches to rocksdb, but not worth it since darwin is only a dev platform. --- nix/pkgs/main/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nix/pkgs/main/default.nix b/nix/pkgs/main/default.nix index 87f260f8..c7161697 100644 --- a/nix/pkgs/main/default.nix +++ b/nix/pkgs/main/default.nix @@ -59,7 +59,13 @@ buildDepsOnlyEnv = let rocksdb' = rocksdb.override { jemalloc = rust-jemalloc-sys'; - enableJemalloc = featureEnabled "jemalloc"; + # rocksdb fails to build with prefixed jemalloc, which is required on + # darwin due to [1]. In this case, fall back to building rocksdb with + # libc malloc. This should not cause conflicts, because all of the + # jemalloc symbols are prefixed. + # + # [1]: https://github.com/tikv/jemallocator/blob/ab0676d77e81268cd09b059260c75b38dbef2d51/jemalloc-sys/src/env.rs#L17 + enableJemalloc = featureEnabled "jemalloc" && !stdenv.isDarwin; }; in {