From c7ca73aecb5736cddc608a040f176f6516e30103 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Sat, 20 Sep 2025 16:34:38 +0200 Subject: [PATCH] Drop support for building with Swift 6.1 Swift 6.2 has been released, so we no longer need to support building and testing SourceKit-LSP using Swift 6.1 --- Package.swift | 2 +- .../LegacyBuildServer.swift | 4 +-- .../Utilities/SwiftExtensions.swift | 5 --- Sources/SourceKitD/SourceKitD.swift | 12 ------- .../SyntaxCodeActionProvider.swift | 5 --- .../ClientPlugin.swift | 36 +------------------ Sources/SwiftSourceKitPlugin/Plugin.swift | 32 +---------------- 7 files changed, 5 insertions(+), 91 deletions(-) diff --git a/Package.swift b/Package.swift index 563d6c4e1..4be8dfde2 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 6.1 +// swift-tools-version: 6.2 import Foundation import PackageDescription diff --git a/Sources/BuildServerIntegration/LegacyBuildServer.swift b/Sources/BuildServerIntegration/LegacyBuildServer.swift index 44e49b262..2578450e7 100644 --- a/Sources/BuildServerIntegration/LegacyBuildServer.swift +++ b/Sources/BuildServerIntegration/LegacyBuildServer.swift @@ -20,8 +20,8 @@ import SKOptions import SwiftExtensions import ToolchainRegistry -#if compiler(>=6.3) -#warning("We have had a one year transition period to the pull based build server. Consider removing this build server") +#if compiler(>=6.5) +#warning("We have had a two year transition period to the pull based build server. Consider removing this build server") #endif /// Bridges the gap between the legacy push-based BSP settings model and the new pull based BSP settings model. diff --git a/Sources/CompletionScoring/Utilities/SwiftExtensions.swift b/Sources/CompletionScoring/Utilities/SwiftExtensions.swift index 25cce7c8a..cf45c3080 100644 --- a/Sources/CompletionScoring/Utilities/SwiftExtensions.swift +++ b/Sources/CompletionScoring/Utilities/SwiftExtensions.swift @@ -289,11 +289,6 @@ protocol ContiguousZeroBasedIndexedCollection: Collection where Index == Int { var indices: Range { get } } -#if compiler(<6.2) -/// Provide a compatibility layer for `SendableMetatype` if it doesn't exist in the compiler -typealias SendableMetatype = Any -#endif - extension ContiguousZeroBasedIndexedCollection { func slicedConcurrentForEachSliceRange(body: @Sendable (Range) -> Void) where Self: SendableMetatype { // We want to use `DispatchQueue.concurrentPerform`, but we want to be called only a few times. So that we diff --git a/Sources/SourceKitD/SourceKitD.swift b/Sources/SourceKitD/SourceKitD.swift index 8765d8ce6..b9d3af1fd 100644 --- a/Sources/SourceKitD/SourceKitD.swift +++ b/Sources/SourceKitD/SourceKitD.swift @@ -173,18 +173,6 @@ package actor SourceKitD { pluginPaths: PluginPaths? ) async throws -> SourceKitD { try await SourceKitDRegistry.shared.getOrAdd(dylibPath, pluginPaths: pluginPaths) { - #if canImport(Darwin) - #if compiler(>=6.3) - #warning("Remove this when we no longer need to support sourcekitd_plugin_initialize") - #endif - if let pluginPaths { - try setenv( - name: "SOURCEKIT_LSP_PLUGIN_SOURCEKITD_PATH_\(pluginPaths.clientPlugin.realpath.filePath)", - value: dylibPath.filePath, - override: false - ) - } - #endif return try SourceKitD(dylib: dylibPath, pluginPaths: pluginPaths) } } diff --git a/Sources/SwiftLanguageService/CodeActions/SyntaxCodeActionProvider.swift b/Sources/SwiftLanguageService/CodeActions/SyntaxCodeActionProvider.swift index d3ccc085e..35c3c8884 100644 --- a/Sources/SwiftLanguageService/CodeActions/SyntaxCodeActionProvider.swift +++ b/Sources/SwiftLanguageService/CodeActions/SyntaxCodeActionProvider.swift @@ -16,11 +16,6 @@ import SourceKitLSP import SwiftRefactor import SwiftSyntax -#if compiler(<6.2) -/// Provide a compatibility layer for `SendableMetatype` if it doesn't exist in the compiler -typealias SendableMetatype = Any -#endif - /// Describes types that provide one or more code actions based on purely /// syntactic information. protocol SyntaxCodeActionProvider: SendableMetatype { diff --git a/Sources/SwiftSourceKitClientPlugin/ClientPlugin.swift b/Sources/SwiftSourceKitClientPlugin/ClientPlugin.swift index b4e908527..2e86c4816 100644 --- a/Sources/SwiftSourceKitClientPlugin/ClientPlugin.swift +++ b/Sources/SwiftSourceKitClientPlugin/ClientPlugin.swift @@ -16,45 +16,11 @@ import SourceKitD import SwiftExtensions import SwiftSourceKitPluginCommon -#if compiler(>=6.3) -#warning("Remove sourcekitd_plugin_initialize when we no longer support toolchains that call it") -#endif - /// Legacy plugin initialization logic in which sourcekitd does not inform the plugin about the sourcekitd path it was /// loaded from. @_cdecl("sourcekitd_plugin_initialize") public func sourcekitd_plugin_initialize(_ params: sourcekitd_api_plugin_initialize_params_t) { - #if canImport(Darwin) - var dlInfo = Dl_info() - dladdr(#dsohandle, &dlInfo) - let path = String(cString: dlInfo.dli_fname) - let clientPluginDylibUrl = URL(fileURLWithPath: path, isDirectory: false) - var url = clientPluginDylibUrl - while url.pathExtension != "framework" && url.lastPathComponent != "/" { - url.deleteLastPathComponent() - } - url = - url - .deletingLastPathComponent() - .appendingPathComponent("sourcekitd.framework") - .appendingPathComponent("sourcekitd") - if !FileManager.default.fileExists(at: url), - let clientPluginDylibUrlRealpath = try? clientPluginDylibUrl.realpath.filePath, - let sourcekitdPath = ProcessInfo.processInfo.environment[ - "SOURCEKIT_LSP_PLUGIN_SOURCEKITD_PATH_\(clientPluginDylibUrlRealpath)" - ] - { - // When using a SourceKit plugin from the build directory, we can't find sourcekitd relative to the plugin. - // Respect the sourcekitd path that was passed to us via an environment variable from - // `SourceKitD.getOrCreate`. - url = URL(fileURLWithPath: sourcekitdPath) - } - try! url.filePath.withCString { sourcekitdPath in - sourcekitd_plugin_initialize_2(params, sourcekitdPath) - } - #else - fatalError("sourcekitd_plugin_initialize is not supported on non-Darwin platforms") - #endif + fatalError("sourcekitd_plugin_initialize has been removed in favor of sourcekitd_plugin_initialize_2") } @_cdecl("sourcekitd_plugin_initialize_2") diff --git a/Sources/SwiftSourceKitPlugin/Plugin.swift b/Sources/SwiftSourceKitPlugin/Plugin.swift index 9372fda9e..10a873d38 100644 --- a/Sources/SwiftSourceKitPlugin/Plugin.swift +++ b/Sources/SwiftSourceKitPlugin/Plugin.swift @@ -157,41 +157,11 @@ final class RequestHandler: Sendable { } } -#if compiler(>=6.3) -#warning("Remove sourcekitd_plugin_initialize when we no longer support toolchains that call it") -#endif - /// Legacy plugin initialization logic in which sourcekitd does not inform the plugin about the sourcekitd path it was /// loaded from. @_cdecl("sourcekitd_plugin_initialize") public func sourcekitd_plugin_initialize(_ params: sourcekitd_api_plugin_initialize_params_t) { - #if canImport(Darwin) - var dlInfo = Dl_info() - dladdr(#dsohandle, &dlInfo) - let path = String(cString: dlInfo.dli_fname) - var url = URL(fileURLWithPath: path, isDirectory: false) - while url.pathExtension != "framework" && url.lastPathComponent != "/" { - url.deleteLastPathComponent() - } - url = - url - .deletingLastPathComponent() - .appendingPathComponent("sourcekitd.framework") - .appendingPathComponent("sourcekitd") - if FileManager.default.fileExists(at: url) { - try! url.filePath.withCString { sourcekitdPath in - sourcekitd_plugin_initialize_2(params, sourcekitdPath) - } - } else { - // When using a SourceKit plugin from the build directory, we can't find sourcekitd relative to the plugin. - // Since sourcekitd_plugin_initialize is only called on Darwin from Xcode toolchains, we know that we are getting - // called from an XPC sourcekitd. Thus, all sourcekitd symbols that we need should be loaded in the current process - // already and we can use `RTLD_DEFAULT` for the sourcekitd library. - sourcekitd_plugin_initialize_2(params, "SOURCEKIT_LSP_PLUGIN_PARENT_LIBRARY_RTLD_DEFAULT") - } - #else - fatalError("sourcekitd_plugin_initialize is not supported on non-Darwin platforms") - #endif + fatalError("sourcekitd_plugin_initialize has been removed in favor of sourcekitd_plugin_initialize_2") } #if canImport(Darwin)