Skip to content

Update request: swift 5.8 → 6 #343210

Closed
Closed

Description

@223740

Notify maintainers

@dtzWill @trepetti @dduan @Trundle @stephank


Note for maintainers: Please tag this issue in your PR.


Add a 👍 reaction to issues you find important.

https://www.swift.org/install/linux/debian/12/#versions
Swift also supports a static SDK now, it would be truly great to also have support for that.
After trying to update the package myself, I wonder if package updates were not simpler if we would just use the official swift build process instead of hacking together our own. The current version is hopelessly behind the official, with the release of cross-compiling targets such as the static SDK and WASM, which are both highly relevant, it would seem prudent to re-evaluate if utils/update-checkout and utils/build-script would not simplfy the process to a great extent.

Activity

  1. added
    9.needs: package (update)
    on Sep 20, 2024
  2. TheNightmanCodeth commented on Sep 28, 2024

    @TheNightmanCodeth

    I've been making some progress on this myself.

    I've had varying degrees of success with a 3 stage bootstrap using swifts build scripts (not too dissimilar from this approach).

    Worst of it is getting caught up at the llvm install phase in stage0, not sure how to move clang-unwrapped back to clang before it's installed. I can't find where the cmake_install script is generated, otherwise I could probably handle it in there. Once I can get past that I will have a working stage0.

    I'm about to pause all that to try and get 6 building using the updated patches with the existing now-functional build script.

    If anyone else is working on this and would like to collab please reach out, I'm not sure where to look for any current work on this (if there is any). Otherwise I'll try and get my build logs human-readable and link them here.

  3. 223740 commented on Sep 30, 2024

    @223740
    ContributorAuthor

    This is what I came up with, but it does not work yet (and I do not have any time in the next week to fix it). Note that it requires a patch for postFetch to work here, it is currently awaiting review: #339989

    I think the idea is quite obvious, but I am not sure if it is really the way to go. But to me it seems simpler to use swift's own dependency management and build scripts instead of creating our own.

    { lib, stdenv
    , cmake
    , coreutils
    , glibc
    , gccForLibs
    , which
    , perl
    , libedit
    , ninja
    , pkg-config
    , sqlite
    , libxml2
    , clang_18
    , python4
    , ncurses
    , libuuid
    , icu
    , libgcc
    , libblocksruntime
    , curl
    , rsync
    , git
    , libgit2
    , fetchFromGitHub
    , makeWrapper
    , gnumake
    , file
    , openssl
    , cacert
    }:
    
    let
      versions = {
        swift = "5.10";
      };
    
      python = (python3.withPackages (ps: [ps.six]));
    
    in
    stdenv.mkDerivation {
      pname = "swift";
      version = versions.swift;
    
      nativeBuildInputs = [
        cmake
        git
        makeWrapper
        ninja
        perl
        pkg-config
        python
        rsync
        which
      ];
    
      buildInputs = [
        curl
        glibc
        icu
        libblocksruntime
        libedit
        libgcc
        libuuid
        libxml2
        ncurses
        sqlite
        clang_18
      ];
    
      # TODO: Revisit what needs to be propagated and how.
      propagatedBuildInputs = [
        libgcc
        libgit2
        python
      ];
    
      propagatedUserEnvPkgs = [ git pkg-config ];
    
      hardeningDisable = [ "format" ]; # for LLDB
    
      src = fetchFromGitHub {
        owner = "swiftlang";
        repo = "swift";
        rev = "swift-${versions.swift}-RELEASE";
        fetchSubmodules = true;
        leaveDotGit = true; # otherwise, utils/update-checkout fails
        nativeBuildInputs = [ python git openssl cacert ];
        postFetch = ''
            export SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt";
            mkdir -p $out/swift
    
            mv $out/.* $out/swift
            mv $out/* $out/swift || true
    
            $out/swift/utils/update-checkout --clone --clean --tag swift-${versions.swift}-RELEASE --source-root $out --skip-history -j1
            ls -lsa $out
        '';
        #sha256 = "sha256-JrewdK05fSEkaqsGxWQB2J9N7w6XYxV7qbUdKNKy110e8=";
      };
    
      configurePhase = ''
        # do nothing here
      '';
    
      buildPhase = ''
        ls -lsa
        pwd
        ls -lsa $out
        #swift/utils/build-script \
          --clean\
          --install-prefix $out \
          --install-all \
          --lto \
          --static-libxml2 \
          --static-zlib \
          --static-curl \
          --build-swift-static-stdlib \
          --build-swift-static-sdk-overlay \
          --build-swift-stdlib-static-print
      '';
    
      meta = with lib; {
        description = "The Swift Programming Language";
        homepage = "https://github.com/swiftlang/swift";
        maintainers = with maintainers; [  ]; # TODO update maintainers
        license = licenses.asl20;
        # Swift doesn't support 32-bit Linux, unknown on other platforms.
        platforms = platforms.linux;
        badPlatforms = platforms.i686;
        timeout = 86400; # 24 hours.
      };
    }
    
  4. TheNightmanCodeth commented on Sep 30, 2024

    @TheNightmanCodeth

    @b521f771d8991e6f1d8e65ae05a8d783 interesting. I'll give this a shot and see if I can get anywhere. I started trying to get a build to go through with HOSTTOOLS bootstrapping but keep hitting "missing libdispatch.so". Hopefully I have more luck with your solution

  5. TheNightmanCodeth commented on Oct 13, 2024

    @TheNightmanCodeth

    image

    Made some decent progress with swift binary distribution from swift.org this weekend. Haven't tried static SDK yet or anything beyond hello world but hopefully I get somewhere soon

    https://github.com/TheNightmanCodeth/swift-bin-flake/tree/wip/wrapper

  6. TheNightmanCodeth commented on Oct 19, 2024

    @TheNightmanCodeth

    Actually got 6.0.1 working for real this time
    image

    Haven't tested Darwin but I doubt it works there. Should work on x86_64-linux and does work on aarch64-linux:

    https://github.com/TheNightmanCodeth/swift-direnv

  7. tknawara commented on Oct 23, 2024

    @tknawara

    @TheNightmanCodeth any chance you are able to build sourcekit-lsp as well, I remember there was an issue when releasing sourcekit-lsp separately from swift build swiftlang/vscode-swift#988

  8. TheNightmanCodeth commented on Oct 24, 2024

    @TheNightmanCodeth

    @TheNightmanCodeth any chance you are able to build sourcekit-lsp as well, I remember there was an issue when releasing sourcekit-lsp separately from swift build swiftlang/vscode-swift#988

    I'll be working on this over the weekend. Will update here

  9. nixos-discourse commented on Nov 3, 2024

    @nixos-discourse

    This issue has been mentioned on NixOS Discourse. There might be relevant details there:

    https://discourse.nixos.org/t/swift-6-coming-soon/55447/2

  10. emilazy commented on Nov 3, 2024

    @emilazy
    Member

    Linking my Discourse post here: https://discourse.nixos.org/t/swift-6-coming-soon/55447/3.

    There’s a bootstrapping issue with Swift 6. We really don’t want to use their build scripts, either, as the current build is insufficiently factored already; having an entire LLVM build that we have to maintain and patch separately in the same derivation as the Swift compiler is a huge source of maintenance hassle and wasted build time. We should ideally be looking at splitting it up more if possible.

    I’m hoping we can have Swift 6 working and building successfully on Hydra for 25.05, though! It’s great to see some preliminary work in that direction and if anyone is interested in cleaning up the Swift derivation then it’d be great to chat in the Matrix room.

  11. added
    6.topic: swift
    on Nov 7, 2024
  12. timothyklim commented on Dec 2, 2024

    @timothyklim
    Contributor

    I made 6.0.2 bin version as a flake: https://github.com/timothyklim/swift-flake that works without FHS, even in bazel with rules_swift. But currently dont have a time to make a PR for nixpkgs

  13. added a commit that references this issue on Dec 8, 2024
  14. igorgue commented on Apr 14, 2025

    @igorgue

    6.1 is out already and it now recommends swiftly to install swift but when I tried swift cannot find some glibc stuff...

  15. 223740 commented on Apr 15, 2025

    @223740
    ContributorAuthor

    Yeah, this is still open. I still think that it would be better to just use swift's own build system and not patch the CMake-Build - this would make updates far easier

  16. 43 remaining items

  17. reckenrode commented on Apr 12, 2026

    @reckenrode
    Contributor
  18. nixos-discourse commented on Jun 2, 2026

    @nixos-discourse
  19. reckenrode commented on Aug 5, 2026

    @reckenrode
    Contributor

    Quick update. I have Swift 6.2.4 building on Darwin and Linux with the new packaging. I’m reviewing open issues for anything else that needs fixed, and then I have to do some cleanup before opening the PR, but it it should be coming soon (in the next week or so).

  20. reckenrode commented on Aug 30, 2026

    @reckenrode
    Contributor
  21. Samuel-Martineau commented on Aug 30, 2026

    @Samuel-Martineau
    Contributor

    Thank you @reckenrode for this amazing work! Swift was quite the beast to tame

  22. shgew commented on Aug 30, 2026

    @shgew
    Member

    Thank you so much @reckenrode!

  23. barkoded commented on Sep 3, 2026

    @barkoded

    Amazing @reckenrode

  24. reckenrode commented on Sep 13, 2026

    @reckenrode
    Contributor

    I plan to merge #557896 on Wednesday or Thursday of this week depending on whether there’s any more feedback. I have Swift 6.3.3 successfully bootstrapping on Darwin. I need to build the rest of the package set to confirm what (if anything) needs updated patches and build it on Linux. I expect Swift 6.3.3 (and 6.4.0) to follow shortly after Swift 6.2.4 is merged.

  25. Cameo007 commented on Sep 17, 2026

    @Cameo007
    Contributor

    Resolved by #557896

  26. reckenrode commented on Sep 17, 2026

    @reckenrode
    Contributor

    Note this is still on staging. The next cycle should start around this weekend and be done the week after (when it will become available on master).

    I have Swift 6.3 building on both platforms. I’m currently cleaning up the update script. Depending on the timing, the Swift 6.3 update may also make the next staging cycle.

  27. reckenrode commented on Sep 22, 2026

    @reckenrode
    Contributor
  28. reckenrode commented on Oct 18, 2026

    @reckenrode
    Contributor

    #574002

    Swift 6.4.1 should follow shortly. I’m doing them separately because I want it to (hopefully) be the first mundane update where changes aren’t required to the Swift packaging.

  29. timothyklim commented on Oct 18, 2026

    @timothyklim
    Contributor

    31. #574002
    Swift 6.4.1 should follow shortly. I’m doing them separately because I want it to (hopefully) be the first mundane update where changes aren’t required to the Swift packaging.

    Thank you so much for your work!

  30. reckenrode commented on Oct 22, 2026

    @reckenrode
    Contributor

    Once #574002 is merged, I can mark #577150 as ready. The 6.4.1 PR is nice and boring. Hopefully Swift 6.5 doesn’t have any surprises. The big one for Swift 6.4 was dealing with the fallout of switching SwiftPM to use Swift Build by default. That’s solved now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    6.topic: swift9.needs: package (update)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions