diff --git a/pkgs/os-specific/darwin/cctools/darwin-no-memstream.patch b/pkgs/os-specific/darwin/cctools/darwin-no-memstream.patch new file mode 100644 index 000000000000..bb8a4ad68f3b --- /dev/null +++ b/pkgs/os-specific/darwin/cctools/darwin-no-memstream.patch @@ -0,0 +1,21 @@ +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); + */ + void diagnostics_write(void); + +-#if defined(__APPLE__ ) && defined(__has_builtin) +-# if __has_builtin(__builtin_available) +-# define HAVE_OPENMEMSTREAM_RUNTIME __builtin_available(macOS 10.13, *) +-# endif +-#endif +-#ifndef HAVE_OPENMEMSTREAM_RUNTIME +-# define HAVE_OPENMEMSTREAM_RUNTIME 1 +-#endif ++#define HAVE_OPENMEMSTREAM_RUNTIME 0 + + #endif /* diagnostics_h */ diff --git a/pkgs/os-specific/darwin/cctools/port.nix b/pkgs/os-specific/darwin/cctools/port.nix index bace6f0689d9..3c48c3ebc0c4 100644 --- a/pkgs/os-specific/darwin/cctools/port.nix +++ b/pkgs/os-specific/darwin/cctools/port.nix @@ -19,13 +19,17 @@ assert (!stdenv.hostPlatform.isDarwin) -> maloader != null; stdenv.mkDerivation { pname = "${targetPrefix}cctools-port"; - version = "949.0.1"; + version = "973.0.1"; src = fetchFromGitHub { owner = "tpoechtrager"; repo = "cctools-port"; - rev = "43f32a4c61b5ba7fde011e816136c550b1b3146f"; - sha256 = "10yc5smiczzm62q6ijqccc58bwmfhc897f3bwa5i9j98csqsjj0k"; + # This is the commit before: https://github.com/tpoechtrager/cctools-port/pull/114 + # That specific change causes trouble for us (see the PR discussion), but + # is also currently the last commit on master at the time of writing, so we + # can just go back one step. + rev = "457dc6ddf5244ebf94f28e924e3a971f1566bd66"; + sha256 = "0ns12q7vg9yand4dmdsps1917cavfbw67yl5q7bm6kb4ia5kkx13"; }; outputs = [ "out" "dev" "man" ]; @@ -35,7 +39,11 @@ stdenv.mkDerivation { ++ lib.optionals stdenv.isDarwin [ libobjc ] ++ lib.optional enableTapiSupport libtapi; - patches = [ ./ld-ignore-rpath-link.patch ./ld-rpath-nonfinal.patch ]; + patches = [ + ./ld-ignore-rpath-link.patch + ./ld-rpath-nonfinal.patch + ] + ++ lib.optional stdenv.isDarwin ./darwin-no-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 @@ -64,32 +72,99 @@ stdenv.mkDerivation { --replace "-isystem /usr/local/include -isystem /usr/pkg/include" "" \ --replace "-L/usr/local/lib" "" \ - substituteInPlace cctools/include/Makefile \ - --replace "/bin/" "" + # Appears to use new libdispatch API not available in macOS SDK 10.12. + substituteInPlace cctools/ld64/src/ld/libcodedirectory.c \ + --replace "#define LIBCD_PARALLEL 1" "" patchShebangs tools sed -i -e 's/which/type -P/' tools/*.sh - # Workaround for https://www.sourceware.org/bugzilla/show_bug.cgi?id=11157 - cat > cctools/include/unistd.h <