summary refs log tree commit diff
diff options
context:
space:
mode:
authorStéphan Kochen <git@stephank.nl>2022-08-06 11:49:27 +0200
committerStéphan Kochen <git@stephank.nl>2022-08-08 12:52:12 +0200
commit71b05eccaaf4dad1f01b13832cb0d692b8e1e761 (patch)
treebc1f6609352ebcc086eddb45f995576933c374be
parent9e2d4286838519b59ab733ca0859c32ab8445d83 (diff)
downloadnixpkgs-71b05eccaaf4dad1f01b13832cb0d692b8e1e761.tar
nixpkgs-71b05eccaaf4dad1f01b13832cb0d692b8e1e761.tar.gz
nixpkgs-71b05eccaaf4dad1f01b13832cb0d692b8e1e761.tar.bz2
nixpkgs-71b05eccaaf4dad1f01b13832cb0d692b8e1e761.tar.lz
nixpkgs-71b05eccaaf4dad1f01b13832cb0d692b8e1e761.tar.xz
nixpkgs-71b05eccaaf4dad1f01b13832cb0d692b8e1e761.tar.zst
nixpkgs-71b05eccaaf4dad1f01b13832cb0d692b8e1e761.zip
darwin.cctools: 949.0.1 -> 973.0.1
-rw-r--r--pkgs/os-specific/darwin/cctools/darwin-no-memstream.patch21
-rw-r--r--pkgs/os-specific/darwin/cctools/port.nix115
2 files changed, 116 insertions, 20 deletions
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 00000000000..bb8a4ad68f3
--- /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 bace6f0689d..3c48c3ebc0c 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 <<EOF
-    #ifdef __block
-    #  undef __block
-    #  include_next "unistd.h"
-    #  define __block __attribute__((__blocks__(byref)))
-    #else
-    #  include_next "unistd.h"
-    #endif
-    EOF
-
     cd cctools
   '';
 
   preInstall = ''
-    pushd include
-    make DSTROOT=$out/include RC_OS=common install
+    installManPage ar/ar.{1,5}
+
+    # The makefile rules for installing headers are missing in 973.0.1.
+    # The below is derived from 949.0.1.
+    mkdir -p $dev/include/mach-o/i386
+    mkdir -p $dev/include/mach-o/ppc
+    mkdir -p $dev/include/mach-o/x86_64
+    mkdir -p $dev/include/mach-o/arm
+    mkdir -p $dev/include/mach-o/arm64
+    mkdir -p $dev/include/mach-o/m68k
+    mkdir -p $dev/include/mach-o/sparc
+    mkdir -p $dev/include/mach-o/hppa
+    mkdir -p $dev/include/mach-o/i860
+    mkdir -p $dev/include/mach-o/m88k
+    mkdir -p $dev/include/dyld
+    mkdir -p $dev/include/cbt
+
+    pushd include/mach-o
+    install -c -m 444  arch.h ldsyms.h reloc.h \
+      stab.h loader.h fat.h swap.h getsect.h nlist.h \
+      ranlib.h $dev/include/mach-o
     popd
 
-    installManPage ar/ar.{1,5}
+    pushd include/mach-o/i386
+    install -c -m 444  swap.h \
+      $dev/include/mach-o/i386
+    popd
+
+    pushd include/mach-o/ppc
+    install -c -m 444  reloc.h swap.h \
+      $dev/include/mach-o/ppc
+    popd
+
+    pushd include/mach-o/x86_64
+    install -c -m 444  reloc.h \
+      $dev/include/mach-o/x86_64
+    popd
+
+    pushd include/mach-o/arm
+    install -c -m 444  reloc.h \
+      $dev/include/mach-o/arm
+    popd
+
+    pushd include/mach-o/arm64
+    install -c -m 444  reloc.h \
+      $dev/include/mach-o/arm64
+    popd
+
+    pushd include/mach-o/m68k
+    install -c -m 444  swap.h \
+      $dev/include/mach-o/m68k
+    popd
+
+    pushd include/mach-o/sparc
+    install -c -m 444  reloc.h swap.h \
+      $dev/include/mach-o/sparc
+    popd
+
+    pushd include/mach-o/hppa
+    install -c -m 444  reloc.h swap.h \
+      $dev/include/mach-o/hppa
+    popd
+
+    pushd include/mach-o/i860
+    install -c -m 444  reloc.h swap.h \
+      $dev/include/mach-o/i860
+    popd
+
+    pushd include/mach-o/m88k
+    install -c -m 444  reloc.h swap.h \
+      $dev/include/mach-o/m88k
+    popd
+
+    pushd include/stuff
+    install -c -m 444  bool.h \
+      $dev/include/dyld
+    popd
+
+    pushd include/cbt
+    install -c -m 444  libsyminfo.h \
+      $dev/include/cbt
+    popd
   '';
 
   passthru = {