darwin.swift-corelibs-foundation: drop

Broken since at least 24.11, stuck on a version from 2018, and no
longer relevant with the new SDK pattern. A newer version is packaged
separately for the Swift compiler, so maybe it could be revived there
if people clamour for a source‐built CoreFoundation in the future.
This commit is contained in:
Emily
2025-04-20 23:19:16 +01:00
parent a1f516820b
commit 4c6d3b0724
13 changed files with 1 additions and 461 deletions
@@ -1,8 +1,3 @@
# TODO: We already package the CoreFoundation component of Foundation in:
# pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix
# This is separate because the CF build is completely different and part of
# stdenv. Merging the two was kept outside of the scope of Swift work.
{
lib,
stdenv,
@@ -1,30 +0,0 @@
From 549160574ee44656d50997b27ef83736e0848201 Mon Sep 17 00:00:00 2001
From: toonn <toonn@toonn.io>
Date: Mon, 26 Apr 2021 20:51:05 +0200
Subject: [PATCH] Add missing TARGET_OS_* defines
---
.../Base.subproj/SwiftRuntime/TargetConditionals.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/CoreFoundation/Base.subproj/SwiftRuntime/TargetConditionals.h b/CoreFoundation/Base.subproj/SwiftRuntime/TargetConditionals.h
index 6d42b873..abf746c9 100644
--- a/CoreFoundation/Base.subproj/SwiftRuntime/TargetConditionals.h
+++ b/CoreFoundation/Base.subproj/SwiftRuntime/TargetConditionals.h
@@ -118,6 +118,13 @@
#define TARGET_OS_WIN32 TARGET_OS_WINDOWS
#define TARGET_OS_MAC TARGET_OS_DARWIN
+#define TARGET_OS_OSX TARGET_OS_DARWIN
+
+#define TARGET_OS_IPHONE 0
+#define TARGET_OS_WATCH 0
+#define TARGET_OS_TV 0
+#define TARGET_OS_EMBEDDED 0
+
#if __x86_64__
#define TARGET_CPU_PPC 0
--
2.17.2 (Apple Git-113)
@@ -1,11 +0,0 @@
--- 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
@@ -1,25 +0,0 @@
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);
@@ -1,66 +0,0 @@
--- a/CoreFoundation/CMakeLists.txt 1969-12-31 19:00:01.000000000 -0500
+++ b/CoreFoundation/CMakeLists.txt 2023-06-29 18:52:49.096019700 -0400
@@ -129,7 +129,7 @@
Base.subproj/CFByteOrder.h
Base.subproj/CFUUID.h
Base.subproj/CFUtilities.h
- Base.subproj/SwiftRuntime/CoreFoundation.h
+ Base.subproj/CoreFoundation.h # The SwiftRuntime version of this file causes linker errors and is not correct for standalone CF.
Base.subproj/SwiftRuntime/TargetConditionals.h
# Collections
Collections.subproj/CFArray.h
@@ -245,6 +245,8 @@
# RunLoop
RunLoop.subproj/CFRunLoop.c
RunLoop.subproj/CFSocket.c
+ RunLoop.subproj/CFMachPort.c # These files are missing from the upstream `CMakeLists.txt` but required to build on Darwin.
+ RunLoop.subproj/CFMessagePort.c
# Stream
Stream.subproj/CFConcreteStreams.c
Stream.subproj/CFSocketStream.c
@@ -336,6 +338,11 @@
target_include_directories(CoreFoundation
PRIVATE
${CURL_INCLUDE_DIRS})
+elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+ find_package(CURL REQUIRED)
+ target_include_directories(CoreFoundation PRIVATE ${CURL_INCLUDE_DIRS})
+ find_package(LibXml2 REQUIRED)
+ target_include_directories(CoreFoundation PRIVATE ${LIBXML2_INCLUDE_DIR})
else()
target_include_directories(CoreFoundation
PRIVATE
@@ -365,6 +372,10 @@
PRIVATE
${CURL_LIBRARIES}
${LIBXML2_LIBRARIES})
+elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+ target_link_libraries(CoreFoundation PRIVATE
+ ${CURL_LIBRARIES}
+ ${LIBXML2_LIBRARIES})
else()
target_link_libraries(CoreFoundation
PRIVATE
@@ -398,9 +400,19 @@
target_link_libraries(CoreFoundation
PRIVATE
icucore)
- set_target_properties(CoreFoundation
- PROPERTIES LINK_FLAGS
- -Xlinker;-alias_list;-Xlinker;Base.subproj/DarwinSymbolAliases;-twolevel_namespace;-sectcreate;__UNICODE;__csbitmaps;CharacterSets/CFCharacterSetBitmaps.bitmap;-sectcreate;__UNICODE;__properties;CharacterSets/CFUniCharPropertyDatabase.data;-sectcreate;__UNICODE;__data;CharacterSets/CFUnicodeData-L.mapping;-segprot;__UNICODE;r;r)
+ target_link_options(CoreFoundation
+ PUBLIC
+ "LINKER:-alias_list,../Base.subproj/DarwinSymbolAliases"
+ "LINKER:-twolevel_namespace"
+ "LINKER:-sectcreate,__UNICODE,__csbitmaps,../CharacterSets/CFCharacterSetBitmaps.bitmap"
+ "LINKER:-sectcreate,__UNICODE,__properties,../CharacterSets/CFUniCharPropertyDatabase.data"
+ "LINKER:-sectcreate,__UNICODE,__data,../CharacterSets/CFUnicodeData-L.mapping"
+ "LINKER:-segprot,__UNICODE,r,r"
+ "LINKER:-current_version,1454.90.0"
+ "LINKER:-compatibility_version,150.0.0"
+ "LINKER:-init,___CFInitialize")
+ set(CMAKE_SHARED_LIBRARY_PREFIX "")
+ set(CMAKE_SHARED_LIBRARY_SUFFIX "")
endif()
install(TARGETS
@@ -1,23 +0,0 @@
diff -u aa/CoreFoundation/CMakeLists.txt b/CoreFoundation/CMakeLists.txt
--- a/CoreFoundation/CMakeLists.txt 1969-12-31 19:00:01.000000000 -0500
+++ b/CoreFoundation/CMakeLists.txt 2023-06-29 18:59:19.492601179 -0400
@@ -424,16 +424,11 @@
set(CMAKE_SHARED_LIBRARY_SUFFIX "")
endif()
-install(TARGETS
- CoreFoundation
- DESTINATION
- "${CMAKE_INSTALL_FULL_LIBDIR}")
install(DIRECTORY
${CoreFoundation_FRAMEWORK_DIRECTORY}
DESTINATION
- ${CMAKE_INSTALL_PREFIX}/System/Library/Frameworks
- USE_SOURCE_PERMISSIONS
- PATTERN PrivateHeaders EXCLUDE)
+ ${CMAKE_INSTALL_PREFIX}/Library/Frameworks
+ USE_SOURCE_PERMISSIONS)
# TODO(compnerd) formalize this
@@ -1,84 +0,0 @@
diff -u a/CoreFoundation/CMakeLists.txt b/CoreFoundation/CMakeLists.txt
--- a/CoreFoundation/CMakeLists.txt 1969-12-31 19:00:01.000000000 -0500
+++ b/CoreFoundation/CMakeLists.txt 2023-06-29 18:59:08.659632504 -0400
@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 3.4.3)
+cmake_minimum_required(VERSION 3.14)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -45,6 +45,8 @@
${FRAMEWORK_LIBRARY_TYPE}
FRAMEWORK_DIRECTORY
CoreFoundation_FRAMEWORK_DIRECTORY
+ VERSION
+ A
MODULE_MAP
Base.subproj/module.modulemap
PRIVATE_HEADERS
diff -u a/CoreFoundation/cmake/modules/CoreFoundationAddFramework.cmake b/CoreFoundation/cmake/modules/CoreFoundationAddFramework.cmake
--- a/CoreFoundation/cmake/modules/CoreFoundationAddFramework.cmake 1969-12-31 19:00:01.000000000 -0500
+++ b/CoreFoundation/cmake/modules/CoreFoundationAddFramework.cmake 2023-06-29 18:57:55.792860996 -0400
@@ -3,7 +3,7 @@
function(add_framework NAME)
set(options STATIC SHARED)
- set(single_value_args MODULE_MAP FRAMEWORK_DIRECTORY)
+ set(single_value_args MODULE_MAP FRAMEWORK_DIRECTORY VERSION)
set(multiple_value_args PRIVATE_HEADERS PUBLIC_HEADERS SOURCES)
cmake_parse_arguments(AF "${options}" "${single_value_args}" "${multiple_value_args}" ${ARGN})
@@ -14,26 +14,32 @@
set(AF_TYPE SHARED)
endif()
+ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${NAME}.framework/Versions/${AF_VERSION})
+ file(CREATE_LINK ${AF_VERSION} ${CMAKE_BINARY_DIR}/${NAME}.framework/Versions/Current SYMBOLIC)
+
if(AF_MODULE_MAP)
file(COPY
${AF_MODULE_MAP}
DESTINATION
- ${CMAKE_BINARY_DIR}/${NAME}.framework/Modules
+ ${CMAKE_BINARY_DIR}/${NAME}.framework/Versions/Current/Modules
NO_SOURCE_PERMISSIONS)
+ file(CREATE_LINK Versions/Current/Modules ${CMAKE_BINARY_DIR}/${NAME}.framework/Modules SYMBOLIC)
endif()
if(AF_PUBLIC_HEADERS)
file(COPY
${AF_PUBLIC_HEADERS}
DESTINATION
- ${CMAKE_BINARY_DIR}/${NAME}.framework/Headers
+ ${CMAKE_BINARY_DIR}/${NAME}.framework/Versions/Current/Headers
NO_SOURCE_PERMISSIONS)
+ file(CREATE_LINK Versions/Current/Headers ${CMAKE_BINARY_DIR}/${NAME}.framework/Headers SYMBOLIC)
endif()
if(AF_PRIVATE_HEADERS)
file(COPY
${AF_PRIVATE_HEADERS}
DESTINATION
- ${CMAKE_BINARY_DIR}/${NAME}.framework/PrivateHeaders
+ ${CMAKE_BINARY_DIR}/${NAME}.framework/Versions/Current/PrivateHeaders
NO_SOURCE_PERMISSIONS)
+ file(CREATE_LINK Versions/Current/PrivateHeaders ${CMAKE_BINARY_DIR}/${NAME}.framework/PrivateHeaders SYMBOLIC)
endif()
add_custom_target(${NAME}_POPULATE_HEADERS
DEPENDS
@@ -51,13 +57,15 @@
set_target_properties(${NAME}
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY
- ${CMAKE_BINARY_DIR}/${NAME}.framework)
+ ${CMAKE_BINARY_DIR}/${NAME}.framework/Versions/Current)
target_compile_options(${NAME}
PRIVATE
-F;${CMAKE_BINARY_DIR}
-I;${CMAKE_BINARY_DIR}/${NAME}.framework/PrivateHeaders)
add_dependencies(${NAME} ${NAME}_POPULATE_HEADERS)
+ file(CREATE_LINK Versions/Current/${NAME} ${CMAKE_BINARY_DIR}/${NAME}.framework/${NAME} SYMBOLIC)
+
if(AF_FRAMEWORK_DIRECTORY)
set(${AF_FRAMEWORK_DIRECTORY} ${CMAKE_BINARY_DIR}/${NAME}.framework PARENT_SCOPE)
endif()
@@ -1,31 +0,0 @@
diff -ur d/CoreFoundation/CMakeLists.txt e/CoreFoundation/CMakeLists.txt
--- d/CoreFoundation/CMakeLists.txt 1969-12-31 19:00:01.000000000 -0500
+++ e/CoreFoundation/CMakeLists.txt 2023-06-29 19:13:15.561253229 -0400
@@ -343,6 +343,7 @@
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
find_package(CURL REQUIRED)
target_include_directories(CoreFoundation PRIVATE ${CURL_INCLUDE_DIRS})
+ find_package(ICU COMPONENTS uc i18n data REQUIRED)
find_package(LibXml2 REQUIRED)
target_include_directories(CoreFoundation PRIVATE ${LIBXML2_INCLUDE_DIR})
else()
@@ -377,6 +378,9 @@
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_link_libraries(CoreFoundation PRIVATE
${CURL_LIBRARIES}
+ ICU::uc
+ ICU::i18n
+ ICU::data
${LIBXML2_LIBRARIES})
else()
target_link_libraries(CoreFoundation
@@ -408,9 +412,6 @@
PROPERTIES LINK_FLAGS
-Xlinker;@${CMAKE_SOURCE_DIR}/linux.ld;-Bsymbolic)
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
- target_link_libraries(CoreFoundation
- PRIVATE
- icucore)
target_link_options(CoreFoundation
PUBLIC
"LINKER:-alias_list,../Base.subproj/DarwinSymbolAliases"
@@ -1,46 +0,0 @@
diff -u a/CoreFoundation/CMakeLists.txt b/CoreFoundation/CMakeLists.txt
--- a/CoreFoundation/CMakeLists.txt 1969-12-31 19:00:01.000000000 -0500
+++ b/CoreFoundation/CMakeLists.txt 2023-06-29 19:39:30.074449222 -0400
@@ -104,7 +104,6 @@
# URL
URL.subproj/CFURL.inc.h
URL.subproj/CFURLPriv.h
- URL.subproj/CFURLSessionInterface.h
PUBLIC_HEADERS
# FIXME: PrivateHeaders referenced by public headers
Base.subproj/CFKnownLocations.h
@@ -120,7 +119,6 @@
String.subproj/CFRegularExpression.h
String.subproj/CFRunArray.h
URL.subproj/CFURLPriv.h
- URL.subproj/CFURLSessionInterface.h
# AppServices
AppServices.subproj/CFNotificationCenter.h
@@ -280,8 +278,7 @@
URL.subproj/CFURL.c
URL.subproj/CFURLAccess.c
URL.subproj/CFURLComponents.c
- URL.subproj/CFURLComponents_URIParser.c
- URL.subproj/CFURLSessionInterface.c)
+ URL.subproj/CFURLComponents_URIParser.c)
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android)
target_compile_definitions(CoreFoundation
PRIVATE
@@ -341,8 +338,6 @@
PRIVATE
${CURL_INCLUDE_DIRS})
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
- find_package(CURL REQUIRED)
- target_include_directories(CoreFoundation PRIVATE ${CURL_INCLUDE_DIRS})
find_package(ICU COMPONENTS uc i18n data REQUIRED)
find_package(LibXml2 REQUIRED)
target_include_directories(CoreFoundation PRIVATE ${LIBXML2_INCLUDE_DIR})
@@ -377,7 +372,6 @@
${LIBXML2_LIBRARIES})
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_link_libraries(CoreFoundation PRIVATE
- ${CURL_LIBRARIES}
ICU::uc
ICU::i18n
ICU::data
@@ -1,114 +0,0 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchurl,
makeSetupHook,
cmake,
pkg-config,
launchd,
libdispatch,
python3Minimal,
libxml2,
objc4,
icu,
}:
let
# 10.12 adds a new sysdir.h that our version of CF in the main derivation depends on, but
# isn't available publicly, so instead we grab an older version of the same file that did
# not use sysdir.h, but provided the same functionality. Luckily it's simple :) hack hack
sysdir-free-system-directories = fetchurl {
url = "https://raw.githubusercontent.com/apple/swift-corelibs-foundation/9a5d8420f7793e63a8d5ec1ede516c4ebec939f0/CoreFoundation/Base.subproj/CFSystemDirectories.c";
sha256 = "0krfyghj4f096arvvpf884ra5czqlmbrgf8yyc0b3avqmb613pcc";
};
in
stdenv.mkDerivation {
pname = "swift-corefoundation";
version = "unstable-2018-09-14";
src = fetchFromGitHub {
owner = "apple";
repo = "swift-corelibs-foundation";
rev = "71aaba20e1450a82c516af1342fe23268e15de0a";
sha256 = "17kpql0f27xxz4jjw84vpas5f5sn4vdqwv10g151rc3rswbwln1z";
};
nativeBuildInputs = [
cmake
pkg-config
python3Minimal
];
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
# Fix `CMakeLists.txt` to allow it to be used instead of `build.py` to build on Darwin.
./0004-Fix-Darwin-cmake-build.patch
# Install CF framework in `$out/Library/Frameworks` instead of `$out/System/Frameworks`.
./0005-Fix-framework-installation-path.patch
# Build a framework that matches the contents of the system CoreFoundation. This patch adds
# versioning and drops the prefix and suffix, so the dynamic library is named `CoreFoundation`
# instead of `libCoreFoundation.dylib`.
./0006-System-CF-framework-compatibility.patch
# Link against the nixpkgs ICU instead of using Apples vendored version.
./0007-Use-nixpkgs-icu.patch
# Dont link against libcurl. This breaks a cycle between CF and curl, which depends on CF and
# uses the SystemConfiguration framework to support NAT64.
# This is safe because the symbols provided in CFURLSessionInterface are not provided by the
# system CoreFoundation. They are meant to be used by the implementation of `NSURLSession` in
# swift-corelibs-foundation, which is not built because it is not fully compatible with the
# system Foundation used on Darwin.
./0008-Dont-link-libcurl.patch
];
postPatch = ''
cd CoreFoundation
cp ${sysdir-free-system-directories} Base.subproj/CFSystemDirectories.c
# Includes xpc for some initialization routine that they don't define anyway, so no harm here
substituteInPlace PlugIn.subproj/CFBundlePriv.h \
--replace '#if (TARGET_OS_MAC' '#if (0'
# Why do we define __GNU__? Is that normal?
substituteInPlace Base.subproj/CFAsmMacros.h \
--replace '#if defined(__GNU__) ||' '#if 0 &&'
# The MIN macro doesn't seem to be defined sensibly for us. Not sure if our stdenv or their bug
substituteInPlace Base.subproj/CoreFoundation_Prefix.h \
--replace '#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX' '#if 1'
'';
env.NIX_CFLAGS_COMPILE = toString [
# Silence warnings regarding other targets
"-Wno-error=undef-prefix"
# Avoid redefinitions when including objc headers
"-DINCLUDE_OBJC=1"
];
cmakeFlags = [
"-DBUILD_SHARED_LIBS=ON"
"-DCF_ENABLE_LIBDISPATCH=OFF"
];
enableParallelBuilding = true;
postInstall = ''
install_name_tool -id '@rpath/CoreFoundation.framework/Versions/A/CoreFoundation' \
"$out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation"
mkdir -p "$out/nix-support"
'';
}
@@ -1,20 +0,0 @@
{
stdenv,
fetchFromGitHub,
cmake,
xnu-new,
}:
stdenv.mkDerivation rec {
name = "swift-corelibs-libdispatch";
src = fetchFromGitHub {
owner = "apple";
repo = name;
rev = "f83b5a498bad8e9ff8916183cf6e8ccf677c346b";
sha256 = "1czkyyc9llq2mnqfp19mzcfsxzas0y8zrk0gr5hg60acna6jkz2l";
};
nativeBuildInputs = [ cmake ];
buildInputs = [
xnu-new
];
}
+1
View File
@@ -94,4 +94,5 @@ mapAliases ({
### S ###
stubs = throw "'darwin.stubs.*' have been removed as they were unused"; # added 2025-04-20
swift-corelibs-foundation = throw "'darwin.swift-corelibs-foundation' has been removed, as it was broken and is no longer used"; # added 2025-04-20
})
-6
View File
@@ -263,12 +263,6 @@ makeScopeWithSplicing' {
propagatedBuildInputs = [ pkgs.pkgsBuildHost.openssl ];
} ../os-specific/darwin/xcode-project-check-hook/setup-hook.sh;
# Formerly the CF attribute. Use this is you need the open source release.
swift-corelibs-foundation = callPackage ../os-specific/darwin/swift-corelibs/corefoundation.nix { };
# As the name says, this is broken, but I don't want to lose it since it's a direction we want to go in
# libdispatch-broken = callPackage ../os-specific/darwin/swift-corelibs/libdispatch.nix { };
# See doc/packages/darwin-builder.section.md
linux-builder = lib.makeOverridable (
{ modules }: