From 638205e8c69ef22cc58a63a5803ed676a27226f4 Mon Sep 17 00:00:00 2001 From: Erik Eckstein Date: Thu, 27 Jun 2024 10:14:44 +0200 Subject: [PATCH] SwiftCompilerSources: remove references to C's stderr Fixes a linux build error. The `var standardError` was only used in one place for logging, which can be done with `log` anyway. Instead of using such C library constructs directly we should bridge to higher level APIs. This is more platform independent. https://github.com/swiftlang/swift/issues/73252 https://github.com/swiftlang/swift/issues/74701 --- .../Sources/Basic/Utils.swift | 25 ------------------- .../LifetimeDependenceDiagnostics.swift | 5 +--- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/SwiftCompilerSources/Sources/Basic/Utils.swift b/SwiftCompilerSources/Sources/Basic/Utils.swift index bdca8e5ca7a3c..c7d24b5e837ce 100644 --- a/SwiftCompilerSources/Sources/Basic/Utils.swift +++ b/SwiftCompilerSources/Sources/Basic/Utils.swift @@ -67,31 +67,6 @@ public extension NoReflectionChildren { var customMirror: Mirror { Mirror(self, children: []) } } -#if !os(Windows) -// TODO: https://github.com/apple/swift/issues/73252 - -public var standardError = CFileStream(fp: stderr) - -#if os(Android) || canImport(Musl) - public typealias FILEPointer = OpaquePointer -#else - public typealias FILEPointer = UnsafeMutablePointer -#endif - -public struct CFileStream: TextOutputStream { - var fp: FILEPointer - - public func write(_ string: String) { - fputs(string, fp) - } - - public func flush() { - fflush(fp) - } -} - -#endif - //===----------------------------------------------------------------------===// // StringRef //===----------------------------------------------------------------------===// diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceDiagnostics.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceDiagnostics.swift index 7927bd397d34d..65c33912223c3 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceDiagnostics.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceDiagnostics.swift @@ -126,10 +126,7 @@ private struct DiagnoseDependence { } func reportUnknown(operand: Operand) { -#if !os(Windows) - // TODO: https://github.com/apple/swift/issues/73252 - standardError.write("Unknown use: \(operand)\n\(function)") -#endif + log("Unknown use: \(operand)\n\(function)") reportEscaping(operand: operand) }