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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
ARG SWIFT_VERSION=5.9
ARG SWIFT_VERSION=6.1
# Other ARG declarations must follow FROM
FROM swift:${SWIFT_VERSION}

ARG HYLO_LLVM_BUILD_TYPE=MinSizeRel
ARG HYLO_LLVM_BUILD_RELEASE=20240303-215025
ARG HYLO_LLVM_VERSION=17.0.6
ARG CMAKE_VERSION=3.29.1

ENV HYLO_LLVM_DOWNLOAD_URL="https://github.com/hylo-lang/llvm-build/releases/download"

RUN apt install -y gnupg
RUN apt update
RUN apt install -y curl libzstd-dev libzstd1 lsb-release make ninja-build tar wget zstd software-properties-common python3-pip

# 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
# Install the dependencies for the LLVM build.
# Note that we do cleanup in the same layer to save disk space.
RUN apt-get update && \
apt-get install -y --no-install-recommends gnupg curl libzstd-dev libzstd1 lsb-release make \
ninja-build tar wget zstd software-properties-common python3-pip cmake && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Get the LLVM builds for the host architecture
RUN <<EOT bash -ex -o pipefail
Expand Down
8 changes: 4 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"build": {
"dockerfile": "Dockerfile",
"args": {
"SWIFT_VERSION" : "5.9",
"SWIFT_VERSION" : "6.1",
"HYLO_LLVM_BUILD_TYPE": "${localEnv:HYLO_LLVM_BUILD_TYPE:MinSizeRel}"
}
}
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "false",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"userUid": "1001", // 1000 is already taken by the default user in the container
"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.

"upgradePackages": "false"
},
"ghcr.io/devcontainers/features/git:1": {
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
- ".editorconfig"

env:
swift-version: '5.10'
swift-version: '6.1'

jobs:
dev-container:
Expand Down Expand Up @@ -122,12 +122,14 @@ jobs:
with:
xcode-version: latest-stable

- name: Import Swift GPG Key (Ubuntu Only) # until fix arrives for https://github.com/SwiftyLab/setup-swift/issues/388
if: runner.os == 'Linux'
run: gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys '52BB 7E3D E28A 71BE 22EC 05FF EF80 A866 B47A 981F'
- name: 'Set up swift (non-Windows)'
if: ${{ runner.os != 'Windows' }}
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)
Expand Down Expand Up @@ -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' || '' }}
${{ runner.os == 'macOS' && '-DCMAKE_Swift_COMPILER=swiftc -DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path)' || '' }}
working-directory: Swifty-LLVM

- name: Build (CMake)
Expand Down Expand Up @@ -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' || '' }}
${{ runner.os == 'macOS' && '-DCMAKE_Swift_COMPILER=swiftc -DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path)' || '' }}

cd .xcode-build

xcrun xcodebuild -configuration ${{ matrix.spm_configuration }} -scheme SwiftyLLVM -destination 'platform=macOS' test
working-directory: Swifty-LLVM

- name: Build and Test via SPM
if: ${{ runner.os != 'Windows' || env.swift-version != '5.10' }}
run: swift test -v ${{ matrix.swift_test_options }} -c ${{ matrix.spm_configuration }}
working-directory: Swifty-LLVM

Expand All @@ -224,7 +225,7 @@ jobs:

- name: Upload coverage reports to Codecov
if: ${{ contains(matrix.swift_test_options, '--enable-code-coverage') }}
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Standard project boilerplate
#
cmake_minimum_required(VERSION 3.26)
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0)
project(Swifty-LLVM
VERSION 0.1.0
DESCRIPTION "A Swifty interface for the LLVM compiler infrastructure, currently wrapping LLVM's C API."
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.1
import PackageDescription


Expand All @@ -24,7 +24,7 @@ func pseudoPkgConfigText(_ package: String) -> String? {
guard let pcp = ProcessInfo.processInfo.environment["PKG_CONFIG_PATH"] else { return nil }

return pcp.split(separator: pathSeparator)
.lazy.compactMap({ try? String(contentsOfFile: "\($0)/\(package).pc") }).first
.lazy.compactMap({ try? String(contentsOfFile: "\($0)/\(package).pc", encoding: String.Encoding.utf8) }).first
}

/// Returns the un-quoted, un-escaped elements in the remainder of the
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftyLLVM/AddressSpace.swift
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,6 +10,6 @@ public struct AddressSpace: Hashable {
}

/// The default address space.
public static var `default` = AddressSpace(0)
public static let `default` = AddressSpace(0)

}
4 changes: 2 additions & 2 deletions Sources/SwiftyLLVM/Values/Constants/Intrinsic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -55,6 +55,6 @@ extension Intrinsic {
}

/// The prefix of all intrinsics.
public static var llvm = Name("llvm")
public static let llvm = Name("llvm")

}