···11-MacOS SDKs before 10.13 don't support open_memstream. This is already replaced
22-by a runtime check in cctools-port, but because we build with SDK 10.12 by
33-default, linking still fails for us. Disable it entirely here.
44-51--- a/cctools/include/stuff/diagnostics.h
62+++ b/cctools/include/stuff/diagnostics.h
73@@ -60,13 +60,6 @@ void diagnostics_log_msg(enum diagnostic_level level, const char* message);
···1612-#ifndef HAVE_OPENMEMSTREAM_RUNTIME
1713-# define HAVE_OPENMEMSTREAM_RUNTIME 1
1814-#endif
1919-+#define HAVE_OPENMEMSTREAM_RUNTIME 0
1515++#define HAVE_OPENMEMSTREAM_RUNTIME 1
20162117 #endif /* diagnostics_h */
+6-4
pkgs/os-specific/darwin/cctools/port.nix
···11-{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, autoreconfHook
11+{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, autoreconfHook, memstreamHook
22, installShellFiles
33, libuuid
44, libobjc ? null, maloader ? null
···35353636 outputs = [ "out" "dev" "man" ];
37373838- nativeBuildInputs = [ autoconf automake libtool autoreconfHook installShellFiles ];
3838+ nativeBuildInputs = [ autoconf automake libtool autoreconfHook installShellFiles ]
3939+ ++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [ memstreamHook ];
3940 buildInputs = [ libuuid ]
4041 ++ lib.optionals stdenv.isDarwin [ libobjc ]
4142 ++ lib.optional enableTapiSupport libtapi;
···5152 url = "https://github.com/MercuryTechnologies/cctools-port/commit/025899b7b3593dedb0c681e689e57c0e7bbd9b80.patch";
5253 hash = "sha256-SWVUzFaJHH2fu9y8RcU3Nx/QKx60hPE5zFx0odYDeQs=";
5354 })
5454- ]
5555- ++ lib.optional stdenv.isDarwin ./darwin-no-memstream.patch;
5555+ # Always use `open_memstream`. This is provided by memstream via hook on x86_64-darwin.
5656+ ./darwin-memstream.patch
5757+ ];
56585759 __propagatedImpureHostDeps = [
5860 # As far as I can tell, otool from cctools is the only thing that depends on these two, and we should fix them