Closing this as we are no longer pursuing Swift adoption

Source: github.com
296 points by thewavelength 22 hours ago on hackernews | 265 comments

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

Swift issues:

CMake issues:

  • https://gitlab.kitware.com/cmake/cmake/-/issues/26174

    Details: Swift + Ninja doesn't respect CMAKE_OSX_DEPLOYMENT_TARGET. This results in a mismatched LC_BUILD_VERSION on swift and c++ object files, spamming the console with warnings.

    Workaround:

    # FIXME: https://gitlab.kitware.com/cmake/cmake/-/issues/26174
    if (APPLE)
    set(CMAKE_Swift_COMPILER_TARGET "${CMAKE_SYSTEM_PROCESSOR}-apple-macosx${CMAKE_OSX_DEPLOYMENT_TARGET}")
    endif()
  • https://gitlab.kitware.com/cmake/cmake/-/issues/26175

    Details: With CMP0157 enabled, swiftc does not set install_name directory to "@rpath" per CMAKE_INSTALL_NAME_DIR

    Workaround:

    # FIXME: https://gitlab.kitware.com/cmake/cmake/-/issues/26175
    if (APPLE)
    add_custom_command(TARGET LibGfx POST_BUILD
    COMMAND install_name_tool -id @rpath/liblagom-gfx.0.dylib "$<TARGET_FILE:LibGfx>"
    )
    endif()

    PR: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9692. Merged Aug 2, 2024 to be backported to CMake 3.29, 3.30.

  • https://gitlab.kitware.com/cmake/cmake/-/issues/26195

    Details: Imported targets from dependencies can have INTERFACE_COMPILE_OPTIONS or INTERFACE_LINK_OPTIONS that swiftc doesn't understand.

    Workaround: Swizzle the flags just after import, for every single imported library.

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