@@ -131,35 +131,31 @@ extension CompilerPlugin {
131131 /// Main entry point of the plugin — sets up a communication channel with
132132 /// the plugin host and runs the main message loop.
133133 public static func main( ) throws {
134- let stdin = _ss_stdin ( )
135- let stdout = _ss_stdout ( )
136- let stderr = _ss_stderr ( )
137-
138134 // Duplicate the `stdin` file descriptor, which we will then use for
139135 // receiving messages from the plugin host.
140- let inputFD = dup ( fileno ( stdin ) )
136+ let inputFD = dup ( fileno ( _stdin ) )
141137 guard inputFD >= 0 else {
142- internalError ( " Could not duplicate `stdin`: \( describe ( errno: _ss_errno ( ) ) ) . " )
138+ internalError ( " Could not duplicate `stdin`: \( describe ( errno: _errno ) ) . " )
143139 }
144140
145141 // Having duplicated the original standard-input descriptor, we close
146142 // `stdin` so that attempts by the plugin to read console input (which
147143 // are usually a mistake) return errors instead of blocking.
148- guard close ( fileno ( stdin ) ) >= 0 else {
149- internalError ( " Could not close `stdin`: \( describe ( errno: _ss_errno ( ) ) ) . " )
144+ guard close ( fileno ( _stdin ) ) >= 0 else {
145+ internalError ( " Could not close `stdin`: \( describe ( errno: _errno ) ) . " )
150146 }
151147
152148 // Duplicate the `stdout` file descriptor, which we will then use for
153149 // sending messages to the plugin host.
154- let outputFD = dup ( fileno ( stdout ) )
150+ let outputFD = dup ( fileno ( _stdout ) )
155151 guard outputFD >= 0 else {
156- internalError ( " Could not dup `stdout`: \( describe ( errno: _ss_errno ( ) ) ) . " )
152+ internalError ( " Could not dup `stdout`: \( describe ( errno: _errno ) ) . " )
157153 }
158154
159155 // Having duplicated the original standard-output descriptor, redirect
160156 // `stdout` to `stderr` so that all free-form text output goes there.
161- guard dup2 ( fileno ( stderr ) , fileno ( stdout ) ) >= 0 else {
162- internalError ( " Could not dup2 `stdout` to `stderr`: \( describe ( errno: _ss_errno ( ) ) ) . " )
157+ guard dup2 ( fileno ( _stderr ) , fileno ( _stdout ) ) >= 0 else {
158+ internalError ( " Could not dup2 `stdout` to `stderr`: \( describe ( errno: _errno ) ) . " )
163159 }
164160
165161 #if canImport(ucrt)
@@ -189,7 +185,7 @@ extension CompilerPlugin {
189185
190186 // Private function to report internal errors and then exit.
191187 fileprivate static func internalError( _ message: String ) -> Never {
192- fputs ( " Internal Error: \( message) \n " , _ss_stderr ( ) )
188+ fputs ( " Internal Error: \( message) \n " , _stderr )
193189 exit ( 1 )
194190 }
195191}
@@ -240,7 +236,7 @@ private func _write(_ fd: CInt, contentsOf buffer: UnsafeRawBufferPointer) throw
240236 let endPtr = ptr. advanced ( by: buffer. count)
241237 while ptr != endPtr {
242238 switch write ( fd, ptr, numericCast ( endPtr - ptr) ) {
243- case - 1 : throw IOError . writeFailed ( errno: _ss_errno ( ) )
239+ case - 1 : throw IOError . writeFailed ( errno: _errno )
244240 case 0 : throw IOError . writeFailed ( errno: 0 ) /* unreachable */
245241 case let n: ptr += Int ( n)
246242 }
@@ -255,7 +251,7 @@ private func _read(_ fd: CInt, into buffer: UnsafeMutableRawBufferPointer) throw
255251 let endPtr = ptr. advanced ( by: buffer. count)
256252 while ptr != endPtr {
257253 switch read ( fd, ptr, numericCast ( endPtr - ptr) ) {
258- case - 1 : throw IOError . readFailed ( errno: _ss_errno ( ) )
254+ case - 1 : throw IOError . readFailed ( errno: _errno )
259255 case 0 : throw IOError . readReachedEndOfInput
260256 case let n: ptr += Int ( n)
261257 }
0 commit comments