From 4fc2be6b1f599d475b2a38fcd1f83545a7ed6aa6 Mon Sep 17 00:00:00 2001 From: Michael Rawdon Date: Tue, 12 Aug 2025 16:39:01 -0700 Subject: [PATCH 1/9] Fix build warnings about unused variable 'buildService', and unnecessary 'try await'. This now matches similar methods in the same file by simply returning a StringListResponse with an empty array. rdar://122969732 --- Sources/SWBBuildService/Messages.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Sources/SWBBuildService/Messages.swift b/Sources/SWBBuildService/Messages.swift index 070b5d3c..ded6b880 100644 --- a/Sources/SWBBuildService/Messages.swift +++ b/Sources/SWBBuildService/Messages.swift @@ -99,12 +99,10 @@ private struct MacCatalystUnavailableFrameworkNamesHandler: MessageHandler { } } +// TODO: Delete once all clients are no longer calling the public APIs which invoke this message private struct AppleSystemFrameworkNamesHandler: MessageHandler { func handle(request: Request, message: AppleSystemFrameworkNamesRequest) async throws -> StringListResponse { - guard let buildService = request.service as? BuildService else { - throw StubError.error("service object is not of type BuildService") - } - return try await StringListResponse([]) + return StringListResponse([]) } } From 93b06f8e05ebb6ee227f3d5474936b74fb79cdce Mon Sep 17 00:00:00 2001 From: Michael Rawdon Date: Tue, 12 Aug 2025 16:40:43 -0700 Subject: [PATCH 2/9] Fix build warning about switch not being exhaustive. VirtualPath.buildArtifactWithKnownContents is a recent addition to the enum. --- Sources/SWBCore/LibSwiftDriver/PlannedBuild.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SWBCore/LibSwiftDriver/PlannedBuild.swift b/Sources/SWBCore/LibSwiftDriver/PlannedBuild.swift index 5b7a5685..8fcefc65 100644 --- a/Sources/SWBCore/LibSwiftDriver/PlannedBuild.swift +++ b/Sources/SWBCore/LibSwiftDriver/PlannedBuild.swift @@ -25,7 +25,7 @@ private extension Path { init(_ virtualPath: TypedVirtualPath) throws { switch virtualPath.file { case let .absolute(absPath): self = Path(absPath.pathString) - case .standardInput, .standardOutput, .fileList, .relative, .temporary, .temporaryWithKnownContents: + case .standardInput, .standardOutput, .fileList, .relative, .temporary, .temporaryWithKnownContents, .buildArtifactWithKnownContents: fallthrough @unknown default: throw StubError.error("Cannot build Path from \(virtualPath); unimplemented path type.") From 10a3723baa84346a7852ff735556d6729633a651 Mon Sep 17 00:00:00 2001 From: Michael Rawdon Date: Tue, 12 Aug 2025 16:41:24 -0700 Subject: [PATCH 3/9] Fix build warning about unnecessary 'await'. --- Sources/SWBCore/LinkageDependencyResolver.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SWBCore/LinkageDependencyResolver.swift b/Sources/SWBCore/LinkageDependencyResolver.swift index 9c648201..78897d9d 100644 --- a/Sources/SWBCore/LinkageDependencyResolver.swift +++ b/Sources/SWBCore/LinkageDependencyResolver.swift @@ -166,7 +166,7 @@ actor LinkageDependencyResolver { return nil } let buildParameters = resolver.buildParametersByTarget[target] ?? configuredTarget.parameters - if await !resolver.isTargetSuitableForPlatformForIndex(target, parameters: buildParameters, imposedParameters: imposedParameters) { + if !resolver.isTargetSuitableForPlatformForIndex(target, parameters: buildParameters, imposedParameters: imposedParameters) { return nil } let effectiveImposedParameters = imposedParameters?.effectiveParameters(target: configuredTarget, dependency: ConfiguredTarget(parameters: buildParameters, target: target), dependencyResolver: resolver) From f1b7379c0770fca82be77cc6617512dc0ad2eb94 Mon Sep 17 00:00:00 2001 From: Michael Rawdon Date: Tue, 12 Aug 2025 16:42:02 -0700 Subject: [PATCH 4/9] Fix build warning about unnecessary 'await'. rdar://148558223 --- Sources/SWBCore/SpecImplementations/Tools/CCompiler.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SWBCore/SpecImplementations/Tools/CCompiler.swift b/Sources/SWBCore/SpecImplementations/Tools/CCompiler.swift index d09d9119..279b0b3b 100644 --- a/Sources/SWBCore/SpecImplementations/Tools/CCompiler.swift +++ b/Sources/SWBCore/SpecImplementations/Tools/CCompiler.swift @@ -1065,7 +1065,7 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible // Start with the executable. let compilerExecPath = resolveExecutablePath(cbc, forLanguageOfFileType: resolvedInputFileType) - let launcher = await resolveCompilerLauncher(cbc, compilerPath: compilerExecPath, delegate: delegate) + let launcher = resolveCompilerLauncher(cbc, compilerPath: compilerExecPath, delegate: delegate) if let launcher { commandLine += [launcher.str] } From ac04e7a934bc60112c5f40f096899a885b9fe205 Mon Sep 17 00:00:00 2001 From: Michael Rawdon Date: Tue, 12 Aug 2025 16:44:01 -0700 Subject: [PATCH 5/9] Fix build warnings in BuildOperationTester.swift about the return value of withTimeout(timeout:description:) being unused by marking the method with @discardableResult. rdar://122969153 --- Sources/SWBTestSupport/Timeout.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SWBTestSupport/Timeout.swift b/Sources/SWBTestSupport/Timeout.swift index 42e54606..c50176b5 100644 --- a/Sources/SWBTestSupport/Timeout.swift +++ b/Sources/SWBTestSupport/Timeout.swift @@ -14,7 +14,7 @@ package struct TimeoutError: Error { package var description: String? } -package func withTimeout( +@discardableResult package func withTimeout( timeout: Duration, description: String? = nil, block: sending () async throws -> T From 85e1aea7a7f6173d07011bc59c7577b3590fb316 Mon Sep 17 00:00:00 2001 From: Michael Rawdon Date: Tue, 12 Aug 2025 16:44:42 -0700 Subject: [PATCH 6/9] Fix build warning about unused variable 'toolchain'. rdar://156114187 --- Tests/SWBBuildSystemTests/CustomTaskBuildOperationTests.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/SWBBuildSystemTests/CustomTaskBuildOperationTests.swift b/Tests/SWBBuildSystemTests/CustomTaskBuildOperationTests.swift index 763d508a..736b48d2 100644 --- a/Tests/SWBBuildSystemTests/CustomTaskBuildOperationTests.swift +++ b/Tests/SWBBuildSystemTests/CustomTaskBuildOperationTests.swift @@ -29,7 +29,6 @@ fileprivate struct CustomTaskBuildOperationTests: CoreBasedTests { try await withTemporaryDirectory { tmpDir in let destination: RunDestinationInfo = .host let core = try await getCore() - let toolchain = try #require(core.toolchainRegistry.defaultToolchain) let environment = destination.hostRuntimeEnvironment(core) let testProject = TestProject( From 69dcfd94f5cff88edc3e6c39768a5d803907c875 Mon Sep 17 00:00:00 2001 From: Michael Rawdon Date: Tue, 12 Aug 2025 16:45:09 -0700 Subject: [PATCH 7/9] Fix build warning about unused variable 't2'. rdar://152192658 --- Tests/SWBCoreTests/DependencyScopingTests.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/SWBCoreTests/DependencyScopingTests.swift b/Tests/SWBCoreTests/DependencyScopingTests.swift index 635577d9..a18490c4 100644 --- a/Tests/SWBCoreTests/DependencyScopingTests.swift +++ b/Tests/SWBCoreTests/DependencyScopingTests.swift @@ -160,7 +160,6 @@ import Foundation // Configure the targets and create a BuildRequest. let buildParameters = BuildParameters(configuration: "Debug") let t1 = BuildRequest.BuildTargetInfo(parameters: buildParameters, target: try #require(workspace.target(named: "T1"))) - let t2 = BuildRequest.BuildTargetInfo(parameters: buildParameters, target: try #require(workspace.target(named: "T2"))) do { let buildRequest = BuildRequest(parameters: buildParameters, buildTargets: [t1], dependencyScope: .workspace, continueBuildingAfterErrors: true, useParallelTargets: false, useImplicitDependencies: true, useDryRun: false) let buildRequestContext = BuildRequestContext(workspaceContext: workspaceContext) From 90327c86c008b67421faa0449de47d4c0bcac05e Mon Sep 17 00:00:00 2001 From: Michael Rawdon Date: Tue, 12 Aug 2025 16:51:41 -0700 Subject: [PATCH 8/9] Fix build warnings about how the tested value can never be nil, by performing a similar but valid check. rdar://122971963 --- .../MsgPackSerializationPerfTests.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/SWBUtilPerfTests/MsgPackSerializationPerfTests.swift b/Tests/SWBUtilPerfTests/MsgPackSerializationPerfTests.swift index 5727c39e..dd005c7e 100644 --- a/Tests/SWBUtilPerfTests/MsgPackSerializationPerfTests.swift +++ b/Tests/SWBUtilPerfTests/MsgPackSerializationPerfTests.swift @@ -44,7 +44,7 @@ fileprivate struct MsgPackSerializationPerfTests: PerfTests { await measure { for _ in 1...iterations { - #expect(self.serializeScalarData() != nil) + #expect(!self.serializeScalarData().byteString.isEmpty) } } } @@ -91,7 +91,7 @@ fileprivate struct MsgPackSerializationPerfTests: PerfTests { await measure { for _ in 1...iterations { - #expect(self.serializeStringData() != nil) + #expect(!self.serializeStringData().byteString.isEmpty) } } } @@ -133,7 +133,7 @@ fileprivate struct MsgPackSerializationPerfTests: PerfTests { await measure { for _ in 1...iterations { - #expect(self.serializeArrayData() != nil) + #expect(!self.serializeArrayData().byteString.isEmpty) } } } @@ -171,7 +171,7 @@ fileprivate struct MsgPackSerializationPerfTests: PerfTests { await measure { for _ in 1...iterations { - #expect(self.serializeDictionaryData() != nil) + #expect(!self.serializeDictionaryData().byteString.isEmpty) } } } @@ -220,7 +220,7 @@ fileprivate struct MsgPackSerializationPerfTests: PerfTests { { for _ in 1...iterations { - #expect(self.serializeCustomElementData(elements) != nil) + #expect(!self.serializeCustomElementData(elements).byteString.isEmpty) } } } From efec36e4e87634a6c2471de974597bcfad929646 Mon Sep 17 00:00:00 2001 From: Michael Rawdon Date: Tue, 12 Aug 2025 16:52:23 -0700 Subject: [PATCH 9/9] Fix build warning about unused variable 'hostOS'. rdar://155898976 --- Tests/SWBUtilTests/FSProxyTests.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Tests/SWBUtilTests/FSProxyTests.swift b/Tests/SWBUtilTests/FSProxyTests.swift index 0389b852..ebfced2a 100644 --- a/Tests/SWBUtilTests/FSProxyTests.swift +++ b/Tests/SWBUtilTests/FSProxyTests.swift @@ -466,8 +466,6 @@ import SWBTestSupport let fileAtts = try FileManager.default.attributesOfItem(atPath: filePath.str) let fileMgrModDate = try #require(fileAtts[FileAttributeKey.modificationDate] as? Date) - // not working on Windows for some reason - let hostOS = try ProcessInfo.processInfo.hostOperatingSystem() #expect(fsModDate == fileMgrModDate) } }