From 48119dbbd23e3eabba48952ac7f75ebeeb87c217 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Thu, 13 Aug 2026 16:35:49 +0100 Subject: [PATCH] Simplify imports in SocketAddresses.swift (#3696) Motivation: The module map for glibc is broken which can lead libc symbols being attributed to the wrong module. In NIO, SocketAddresses.swift imports CNIOLinux (and friends) but, as far as I can tell, doesn't use any of their symbols directly. The result is that various libc symbols incorrectly get attributed to CNIOLinux and compilation can fail for downstream packages with member import visibility checks enabled. See also: https://github.com/swiftlang/swift/issues/85427 Modifications: - Remove the CNIO* imports from SocketAddresses.swift as they appear to be unused - Simplify the imoport block Result: Can build grpc with member import visibility checks enabled. Co-authored-by: Cory Benfield --- Sources/NIOCore/SocketAddresses.swift | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Sources/NIOCore/SocketAddresses.swift b/Sources/NIOCore/SocketAddresses.swift index 80d7fddb0..b1769347a 100644 --- a/Sources/NIOCore/SocketAddresses.swift +++ b/Sources/NIOCore/SocketAddresses.swift @@ -44,21 +44,14 @@ private typealias in_port_t = WinSDK.u_short private typealias sa_family_t = WinSDK.ADDRESS_FAMILY #elseif canImport(Darwin) import Darwin -#elseif os(Linux) || os(Android) +#elseif os(Linux) || os(Android) || os(FreeBSD) || os(OpenBSD) #if canImport(Glibc) @preconcurrency import Glibc #elseif canImport(Musl) @preconcurrency import Musl #elseif canImport(Android) @preconcurrency import Android -#endif -import CNIOLinux -#elseif os(FreeBSD) -@preconcurrency import Glibc -import CNIOFreeBSD -#elseif os(OpenBSD) -@preconcurrency import Glibc -import CNIOOpenBSD +#endif // canImport(Glibc) #elseif canImport(WASILibc) @preconcurrency import WASILibc #else