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-29 20:31:15 -0400
committerRandy Eckenrode <randy@largeandhighquality.com>2023-07-02 17:56:25 -0400
commit8c16d17bdc9c0da8bc655cfc4ef601b1b9bef2d6 (patch)
treed575efd10710cec8b8ae60b1d9fc7ed3a020aa5f /pkgs/os-specific/darwin
parenta845397040d1b85cec4ee41edb8598d8086c3d95 (diff)
swift-corelibs: fix build with clang 16
swift-corelibs fails to build due to a missing header and an invalid
pointer conversion. Patches are provided to fix both of these issues.
Diffstat (limited to 'pkgs/os-specific/darwin')
-rw-r--r--pkgs/os-specific/darwin/swift-corelibs/0002-Add-missing-launchd-header.patch11
-rw-r--r--pkgs/os-specific/darwin/swift-corelibs/0003-Fix-incompatible-pointer-conversion.patch25
-rw-r--r--pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix14
3 files changed, 46 insertions, 4 deletions
diff --git a/pkgs/os-specific/darwin/swift-corelibs/0002-Add-missing-launchd-header.patch b/pkgs/os-specific/darwin/swift-corelibs/0002-Add-missing-launchd-header.patch
new file mode 100644
index 0000000000000..b1187c56587e0
--- /dev/null
+++ b/pkgs/os-specific/darwin/swift-corelibs/0002-Add-missing-launchd-header.patch
@@ -0,0 +1,11 @@
+--- a/CoreFoundation/RunLoop.subproj/CFMessagePort.c	1969-12-31 19:00:01.000000000 -0500
++++ b/CoreFoundation/RunLoop.subproj/CFMessagePort.c	2023-06-09 20:25:28.599209755 -0400
+@@ -28,6 +28,8 @@
+ #endif
+ #endif
+ 
++#include <bootstrap.h>
++
+ extern pid_t getpid(void);
+ 
+ #define __kCFMessagePortMaxNameLengthMax 255
diff --git a/pkgs/os-specific/darwin/swift-corelibs/0003-Fix-incompatible-pointer-conversion.patch b/pkgs/os-specific/darwin/swift-corelibs/0003-Fix-incompatible-pointer-conversion.patch
new file mode 100644
index 0000000000000..910b622ed3ce2
--- /dev/null
+++ b/pkgs/os-specific/darwin/swift-corelibs/0003-Fix-incompatible-pointer-conversion.patch
@@ -0,0 +1,25 @@
+diff -u a/CoreFoundation/URL.subproj/CFURLComponents.c b/CoreFoundation/URL.subproj/CFURLComponents.c
+--- a/CoreFoundation/URL.subproj/CFURLComponents.c	1969-12-31 19:00:01.000000000 -0500
++++ b/CoreFoundation/URL.subproj/CFURLComponents.c	2023-06-09 20:36:52.995514573 -0400
+@@ -66,7 +66,8 @@
+     return CFRetain(CFSTR("A really nice CFURLComponents object"));
+ }
+ 
+-CF_CROSS_PLATFORM_EXPORT void __CFURLComponentsDeallocate(CFURLComponentsRef instance) {
++CF_CROSS_PLATFORM_EXPORT void __CFURLComponentsDeallocate(CFTypeRef cf) {
++    CFURLComponentsRef instance = (CFURLComponentsRef)cf;
+     __CFGenericValidateType(instance, _CFURLComponentsGetTypeID());
+     
+     if (instance->_urlString) CFRelease(instance->_urlString);
+diff -u a/CoreFoundation/URL.subproj/CFURLComponents.h b/CoreFoundation/URL.subproj/CFURLComponents.h
+--- a/CoreFoundation/URL.subproj/CFURLComponents.h	1969-12-31 19:00:01.000000000 -0500
++++ b/CoreFoundation/URL.subproj/CFURLComponents.h	2023-06-09 20:39:36.967857713 -0400
+@@ -38,7 +38,7 @@
+ 
+ CF_EXPORT CFTypeID _CFURLComponentsGetTypeID(void);
+ 
+-CF_CROSS_PLATFORM_EXPORT void __CFURLComponentsDeallocate(CFURLComponentsRef);
++CF_CROSS_PLATFORM_EXPORT void __CFURLComponentsDeallocate(CFTypeRef);
+ 
+ // URLComponents are always mutable.
+ CF_EXPORT _Nullable CFURLComponentsRef _CFURLComponentsCreate(CFAllocatorRef alloc);
diff --git a/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix b/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix
index 1e7aeb3689ea9..3db9073ad5549 100644
--- a/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix
+++ b/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitHub, fetchurl, makeSetupHook, ninja, python3, curl, libxml2, objc4, ICU }:
+{ lib, stdenv, fetchFromGitHub, fetchurl, makeSetupHook, ninja, launchd, libdispatch, python3, curl, libxml2, objc4, ICU }:
 
 let
   # 10.12 adds a new sysdir.h that our version of CF in the main derivation depends on, but
@@ -22,9 +22,15 @@ stdenv.mkDerivation {
   };
 
   nativeBuildInputs = [ ninja python3 ];
-  buildInputs = [ curl libxml2 objc4 ICU ];
-
-  patches = [ ./0001-Add-missing-TARGET_OS_-defines.patch ];
+  buildInputs = [ (lib.getDev launchd) libdispatch libxml2 objc4 ICU ];
+
+  patches = [
+    ./0001-Add-missing-TARGET_OS_-defines.patch
+    # CFMessagePort.h uses `bootstrap_check_in` without declaring it, which is defined in the launchd headers.
+    ./0002-Add-missing-launchd-header.patch
+    # CFURLComponents fails to build with clang 16 due to an invalid pointer conversion. This is fixed upstream.
+    ./0003-Fix-incompatible-pointer-conversion.patch
+  ];
 
   postPatch = ''
     cd CoreFoundation