ladybird: Swift 6.0 Blockers

List of issues preventing moving forward on moving Swift 6.0 support out of an experimental state:

Swift issues:

CMake issues:

Ladybird issues:

Nice-to-have:

Open questions:

  • Unclear how to pass view types or byte slices to swift without creating a copy.

    • We will want to be passing untrusted Strings, or c+±owned Spans of bytes to swift for it to crunch on and return some structured data. It’s not clear how to inform swift about this without copying the data (at least) once.
    • I was not able to massage swift into interpreting our String and StringView types as ‘CxxConvertibleToContainer’ or ‘CxxRandomAccessContainer’ types. Likely because they are actually immutable?
  • Unclear how to convince Swift that our types are just as good as std:: ones.

    • AK::Optional
    • AK::HashTable/HashMap
    • AK::Time
    • more?
  • How to integrate with our garbage collector? https://forums.swift.org/t/ladybird-browser-and-swift-garbage-collection/76084

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 17 (13 by maintainers)

Most upvoted comments

Thanks for your feedback, but like I said, this issue is for technical issues with our specific implementation. If you want to debate the merits of using Swift for an open source project, please do it in the appropriate forum.

We have done our technical diligence regarding this experiment, and suggestions otherwise are not helpful for meeting the goals of the project

Please keep this issue focused on technical challenges encountered with the integration of Swift 6.0 into our build.

@ADKaster BSDs are not “downstream distros”. These are entirely separate and complete operating systems with their own kernels and userlands.

Today no swift compiler exists for these 3 operating systems and I don’t think there will ever be one. I urge you to reconsider the choice of swift. Literally any other language will have better cross-platform and cross-OS support.

Please reconsider the choice of the successor language. Swift is not really supported on Linux (and very little opensource software is written in Swift for Linux) and not even available on BSDs. This will make Ladybird browser a Windows/OSX only browser.

It will be very sad to loose new web browser to closed-source commercial OSes.

As Sam said, I meant to refer to any package or port that distributes the application for their operating system, not to classify the BSDs as Linux Distros.

Today no swift compiler exists for these 3 operating systems and I don’t think there will ever be one.

There is documentation from 2022 for building Swift on OpenBSD. https://github.com/swiftlang/swift/blob/main/docs/OpenBSD.md. The technical challenges with the latest efforts of porting Swift to FreeBSD seem llvm related. The issues with updating Swift to work on more BSD platforms are technical problems, not political ones. Unless there’s BSD mailing list drama I’m not aware of. But that would still be out of scope for our project.

As you mentioned, there are no large and/or popular open source desktop applications using Swift (to my knowledge). I can’t think of a better way to energize Swift porting efforts than to prove that such a thing is possible on non-macOS Unix systems.

It appears as though the fix for the libstdcxx issue was merged into swift nightly and 6.0.3. https://github.com/swiftlang/swift/pull/75971#issuecomment-2690553245

This may be offtopic but why swift that isn’t there yet and not a language that is there already like the D programming language? D has good interop with C and C++ and is available on many platforms. I don’t see what Swift has that D doesn’t have except problems. I’d write it on YT not to bother anyone here but as everyone knows they are broken and half of them are never shown.

You’re misquoting/misunderstanding him. He said “downstreams like distros”. Anywhere that packages Ladybird, whether it’s a distro or a different OS like one of the BSDs or Haiku etc, is downstream of our repo.

Indeed I misunderstood the meaning of downstream in this context.

I do not want to discourage the optimism and I hope that Ladybird will succeed. The opensource ecosystem desperately needs “new blood” in the browser section. But lets look at the facts:

  • Swift was first released in 2014 and Linux always was a second-class citizen (example - Swift’s stable ABI for dynamically loaded libraries only works on OSX). 10 years is plenty of time to “grow” support for various platforms but somehow Swift didn’t do it - comparing to literally any other LLVM based language. The hope that by 2026 the situation will somehow change is thin.

  • Swift’s C++ interop is still WIP. This means that you are inviting a whole new class of language interop bugs into the project that will be difficult to debug.

  • Introduction of any second language into the project inevitably slows the progress down, creates unnecessary context switch for humans and diverges a lot of energy into rewriting existing functionality. Needless to say that most rewrites never finish.

I can’t think of a better way to energize Swift porting efforts than to prove that such a thing is possible on non-macOS Unix systems.

It does seem like you are subscribing yourselves to more work than you expect:

  • Improving Swift’s opensource desktop ecosystem
  • Improving Swift’s cross-OS support
  • Building a new browser

P.S. Have you looked at Herb Sutter’s cppfront? (https://hsutter.github.io/cppfront/) It is a lot less invasive way to get nice things in a C++ project

BSDs are not “downstream distros”.

You’re misquoting/misunderstanding him. He said “downstreams like distros”. Anywhere that packages Ladybird, whether it’s a distro or a different OS like one of the BSDs or Haiku etc, is downstream of our repo.

Today no swift compiler exists for these 3 operating systems and I don’t think there will ever be one.

Ladybird isn’t going into early alpha until 2026, and then a proper release will be years after that. There’s plenty of time for Swift support to develop on those other OSes. The Swift compiler is based on LLVM so the amount of porting required shouldn’t be too huge. (Though I haven’t looked into it.) Even on Linux the Swift situation is a little rough right now, but it’ll improve with time.

Unfortunately the fix for the c++23 std::chrono::time_zone w/gcc issue https://github.com/swiftlang/swift/issues/76809, https://github.com/swiftlang/swift/pull/77098 doesn’t exist in the 6.0.x branch. We’ll have to keep using main on linux until that’s in. I’ll need to get some useful swift changes in for linux to actually get a CI going to keep track of these sorts of things better