|
|
Subscribe / Log in / New account

Darling: macOS compatibility for Linux

July 30, 2019

This article was contributed by Sean Kerner

There is an increasingly active development effort, known as Darling, that is aiming to provide a translation layer for macOS software on Linux; it is inspired in part by Wine. While Darling isn't nearly as mature as Wine, contributors are continuing to build out capabilities that could make the project more useful to a wider group of users in the future.

The project released a progress report for the second quarter of 2019 on July 23 outlining recent contributions and the state of the project overall:

We are very excited to say that in Q2 2019 (April 1 to June 30) we saw more community involvement than ever before. Many pull requests were submitted that spanned from bug fixes for our low level assembly to higher level modules such as the AppKit framework.

According to the project's website, the name Darling is a combination of "Darwin" and "Linux". Darwin is an open-source effort that is at the foundation of macOS, providing a Unix-based layer that macOS is built upon.

Licensing

Darling is licensed under GPLv3 and, according to the project home page, it does not violate Apple's End User License Agreement (EULA) since it only uses the parts of Darwin that have been released as free software. Darwin, however, is licensed under the Apple Public Source License (APSL), which is a free-software license, but is not compatible with the GPL according to the FSF.

In an issue posted on BountySource on July 25, Richard Yao suggested that Darling opt for a different license, such as the LGPLv2.1, which in his view would be compatible with the APSL. Darling contributor Lubos Dolezel disagreed, saying that it is possible to distribute GPL code with differently licensed code:

If you take most Linux distributions, you'll find packages that have mutually somewhat incompatible licenses. That doesn't mean they cannot co-exist in the same RPM/DEB repository or that you cannot write a Bash script that uses executables from both worlds.

Darling is more than an application, it is kind of a macOS distribution.

It is not clear that this reasoning would extend to the kernel module, which is licensed under the GPL but that, according to Yao, contains a fair amount of XNU (Darwin kernel) code that is under the APSL.

Beyond Darwin

There are also tools and libraries outside of Darwin that are part of Darling, including Cocotron, which is an open-source implementation of Cocoa — Apple's API layer for desktop applications.

In an interview, Darling contributor Andrew Hyatt explained that it's best to think of the project as being made up of many different components. Anything on https://opensource.apple.com/ that is useful is pulled down and included by the project. "This is typically command line tools but does include some system libraries/frameworks, such as Security and libsystem," Hyatt said. "Things like AppKit have source unrelated to Apple. We based our AppKit and Foundation on the source of Cocotron, which was outdated when we forked it but we have been slowly adding missing bits to it. I'd say the issues we face are from our implementations being incomplete more than they are divergent."

AppKit is a framework that includes libraries and objects used to build user-interface elements for an application. There are many other frameworks that are now being added into Darling, with a good number of them started in the past quarter by contributor James Urquhart. The report noted that Urquhart's pull requests gave the project more stubs for many frameworks.

Urquhart explained in an interview that stubs are basic implementations of API functions that are meant to allow programs which use the API to load. "In most cases they do absolutely nothing besides this, so they don't provide any guarantees that the program will run correctly," he said. "So the stubs are mere stepping stones to implementing the full required API."

Among the framework stubs that Urquhart contributed is AGL, for creating and managing OpenGL rendering contexts. There are also multiple stubs contributed by Urquhart for frameworks that are related to Carbon, which is a C-based API used for enabling backward compatibility for Mac OS 8 and 9 applications on Mac OS X. The Core Services framework works with Carbon to provide identity and other services, while ApplicationServices brings additional features to Carbon.

Urquhart explained that, in general, the focus for his contributions was to get legacy applications running on a basic level, without a graphical user interface (GUI). This required stubs implemented for the aforementioned frameworks in order for the executable to even load.

The Darling status update also mentions the challenge of nested frameworks within macOS:

Some frameworks on macOS appear to be just one framework but under the hood are made up of sub-frameworks which are usually reexported so that when being linked to it appears to be one big framework. Until now, our build system didn't support nested frameworks. In June, Andrew [Hyatt] added support for this and system frameworks such as Accelerate now have the same file structure as they do on macOS. This was accomplished using some CMake magic and carefully replicating the structure of some system frameworks.

What can you do with Darling?

Unlike Wine, Darling cannot run full macOS GUI applications such as the Xcode IDE on Linux yet. Xcode is a collection of Apple's core development tools that are used for building both macOS and iOS applications. Urquhart said that he's not using Darling in any production environment — most of his tinkering at the moment is for proof-of-concept work.

While a full-GUI macOS application won't run on Linux via Darling, that doesn't mean that macOS applications won't work. Hyatt explained that, if what you want to run can be done from the command line, there is a decent chance it will work. "In the past year we have made some big steps towards getting xcodebuild working, which allows you to compile Xcode projects from the command line," Hyatt said. "I think if we get that fully working it will really grow the project because then it would be possible to build your iOS/macOS apps on a Linux server."

Hyatt highlighted a GitHub issue for the Darling project that illustrates an interesting use case. In that issue, Tom Medema asked if it was possible to run sketchtool, which is the command-line interface for the popular Sketch macOS app. Progress has been made, as can be seen in the bug report, to the point that it will start up and print its usage text.

Another use case for Darling in the future could be for 32-bit software. With the upcoming macOS Catalina release set for later this year, Apple is dropping support for 32-bit applications. Hyatt emphasized that Darling has no such plans and will continue to include 32-bit support. "Our position also allows us to potentially have better compatibility for older apps than macOS itself because we can bake in conditional logic into our APIs that behaves in a more compatible way for older programs," he said.

Looking forward, Hyatt commented that he expects that people will merge patches to improve compatibility for applications they want to use Darling for. "It's tough to put a number on full GUI app support," he said. "If it's in years, I'm not sure how many, I guess it depends on if we can attract even more contributors with the skill and time to work on that."

Overall, it remains to be seen how successful Darling will become and if it will eventually emulate Wine's success by enabling a broad range of macOS applications to run on Linux. It took years of effort for Wine to become stable and it is a continuous effort to enable a growing list of applications; the same trajectory is likely for Darling. What is clear is that there is a dedicated group of developers who are interested and committed to figuring out how make the macOS application layer work in some capacity on Linux.

Index entries for this article
GuestArticlesKerner, Sean


to post comments

Darling: macOS compatibility for Linux

Posted Jul 30, 2019 22:39 UTC (Tue) by bovinespirit (subscriber, #88348) [Link] (7 responses)

Building Mac applications on Linux is huge! Mozilla apparently has a huge number of MiniMacs for building and testing, and I imagine many other projects do too. Lovely as MiniMacs are they are not designed or built for server farms so moving at least some of the work onto purpose built Linux servers would be a win.

On the downside I would imagine that because Darling relies on a Kernel plugin it can't run inside a container on a standard Linux distro.

Darling: macOS compatibility for Linux

Posted Jul 31, 2019 1:15 UTC (Wed) by k8to (guest, #15413) [Link] (1 responses)

You can't really test Mac applications in this environment.

Mac applications break in all kinds of ways across minor macosx versions. Vetting them in this environment wound tell you very little.

Building would be even sketchier. You need the entire system library set, not just a compatability layer.

Darling: macOS compatibility for Linux

Posted Jul 31, 2019 13:18 UTC (Wed) by mathstuf (subscriber, #69389) [Link]

Why would building be even sketchier? Personally, I'm interested in this as a way to containerize our macOS builds (then shipping the build trees to a macOS box for actual testing) since getting hermetic, reproducible macOS builds isn't possible until Apple cares enough to implement containers for their platform.

Darling: macOS compatibility for Linux

Posted Jul 31, 2019 9:11 UTC (Wed) by thumperward (guest, #34368) [Link] (3 responses)

You can already cross-compile to macos targets on Linux (to an extent). This is more about the sort of things Wine does: firstly, permitting proprietary macos applications to run on Linux, and secondly, bridging the development gap so that developers who wish to port existing macos applications to Linux have an easier time of it.

It doesn't solve the problem of needing a cupboard full of Mac Minis to actually test macos builds, for the same reason that it isn't really adequate to test Windows builds by running them on a Linux box via Wine.

Darling: macOS compatibility for Linux

Posted Jul 31, 2019 13:21 UTC (Wed) by mathstuf (subscriber, #69389) [Link] (2 responses)

Do you have links to docs and/or guides for doing the cross-compiling to macOS from Linux?

A quick search shows imcross, but that seems quite outdated and uses GCC, not an Xcode-like toolchain.

Darling: macOS compatibility for Linux

Posted Aug 1, 2019 13:25 UTC (Thu) by ashkulz (guest, #102382) [Link]

You can use vagrant for running under Linux, see https://github.com/wkhtmltopdf/packaging which produces binaries for Windows, macOS and multiple Linux distributions from a single Linux machine.

Darling: macOS compatibility for Linux

Posted Aug 2, 2019 8:40 UTC (Fri) by thumperward (guest, #34368) [Link]

Darling: macOS compatibility for Linux

Posted Jul 31, 2019 15:34 UTC (Wed) by rillian (subscriber, #11344) [Link]

These days Mozilla cross-compiles Firefox for macOS, but there's still a large pile of minis for running tests. They use normal clang+llvm and a port of Apple's cctools, built by these scripts from these sources.

One still needs a mac to install xcode and obtain a copy of the macOS SDK, and to sign binaries for distribution. Maybe that will be something Darling will help with.

Darling: macOS compatibility for Linux

Posted Jul 31, 2019 11:59 UTC (Wed) by BirAdam (guest, #132170) [Link]

There are projects like GNU Step that have some similarity to the macOS environment, and once upon a time there was Étoilé which aimed to be source compatible with macOS. GNU Step and Étoilé never became too popular, but I suppose some parts might be easier than one would imagine.

Anyway, development on macOS is happening so quickly now that I doubt any project like this would really ever be that useful. macOS releases happen every year. This is kind of like Windows too. WINE has had a hard go of it because Microsoft changes Windows in major ways quite often now. In the XP days, things were a bit easier and WINE came a very long way in that time because Windows was stable and unchanging for a very long time. Now, things are changing briskly. Most of the major compatibility gains have been due to Valve, ReactOS, and WINE all working toward compatibility. I doubt we will ever see many people needing/wanting macOS software working on Linux.

Darling: macOS compatibility for Linux

Posted Jul 31, 2019 12:40 UTC (Wed) by nilsmeyer (guest, #122604) [Link] (1 responses)

MacOS 8 and 9 compatibility? Aren't those strictly PowerPC?

Darling: macOS compatibility for Linux

Posted Jul 31, 2019 13:12 UTC (Wed) by thumperward (guest, #34368) [Link]

Carbon was also available for 32-bit Intel. It's also not the case that Carbon is exclusively a backwards compatibility thing: the OS X Finder used Carbon until like OS X 10.6.


Copyright © 2019, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds