about summary refs log tree commit diff
path: root/pkgs/os-specific/darwin
diff options
context:
space:
mode:
authorRandy Eckenrode <randy@largeandhighquality.com>2023-06-04 17:40:37 -0400
committerRandy Eckenrode <randy@largeandhighquality.com>2023-06-30 17:13:45 -0400
commitcf77dee3ad8cce0e14f783121f42021e2dc9a2e3 (patch)
treef04ec20a3c4a10065cccff9ff195e2f8e13b7343 /pkgs/os-specific/darwin
parent7cb8db1c029996e57b1a9d04b75963d01d0955bc (diff)
cctools-port: fix build with clang 16 on x86_64-darwin
Clang 16 fails to build even with `open_memstream` disabled. Just use
the memstream package to provide an implementation.
Diffstat (limited to 'pkgs/os-specific/darwin')
-rw-r--r--pkgs/os-specific/darwin/cctools/darwin-memstream.patch (renamed from pkgs/os-specific/darwin/cctools/darwin-no-memstream.patch)6
-rw-r--r--pkgs/os-specific/darwin/cctools/port.nix10
2 files changed, 7 insertions, 9 deletions
diff --git a/pkgs/os-specific/darwin/cctools/darwin-no-memstream.patch b/pkgs/os-specific/darwin/cctools/darwin-memstream.patch
index bb8a4ad68f3b2..3e0d0a43ba8d0 100644
--- a/pkgs/os-specific/darwin/cctools/darwin-no-memstream.patch
+++ b/pkgs/os-specific/darwin/cctools/darwin-memstream.patch
@@ -1,7 +1,3 @@
-MacOS SDKs before 10.13 don't support open_memstream. This is already replaced
-by a runtime check in cctools-port, but because we build with SDK 10.12 by
-default, linking still fails for us. Disable it entirely here.
-
 --- a/cctools/include/stuff/diagnostics.h
 +++ b/cctools/include/stuff/diagnostics.h
 @@ -60,13 +60,6 @@ void diagnostics_log_msg(enum diagnostic_level level, const char* message);
@@ -16,6 +12,6 @@ default, linking still fails for us. Disable it entirely here.
 -#ifndef HAVE_OPENMEMSTREAM_RUNTIME
 -#  define HAVE_OPENMEMSTREAM_RUNTIME 1
 -#endif
-+#define HAVE_OPENMEMSTREAM_RUNTIME 0
++#define HAVE_OPENMEMSTREAM_RUNTIME 1
  
  #endif /* diagnostics_h */
diff --git a/pkgs/os-specific/darwin/cctools/port.nix b/pkgs/os-specific/darwin/cctools/port.nix
index 4d8079977513a..c9b11ee20155e 100644
--- a/pkgs/os-specific/darwin/cctools/port.nix
+++ b/pkgs/os-specific/darwin/cctools/port.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, autoreconfHook
+{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, autoreconfHook, memstreamHook
 , installShellFiles
 , libuuid
 , libobjc ? null, maloader ? null
@@ -35,7 +35,8 @@ stdenv.mkDerivation {
 
   outputs = [ "out" "dev" "man" ];
 
-  nativeBuildInputs = [ autoconf automake libtool autoreconfHook installShellFiles ];
+  nativeBuildInputs = [ autoconf automake libtool autoreconfHook installShellFiles ]
+    ++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [ memstreamHook ];
   buildInputs = [ libuuid ]
     ++ lib.optionals stdenv.isDarwin [ libobjc ]
     ++ lib.optional enableTapiSupport libtapi;
@@ -51,8 +52,9 @@ stdenv.mkDerivation {
       url = "https://github.com/MercuryTechnologies/cctools-port/commit/025899b7b3593dedb0c681e689e57c0e7bbd9b80.patch";
       hash = "sha256-SWVUzFaJHH2fu9y8RcU3Nx/QKx60hPE5zFx0odYDeQs=";
     })
-  ]
-    ++ lib.optional stdenv.isDarwin ./darwin-no-memstream.patch;
+    # Always use `open_memstream`. This is provided by memstream via hook on x86_64-darwin.
+    ./darwin-memstream.patch
+  ];
 
   __propagatedImpureHostDeps = [
     # As far as I can tell, otool from cctools is the only thing that depends on these two, and we should fix them