Building CoreFoundation for Darwin

Firstly, I know that questions similar this have been asked in a previous thread but I didn't want to bump a 1+ year old thread, so I shall ramble here - I do apologise if this is the wrong place to post.

In the aforementioned thread it is said that tarballs of CF are no longer shipped to opensource.apple.com, instead they've are imported into the GitHub project. It also said that the Darwin CF is a superset of the swift-corelibs-foundation - and I was wondering if it would at all be possible if the "old" CF build system could be brought down into swift-corelibs-foundation - or at least be republished back to the Apple Open Source portal. Doing so would make it significantly easier for us at PureDarwin to build a functioning CF framework, as the current project is very intertwined with Swift - I can't even seem to build the CF from the Swift 5.0 release without DEPLOYMENT_RUNTIME_SWIFT defined.

I've tried many was around this - firstly by creating a target for CoreFoundation as a shared framework in Xcode and attempting to copy as many of the target setting over (which just lead to a bit of a mess, and after teasing out lots of build errors, I was left segfaults in the library that was built), and using CMake, however neither the Xcode build system nor CMake seem to be suited to building a (near) drop-in replacement for /System/Library/Frameworks/CoreFoundation.framework.

If anyone has any pointers on anything that can be done, that would be greatly appreciated!

1 Like

Hi @libsystem-ethan,

We do want to support a kind of 'stand-alone' CF build with the same sources as are used for Swift. There is a "runtime swift" concept that would need to be turned off in this mode - when built for Swift we use the Swift runtime for things like CFRetain and CFRelease.

@millenomi was working on this project at one point, but it's been prioritized behind completing some of the higher level work.

@libsystem-ethan, having done the work to port the build system for CoreFoundation to CMake, I am curious what in the current system is insufficient for your needs. I did spend a fair amount of effort trying to retain the ability to build CoreFoundation standalone, without the Swift runtime, and as a framework.

If there are specific issues, perhaps those can be resolved to avoid recreating more competing build systems which diverge.

@libsystem-ethan: while I haven't explored the functionality of the build setup, CF should build correctly the way you desire if you use its CMakeLists.txt file without setting the CF_DEPLOYMENT_SWIFT variable. That will cause the build to be standalone.

ETA: "Its" CMakeLists.txt file is the one in the CoreFoundation directory of the swift-corelibs-foundation repository.