[swcomp] Remove support code for Linux and Windows

These days swcomp is explicitly supported only on macOS. Furthermore, SwiftCLI requires adjustments to compile on Linux or Windows, which I don't have time to implement. Thus, swcomp won't support these two platforms in the foreseeable future.
This commit is contained in:
Timofey Solomko committed 2026-06-27 21:37:28 +08:00
1 parent ff4cedeb7d
commit b07fa0633f
5 files changed
+4 -61

No files matched your search

@@ -32,35 +32,19 @@ struct BenchmarkMetadata: Codable, Equatable {
private static func getExecURL(for command: String) throws -> URL {
let args = ["-c", "which \(command)"]
#if os(Windows)
swcompExit(.benchmarkCannotGetSubcommandPathWindows)
#else
let output = try BenchmarkMetadata.run(command: URL(fileURLWithPath: "/bin/sh"), arguments: args)
#endif
let output = try BenchmarkMetadata.run(command: URL(fileURLWithPath: "/bin/sh"), arguments: args)
return URL(fileURLWithPath: String(output.dropLast()))
}
private static func getOsInfo() throws -> String {
#if os(Linux)
return try BenchmarkMetadata.run(command: BenchmarkMetadata.getExecURL(for: "uname"), arguments: ["-a"])
#else
#if os(Windows)
return "Unknown Windows OS"
#else
return try BenchmarkMetadata.run(command: BenchmarkMetadata.getExecURL(for: "sw_vers"))
#endif
#endif
return try BenchmarkMetadata.run(command: BenchmarkMetadata.getExecURL(for: "sw_vers"))
}
init(_ description: String?, _ preserveTimestamp: Bool) throws {
self.timestamp = preserveTimestamp ? Date.timeIntervalSinceReferenceDate : nil
self.osInfo = try BenchmarkMetadata.getOsInfo()
#if os(Windows)
self.swiftVersion = "Unknown Swift version on Windows"
#else
self.swiftVersion = try BenchmarkMetadata.run(command: BenchmarkMetadata.getExecURL(for: "swift"),
arguments: ["-version"])
#endif
self.swiftVersion = try BenchmarkMetadata.run(command: BenchmarkMetadata.getExecURL(for: "swift"),
arguments: ["-version"])
self.swcVersion = _SWC_VERSION
self.description = description
}
@@ -3,10 +3,6 @@
//
// See LICENSE for license information
#if os(Linux)
import CoreFoundation
#endif
import Foundation
import SWCompression
import SwiftCLI
@@ -3,10 +3,6 @@
//
// See LICENSE for license information
#if os(Linux)
import CoreFoundation
#endif
import Foundation
import SwiftCLI
@@ -77,9 +73,6 @@ final class RunBenchmarkCommand: Command {
var squareSum = 0.0
print("Iterations: ", terminator: "")
#if !os(Linux)
fflush(__stdoutp)
#endif
var iterations = [Double]()
for i in 1...iterationCount {
if i > 1 {
@@ -87,9 +80,6 @@ final class RunBenchmarkCommand: Command {
}
let speed = benchmark.measure()
print(benchmark.format(speed), terminator: "")
#if !os(Linux)
fflush(__stdoutp)
#endif
sum += speed
squareSum += speed * speed
iterations.append(speed)
@@ -68,16 +68,6 @@ func writeDirectory<T: ContainerEntry>(_ entry: T, _ outputURL: URL, _ verbose:
var attributes = [FileAttributeKey: Any]()
#if !os(Linux) // On linux only permissions attribute is supported.
if let mtime = entry.info.modificationTime {
attributes[FileAttributeKey.modificationDate] = mtime
}
if let ctime = entry.info.creationTime {
attributes[FileAttributeKey.creationDate] = ctime
}
#endif
if let permissions = entry.info.permissions?.rawValue, permissions > 0 {
attributes[FileAttributeKey.posixPermissions] = NSNumber(value: permissions)
}
@@ -132,16 +122,6 @@ func writeFile<T: ContainerEntry>(_ entry: T, _ outputURL: URL, _ verbose: Bool)
var attributes = [FileAttributeKey: Any]()
#if !os(Linux) // On linux only permissions attribute is supported.
if let mtime = entry.info.modificationTime {
attributes[FileAttributeKey.modificationDate] = mtime
}
if let ctime = entry.info.creationTime {
attributes[FileAttributeKey.creationDate] = ctime
}
#endif
if let permissions = entry.info.permissions?.rawValue, permissions > 0 {
attributes[FileAttributeKey.posixPermissions] = NSNumber(value: permissions)
}
@@ -174,10 +174,3 @@ extension TarEntry {
}
}
#if os(Linux) || os(Windows)
@discardableResult
fileprivate func autoreleasepool<T>(_ block: () throws -> T) rethrows -> T {
return try block()
}
#endif