From 64c8be7df87de15af2106c27832dc6787fb1e720 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 5 Feb 2025 18:15:29 -0800 Subject: [PATCH] Minimal Swift6 support. Had to use @unchecked Sendable for LLVM ref types. --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 6 +++--- .github/workflows/test.yml | 14 ++------------ CMakeLists.txt | 2 ++ Package.swift | 2 +- Sources/CMakeLists.txt | 1 - Sources/SwiftyLLVM/AddressSpace.swift | 4 ++-- .../SwiftyLLVM/Values/Constants/Intrinsic.swift | 4 ++-- cmake/TopLevelDefaults.cmake | 2 +- 9 files changed, 14 insertions(+), 23 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a546b87..5522671 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -ARG SWIFT_VERSION=5.9 +ARG SWIFT_VERSION=6.0.3 # Other ARG declarations must follow FROM FROM swift:${SWIFT_VERSION} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0222e1c..d3c19f5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "SWIFT_VERSION" : "5.9", + "SWIFT_VERSION" : "6.0.3", "HYLO_LLVM_BUILD_TYPE": "${localEnv:HYLO_LLVM_BUILD_TYPE:MinSizeRel}" } }, @@ -11,8 +11,8 @@ "ghcr.io/devcontainers/features/common-utils:2": { "installZsh": "false", "username": "vscode", - "userUid": "1000", - "userGid": "1000", + "userUid": "1001", + "userGid": "1001", "upgradePackages": "false" }, "ghcr.io/devcontainers/features/git:1": { diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e313aa..8159a9a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ on: - ".editorconfig" env: - swift-version: '5.10' + swift-version: '6.0.3' jobs: dev-container: @@ -122,20 +122,10 @@ jobs: with: xcode-version: latest-stable - - name: 'Set up swift (non-Windows)' - if: ${{ runner.os != 'Windows' }} + - name: 'Set up swift' uses: SwiftyLab/setup-swift@latest with: swift-version: ${{ env.swift-version }} - cache-snapshot: false # Workaround for https://github.com/SwiftyLab/setup-swift/issues/315 - - - uses: compnerd/gha-setup-vsdevenv@main - - name: Set up swift (Windows) - if: ${{ runner.os == 'Windows' }} - uses: compnerd/gha-setup-swift@v0.2.1 - with: - branch: swift-${{ env.swift-version }}-release - tag: ${{ env.swift-version }}-RELEASE - name: Verify swift version run: swift --version && swift --version | grep -q ${{ env.swift-version }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 70be174..aad61c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ project(Swifty-LLVM ) enable_testing() list(PREPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules) +set(CMAKE_Swift_LANGUAGE_VERSION 6) + if (PROJECT_IS_TOP_LEVEL) include(cmake/TopLevelDefaults.cmake) endif() diff --git a/Package.swift b/Package.swift index a37f30f..2fc59d7 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.9 +// swift-tools-version: 6.0 import PackageDescription diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 35c04f1..6e66af7 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -2,7 +2,6 @@ find_package(HyloLLVM) include(HyloUtilities) set(CMAKE_CXX_STANDARD 20) -set(CMAKE_Swift_LANGUAGE_VERSION 5) # Needed? Useful? # LLVM is built this way, and we must stay compatible with it. # TODO: Usage requirement? diff --git a/Sources/SwiftyLLVM/AddressSpace.swift b/Sources/SwiftyLLVM/AddressSpace.swift index 4528b25..a5cc183 100644 --- a/Sources/SwiftyLLVM/AddressSpace.swift +++ b/Sources/SwiftyLLVM/AddressSpace.swift @@ -1,5 +1,5 @@ /// Properties of a pointer expressed through the data layout. -public struct AddressSpace: Hashable { +public struct AddressSpace: Hashable, Sendable { /// The LLVM representation of this instance. public let llvm: UInt32 @@ -10,6 +10,6 @@ public struct AddressSpace: Hashable { } /// The default address space. - public static var `default` = AddressSpace(0) + public static let `default` = AddressSpace(0) } diff --git a/Sources/SwiftyLLVM/Values/Constants/Intrinsic.swift b/Sources/SwiftyLLVM/Values/Constants/Intrinsic.swift index 87c9efb..76d5c69 100644 --- a/Sources/SwiftyLLVM/Values/Constants/Intrinsic.swift +++ b/Sources/SwiftyLLVM/Values/Constants/Intrinsic.swift @@ -37,7 +37,7 @@ extension Intrinsic { /// The name of an intrinsic. @dynamicMemberLookup - public struct Name { + public struct Name: Sendable { /// The value of this instance. public let value: String @@ -55,6 +55,6 @@ extension Intrinsic { } /// The prefix of all intrinsics. - public static var llvm = Name("llvm") + public static let llvm = Name("llvm") } diff --git a/cmake/TopLevelDefaults.cmake b/cmake/TopLevelDefaults.cmake index 1d6a06d..b85a922 100644 --- a/cmake/TopLevelDefaults.cmake +++ b/cmake/TopLevelDefaults.cmake @@ -14,7 +14,7 @@ block() set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE NEVER) FetchContent_Declare(Hylo-CMakeModules GIT_REPOSITORY https://github.com/hylo-lang/CMakeModules.git - GIT_TAG 6577fca + GIT_TAG c13d9d9 OVERRIDE_FIND_PACKAGE )