Skip to content

Commit be30f7b

Browse files
committed
Attempt to fix build by reverting #8193 and related commits
1 parent 60b4913 commit be30f7b

31 files changed

+29
-159
lines changed

CMakeLists.txt

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ find_package(Foundation QUIET)
5252
find_package(SQLite3 REQUIRED)
5353

5454
# Enable `package` modifier for the whole package.
55-
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
56-
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:-package-name;SwiftPM>" -L/usr/local/lib)
57-
else()
58-
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:-package-name;SwiftPM>")
59-
endif()
55+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:-package-name;SwiftPM>")
6056

6157
add_subdirectory(BuildSupport/SwiftSyntax)
6258
add_subdirectory(Sources)

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ let package = Package(
205205
name: "Basics",
206206
dependencies: [
207207
"_AsyncFileSystem",
208-
.target(name: "SPMSQLite3", condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .visionOS, .macCatalyst, .linux, .custom("freebsd")])),
208+
.target(name: "SPMSQLite3", condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .visionOS, .macCatalyst, .linux])),
209209
.product(name: "SwiftToolchainCSQLite", package: "swift-toolchain-sqlite", condition: .when(platforms: [.windows, .android])),
210210
.product(name: "DequeModule", package: "swift-collections"),
211211
.product(name: "OrderedCollections", package: "swift-collections"),

Sources/Basics/Archiver/ZipArchiver.swift

-7
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,6 @@ public struct ZipArchiver: Archiver, Cancellable {
109109
arguments: [windowsTar, "-a", "-c", "-f", destinationPath.pathString, directory.basename],
110110
workingDirectory: directory.parentDirectory
111111
)
112-
#elseif os(FreeBSD)
113-
// On FreeBSD, the unzip command is available in base but not the zip command.
114-
// Therefore; we use libarchive(bsdtar) to produce the ZIP archive instead.
115-
let process = AsyncProcess(
116-
arguments: ["tar", "-c", "--format", "zip", "-f", destinationPath.pathString, directory.basename],
117-
workingDirectory: directory.parentDirectory
118-
)
119112
#else
120113
// This is to work around `swift package-registry publish` tool failing on
121114
// Amazon Linux 2 due to it having an earlier Glibc version (rdar://116370323)

Sources/Basics/Cancellator.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public final class Cancellator: Cancellable, Sendable {
7575

7676
// Install the default signal handler.
7777
var action = sigaction()
78-
#if canImport(Darwin) || os(OpenBSD) || os(FreeBSD)
78+
#if canImport(Darwin) || os(OpenBSD)
7979
action.__sigaction_u.__sa_handler = SIG_DFL
8080
#elseif canImport(Musl)
8181
action.__sa_handler.sa_handler = SIG_DFL

Sources/Basics/Concurrency/AsyncProcess.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ package final class AsyncProcess {
553553
return stdinPipe.fileHandleForWriting
554554
#elseif(!canImport(Darwin) || os(macOS))
555555
// Initialize the spawn attributes.
556-
#if canImport(Darwin) || os(Android) || os(OpenBSD) || os(FreeBSD)
556+
#if canImport(Darwin) || os(Android) || os(OpenBSD)
557557
var attributes: posix_spawnattr_t? = nil
558558
#else
559559
var attributes = posix_spawnattr_t()
@@ -598,7 +598,7 @@ package final class AsyncProcess {
598598
posix_spawnattr_setflags(&attributes, Int16(flags))
599599

600600
// Setup the file actions.
601-
#if canImport(Darwin) || os(Android) || os(OpenBSD) || os(FreeBSD)
601+
#if canImport(Darwin) || os(Android) || os(OpenBSD)
602602
var fileActions: posix_spawn_file_actions_t? = nil
603603
#else
604604
var fileActions = posix_spawn_file_actions_t()
@@ -614,8 +614,6 @@ package final class AsyncProcess {
614614
if #available(macOS 10.15, *) {
615615
posix_spawn_file_actions_addchdir_np(&fileActions, workingDirectory)
616616
}
617-
#elseif os(FreeBSD)
618-
posix_spawn_file_actions_addchdir_np(&fileActions, workingDirectory)
619617
#elseif os(Linux)
620618
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
621619
throw AsyncProcess.Error.workingDirectoryNotSupported

Sources/Basics/DispatchTimeInterval+Extensions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extension DispatchTimeInterval {
9595
}
9696

9797
// remove when available to all platforms
98-
#if os(Linux) || os(Windows) || os(Android) || os(OpenBSD) || os(FreeBSD)
98+
#if os(Linux) || os(Windows) || os(Android) || os(OpenBSD)
9999
extension DispatchTime {
100100
public func distance(to: DispatchTime) -> DispatchTimeInterval {
101101
let final = to.uptimeNanoseconds

Sources/Basics/Triple+Basics.swift

+2-6
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ extension Triple {
6262
os == .openbsd
6363
}
6464

65-
public func isFreeBSD() -> Bool {
66-
os == .freebsd
67-
}
68-
6965
/// Returns the triple string for the given platform version.
7066
///
7167
/// This is currently meant for Apple platforms only.
@@ -143,7 +139,7 @@ extension Triple {
143139
switch os {
144140
case _ where isDarwin():
145141
return ".dylib"
146-
case .linux, .openbsd, .freebsd:
142+
case .linux, .openbsd:
147143
return ".so"
148144
case .win32:
149145
return ".dll"
@@ -183,7 +179,7 @@ extension Triple {
183179
switch os {
184180
case _ where isDarwin():
185181
return ""
186-
case .linux, .openbsd, .freebsd:
182+
case .linux, .openbsd:
187183
return ""
188184
case .win32:
189185
return ".exe"

Sources/Basics/Vendor/Triple+Platforms.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ extension Triple {
304304

305305
case .linux:
306306
return environment == .android ? "android" : "linux"
307-
case .freebsd:
307+
case .freeBSD:
308308
return "freebsd"
309309
case .openbsd:
310310
return "openbsd"

Sources/Basics/Vendor/Triple.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ extension Triple {
10891089
case cloudABI = "cloudabi"
10901090
case darwin
10911091
case dragonFly = "dragonfly"
1092-
case freebsd = "freebsd"
1092+
case freeBSD = "freebsd"
10931093
case fuchsia
10941094
case ios
10951095
case kfreebsd
@@ -1137,7 +1137,7 @@ extension Triple {
11371137
case _ where os.hasPrefix("dragonfly"):
11381138
return .dragonFly
11391139
case _ where os.hasPrefix("freebsd"):
1140-
return .freebsd
1140+
return .freeBSD
11411141
case _ where os.hasPrefix("fuchsia"):
11421142
return .fuchsia
11431143
case _ where os.hasPrefix("ios"):

Sources/Build/BuildDescription/ProductBuildDescription.swift

+2-5
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,11 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
270270
// Set rpath such that dynamic libraries are looked up
271271
// adjacent to the product, unless overridden.
272272
if !self.buildParameters.linkingParameters.shouldDisableLocalRpath {
273-
switch triple.objectFormat {
274-
case .elf:
273+
if triple.isLinux() {
275274
args += ["-Xlinker", "-rpath=$ORIGIN"]
276-
case .macho:
275+
} else if triple.isDarwin() {
277276
let rpath = self.product.type == .test ? "@loader_path/../../../" : "@loader_path"
278277
args += ["-Xlinker", "-rpath", "-Xlinker", rpath]
279-
default:
280-
break
281278
}
282279
}
283280
args += ["@\(self.linkFileListPath.pathString)"]

Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public final class SwiftModuleBuildDescription {
144144
public var moduleOutputPath: AbsolutePath { // note: needs to be public because of sourcekit-lsp
145145
// If we're an executable and we're not allowing test targets to link against us, we hide the module.
146146
let triple = buildParameters.triple
147-
let allowLinkingAgainstExecutables = [.coff, .macho, .elf].contains(triple.objectFormat) && self.toolsVersion >= .v5_5
147+
let allowLinkingAgainstExecutables = (triple.isDarwin() || triple.isLinux() || triple.isWindows()) && self.toolsVersion >= .v5_5
148148
let dirPath = (target.type == .executable && !allowLinkingAgainstExecutables) ? self.tempsPath : self.modulesPath
149149
return dirPath.appending(component: "\(self.target.c99name).swiftmodule")
150150
}

Sources/Build/BuildPlan/BuildPlan+Product.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ extension BuildPlan {
6363
for description in dependencies.staticTargets {
6464
if case let target as ClangModule = description.module.underlying, target.isCXX {
6565
let triple = buildProduct.buildParameters.triple
66-
if triple.isDarwin() || triple.isFreeBSD() {
66+
if triple.isDarwin() {
6767
buildProduct.additionalFlags += ["-lc++"]
6868
} else if triple.isWindows() {
6969
// Don't link any C++ library.

Sources/Build/BuildPlan/BuildPlan.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,11 @@ extension BuildParameters {
146146
/// platform, or nil if the linker doesn't support it for the platform.
147147
func linkerFlagsForRenamingMainFunction(of target: ResolvedModule) -> [String]? {
148148
let args: [String]
149-
switch self.triple.objectFormat {
150-
case .macho:
149+
if self.triple.isApple() {
151150
args = ["-alias", "_\(target.c99name)_main", "_main"]
152-
case .elf:
151+
} else if self.triple.isLinux() {
153152
args = ["--defsym", "main=\(target.c99name)_main"]
154-
default:
153+
} else {
155154
return nil
156155
}
157156
return args.asSwiftcLinkerFlags()

Sources/Commands/SwiftTestCommand.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ private extension Basics.Diagnostic {
15381538
/// it duplicates the definition of this constant in its own source. Any changes
15391539
/// to this constant in either package must be mirrored in the other.
15401540
private var EXIT_NO_TESTS_FOUND: CInt {
1541-
#if os(macOS) || os(Linux) || canImport(Android) || os(FreeBSD)
1541+
#if os(macOS) || os(Linux) || canImport(Android)
15421542
EX_UNAVAILABLE
15431543
#elseif os(Windows)
15441544
ERROR_NOT_FOUND

Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private typealias JSONModel = PackageCollectionModel.V1
3232
struct JSONPackageCollectionProvider: PackageCollectionProvider {
3333
// TODO: This can be removed when the `Security` framework APIs that the `PackageCollectionsSigning`
3434
// module depends on are available on all Apple platforms.
35-
#if os(macOS) || os(Linux) || os(Windows) || os(Android) || os(FreeBSD)
35+
#if os(macOS) || os(Linux) || os(Windows) || os(Android)
3636
static let isSignatureCheckSupported = true
3737
#else
3838
static let isSignatureCheckSupported = false
@@ -551,8 +551,6 @@ extension PackageModel.Platform {
551551
self = PackageModel.Platform.wasi
552552
case let name where name.contains("openbsd"):
553553
self = PackageModel.Platform.openbsd
554-
case let name where name.contains("freebsd"):
555-
self = PackageModel.Platform.freebsd
556554
default:
557555
return nil
558556
}

Sources/PackageDescription/SupportedPlatforms.swift

-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ public struct Platform: Equatable, Sendable {
6969
/// The OpenBSD platform.
7070
@available(_PackageDescription, introduced: 5.8)
7171
public static let openbsd: Platform = Platform(name: "openbsd")
72-
73-
/// The FreeBSD platform.
74-
@available(_PackageDescription, introduced: 999.0)
75-
public static let freebsd: Platform = Platform(name: "freebsd")
7672
}
7773

7874
/// A platform that the Swift package supports.

Sources/PackageLoading/Platform.swift

+2-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public enum Platform: Equatable, Sendable {
2525
case darwin
2626
case linux(LinuxFlavor)
2727
case windows
28-
case freebsd
2928

3029
/// Recognized flavors of linux.
3130
public enum LinuxFlavor: Equatable, Sendable {
@@ -45,8 +44,6 @@ extension Platform {
4544
{
4645
case "darwin"?:
4746
return .darwin
48-
case "freebsd"?:
49-
return .freebsd
5047
case "linux"?:
5148
return Platform.findCurrentPlatformLinux(localFileSystem)
5249
default:
@@ -92,15 +89,15 @@ extension Platform {
9289
public var dynamicLibraryExtension: String {
9390
switch self {
9491
case .darwin: return ".dylib"
95-
case .linux, .android, .freebsd: return ".so"
92+
case .linux, .android: return ".so"
9693
case .windows: return ".dll"
9794
}
9895
}
9996

10097
public var executableExtension: String {
10198
switch self {
10299
case .windows: return ".exe"
103-
case .linux, .android, .darwin, .freebsd: return ""
100+
case .linux, .android, .darwin: return ""
104101
}
105102
}
106103
}

Sources/PackageLoading/Target+PkgConfig.swift

+1-9
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ extension SystemPackageProviderDescription {
154154
return " yum install \(packages.joined(separator: " "))\n"
155155
case .nuget(let packages):
156156
return " nuget install \(packages.joined(separator: " "))\n"
157-
case .pkg(let packages):
158-
return " pkg install \(packages.joined(separator: " "))\n"
159157
}
160158
}
161159

@@ -182,13 +180,9 @@ extension SystemPackageProviderDescription {
182180
switch platform {
183181
case .darwin, .windows, .linux:
184182
return true
185-
case .android, .freebsd:
183+
case .android:
186184
return false
187185
}
188-
case .pkg:
189-
if case .freebsd = platform {
190-
return true
191-
}
192186
}
193187
return false
194188
}
@@ -221,8 +215,6 @@ extension SystemPackageProviderDescription {
221215
return []
222216
case .nuget:
223217
return []
224-
case .pkg:
225-
return []
226218
}
227219
}
228220

Sources/PackageModel/Manifest/SystemPackageProviderDescription.swift

+1-9
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ public enum SystemPackageProviderDescription: Hashable, Codable, Sendable {
1616
case apt([String])
1717
case yum([String])
1818
case nuget([String])
19-
case pkg([String])
2019
}
2120

2221
extension SystemPackageProviderDescription {
2322
private enum CodingKeys: String, CodingKey {
24-
case brew, apt, yum, nuget, pkg
23+
case brew, apt, yum, nuget
2524
}
2625

2726
public func encode(to encoder: Encoder) throws {
@@ -39,9 +38,6 @@ extension SystemPackageProviderDescription {
3938
case let .nuget(a1):
4039
var unkeyedContainer = container.nestedUnkeyedContainer(forKey: .nuget)
4140
try unkeyedContainer.encode(a1)
42-
case let .pkg(a1):
43-
var unkeyedContainer = container.nestedUnkeyedContainer(forKey: .pkg)
44-
try unkeyedContainer.encode(a1)
4541
}
4642
}
4743

@@ -67,10 +63,6 @@ extension SystemPackageProviderDescription {
6763
var unkeyedValues = try values.nestedUnkeyedContainer(forKey: key)
6864
let a1 = try unkeyedValues.decode([String].self)
6965
self = .nuget(a1)
70-
case .pkg:
71-
var unkeyedValues = try values.nestedUnkeyedContainer(forKey: key)
72-
let a1 = try unkeyedValues.decode([String].self)
73-
self = .pkg(a1)
7466
}
7567
}
7668
}

Sources/PackageModel/ManifestSourceGeneration.swift

-3
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,6 @@ fileprivate extension SourceCodeFragment {
416416
case .nuget(let names):
417417
let params = [SourceCodeFragment(strings: names)]
418418
self.init(enum: "nuget", subnodes: params)
419-
case .pkg(let names):
420-
let params = [SourceCodeFragment(strings: names)]
421-
self.init(enum: "pkg", subnodes: params)
422419
}
423420
}
424421

Sources/PackageModel/Platform.swift

-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public struct Platform: Equatable, Hashable, Codable, Sendable {
4949
public static let windows: Platform = Platform(name: "windows", oldestSupportedVersion: .unknown)
5050
public static let wasi: Platform = Platform(name: "wasi", oldestSupportedVersion: .unknown)
5151
public static let openbsd: Platform = Platform(name: "openbsd", oldestSupportedVersion: .unknown)
52-
public static let freebsd: Platform = Platform(name: "freebsd", oldestSupportedVersion: .unknown)
53-
5452

5553
}
5654

Sources/PackageModel/PlatformRegistry.swift

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public struct PlatformRegistry {
3838
.macOS,
3939
.macCatalyst,
4040
.openbsd,
41-
.freebsd,
4241
.tvOS,
4342
.visionOS,
4443
.wasi,

Sources/SPMBuildCore/BinaryTarget+Extensions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ extension Triple.OS {
9999
/// Returns a representation of the receiver that can be compared with platform strings declared in an XCFramework.
100100
fileprivate var asXCFrameworkPlatformString: String? {
101101
switch self {
102-
case .darwin, .linux, .wasi, .win32, .openbsd, .freebsd, .noneOS:
102+
case .darwin, .linux, .wasi, .win32, .openbsd, .noneOS:
103103
return nil // XCFrameworks do not support any of these platforms today.
104104
case .macosx:
105105
return "macos"

Sources/SPMBuildCore/BuildParameters/BuildParameters.swift

-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ public struct BuildParameters: Encodable {
115115
return .windows
116116
} else if self.triple.isOpenBSD() {
117117
return .openbsd
118-
} else if self.triple.isFreeBSD() {
119-
return .freebsd
120118
} else {
121119
return .linux
122120
}

Sources/SPMBuildCore/Triple+Extensions.swift

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ extension Triple {
1616
public var platformBuildPathComponent: String {
1717
if isDarwin() {
1818
return self.tripleString(forPlatformVersion: "")
19-
} else if isFreeBSD() {
20-
return "\(self.archName)-\(self.vendorName)-\(self.osNameUnversioned)"
2119
}
2220

2321
return self.tripleString

0 commit comments

Comments
 (0)