Skip to content

Swift 6 Support #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

tothambrus11
Copy link

@tothambrus11 tothambrus11 commented May 5, 2025

Upgraded Swift 6 by

  • marking some structs Sendable
  • converting 2 mutable global variables (Name.llvm and AddressSpace.default) to constants.
  • bumping versin numbers in docker, devcontainer and github workflow
  • changing a usage of String(contentsOfFile:) to explicitly pass character encoding and praying that it's utf8. (I checked the llvm.pc, it was indeed utf8, but idk if this is a guarantee)

CI fixes:

  • fix CMake installation. Python's pip installation to install packages globally is deprecated, and it would require another python tool called pipx to do things "properly". So instead I installed cmake from official binaries.
  • fix MacOS builds: same fix as for the Hylo repo, now we are required to pass the DCMAKE_OSX_SYSROOT variable: ${{ matrix.os == 'macos-13' && '-DCMAKE_Swift_COMPILER=swiftc -DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path)' || '' }}
  • allow SPM builds on windows. Finally, Swift 6 fixed SPM builds on windows, so we can enable them again :D

@tothambrus11 tothambrus11 marked this pull request as draft May 5, 2025 07:38
@tothambrus11 tothambrus11 force-pushed the swift-601 branch 2 times, most recently from ba0a314 to 338e248 Compare May 5, 2025 08:21
@tothambrus11 tothambrus11 changed the title Swift 601 Swift 6 Support May 5, 2025
@tothambrus11 tothambrus11 marked this pull request as ready for review May 5, 2025 09:58
# Get a recent cmake (https://www.kitware.com//cmake-python-wheels/)
RUN if $(/usr/bin/which cmake) ; then apt purge --auto-remove cmake ; fi
RUN pip3 install --upgrade cmake
# Remove system cmake if installed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we replacing a simple method of upgrading cmake with a more complex one?
The original was an officially supported method as referenced in the URL.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A month ago when I started this, pip was complaining that installing stuff without a virtual envirnment was dangerous and I should use pipx. It seems, since then they reverted this warning, and now I could install cmake globally without an issue.

I replaced the cmake installation with an even simpler one, just using apt-get. Since the Swift 6.1 image is using Ubuntu 24, it is a quite recent version (28), so I think it should be okay. Should I revert back to the pip method? (that may come with some extra runtime cost)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hylo's CMakeLists.txt says: cmake_minimum_required(VERSION 3.30). I think we should use Swifty-LLVM as a testbed for Hylo CI/configuration, and try to replicate as much as possible in both places. So I think pip is the better choice.

"userUid": "1000",
"userGid": "1000",
"userUid": "1001",
"userGid": "1001",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I know why you did this; it's usually prudent to add a comment for subtle things like this. // userid 1001 becayse https://something… could be sufficient.

@@ -168,7 +170,7 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
-DBUILD_TESTING=YES
-DLLVM_DIR=${{ github.workspace }}/${{ env.llvm_package_basename }}/lib/cmake/llvm
${{ runner.os == 'macOS' && '-D CMAKE_Swift_COMPILER=swiftc' || '' }}
${{ matrix.os == 'macos-13' && '-DCMAKE_Swift_COMPILER=swiftc -DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path)' || '' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use runner was correct and intentional. We don't care which version of macOS is being used and anyway, the matrix is a per-project configuration thing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh true, I didn't catch this when pasting something from the other project. I'll fix this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If by the other project you mean Hylo, we probably ought to make that one match this one. I wish there was a simpler way to share GH actions configuration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're feeling ambitious, explore this

@@ -197,15 +199,14 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
-DBUILD_TESTING=YES
-DLLVM_DIR=${{ github.workspace }}/${{ env.llvm_package_basename }}/lib/cmake/llvm
${{ runner.os == 'macOS' && '-D CMAKE_Swift_COMPILER=swiftc' || '' }}
${{ matrix.os == 'macos-13' && '-DCMAKE_Swift_COMPILER=swiftc -DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path)' || '' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Contributor

@dabrahams dabrahams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the comments I left inline before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants