Skip to content

Commit

Permalink
SwiftCompilerSources: remove references to C's stderr
Browse files Browse the repository at this point in the history
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.

swiftlang#73252
swiftlang#74701
  • Loading branch information
eeckstein committed Jun 27, 2024
1 parent a5ac6aa commit 638205e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
25 changes: 0 additions & 25 deletions SwiftCompilerSources/Sources/Basic/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<FILE>
#endif

public struct CFileStream: TextOutputStream {
var fp: FILEPointer

public func write(_ string: String) {
fputs(string, fp)
}

public func flush() {
fflush(fp)
}
}

#endif

//===----------------------------------------------------------------------===//
// StringRef
//===----------------------------------------------------------------------===//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 638205e

Please sign in to comment.