-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download and use the latest NDK 27 on the CI
- Loading branch information
1 parent
20b250a
commit c293be7
Showing
7 changed files
with
241 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
diff --git a/swift/stdlib/public/Platform/android.modulemap b/swift/stdlib/public/Platform/android.modulemap | ||
index 78e7bda9976..dc25e5c3668 100644 | ||
--- a/swift/stdlib/public/Platform/android.modulemap | ||
+++ b/swift/stdlib/public/Platform/android.modulemap | ||
@@ -556,6 +556,12 @@ module _bits_sa_family_t [system] { | ||
header "bits/sa_family_t.h" | ||
export * | ||
} | ||
+ | ||
+module _bits_sockaddr_storage [system] { | ||
+ header "bits/sockaddr_storage.h" | ||
+ export * | ||
+} | ||
+ | ||
module _bits_stdatomic [system] { | ||
// Note: this module is not part of 'stdatomic' | ||
// as it depends on libc++ and forcing it to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
commit 7e5350751e17515253c096350dddd3aeeda0eee2 | ||
Author: Evan Wilde <etceterawilde@gmail.com> | ||
Date: Tue Jul 9 22:45:20 2024 -0700 | ||
|
||
Workaround broken glibc modulemap | ||
|
||
We have been running into modularization issues on newer versions of | ||
various Linux distros, resulting in the compiler saying that the Glibc | ||
module doesn't have a SOCK_STREAM or SOCK_DGRAM. From some poking | ||
around, the definition is now coming from the CoreFoundation module as | ||
far as Swift is concerned. This is ultimately because our modulemap for | ||
Glibc is bad, but also means that I can't bring up Swift 6 on all of the | ||
Linux distros that 5.10 has support for. | ||
|
||
This workaround removes the explicit module name from `SOCK_STREAM` and | ||
renames it to `FOUNDATION_SOCK_STREAM` to avoid an ambiguous name, and | ||
completely removes `SOCK_DGRAM`. | ||
|
||
Both SOCK_STREAM and SOCK_DGRAM are fileprivates, so changing them will | ||
have no visible external effect. It is true that if another header | ||
somewhere defines `SOCK_STREAM`, we may pick it up instead of the | ||
definition from the glibc module, but that will also cause some nasty | ||
surprises to anyone using that header in C, so it is unlikely. | ||
|
||
Fixes: rdar://128079849 | ||
|
||
diff --git a/swift-corelibs-foundation/Sources/Foundation/Port.swift b/swift-corelibs-foundation/Sources/Foundation/Port.swift | ||
index c53263f0..f06f95a9 100644 | ||
--- a/swift-corelibs-foundation/Sources/Foundation/Port.swift | ||
+++ b/swift-corelibs-foundation/Sources/Foundation/Port.swift | ||
@@ -90,18 +90,22 @@ open class SocketPort: Port {} | ||
|
||
#else | ||
|
||
+#if canImport(Darwin) | ||
+import Darwin | ||
+fileprivate let FOUNDATION_SOCK_STREAM = SOCK_STREAM | ||
+fileprivate let FOUNDATION_IPPROTO_TCP = IPPROTO_TCP | ||
+#endif | ||
+ | ||
#if canImport(Glibc) && !os(Android) && !os(OpenBSD) | ||
import Glibc | ||
-fileprivate let SOCK_STREAM = Int32(Glibc.SOCK_STREAM.rawValue) | ||
-fileprivate let SOCK_DGRAM = Int32(Glibc.SOCK_DGRAM.rawValue) | ||
-fileprivate let IPPROTO_TCP = Int32(Glibc.IPPROTO_TCP) | ||
+fileprivate let FOUNDATION_SOCK_STREAM = Int32(SOCK_STREAM.rawValue) | ||
+fileprivate let FOUNDATION_IPPROTO_TCP = Int32(IPPROTO_TCP) | ||
#endif | ||
|
||
#if canImport(Glibc) && os(Android) || os(OpenBSD) | ||
import Glibc | ||
-fileprivate let SOCK_STREAM = Int32(Glibc.SOCK_STREAM) | ||
-fileprivate let SOCK_DGRAM = Int32(Glibc.SOCK_DGRAM) | ||
-fileprivate let IPPROTO_TCP = Int32(Glibc.IPPROTO_TCP) | ||
+fileprivate let FOUNDATION_SOCK_STREAM = Int32(SOCK_STREAM) | ||
+fileprivate let FOUNDATION_IPPROTO_TCP = Int32(IPPROTO_TCP) | ||
fileprivate let INADDR_ANY: in_addr_t = 0 | ||
#if os(OpenBSD) | ||
fileprivate let INADDR_LOOPBACK = 0x7f000001 | ||
@@ -123,7 +127,8 @@ import WinSDK | ||
fileprivate typealias sa_family_t = ADDRESS_FAMILY | ||
fileprivate typealias in_port_t = USHORT | ||
fileprivate typealias in_addr_t = UInt32 | ||
-fileprivate let IPPROTO_TCP = Int32(WinSDK.IPPROTO_TCP.rawValue) | ||
+fileprivate let FOUNDATION_SOCK_STREAM = SOCK_STREAM | ||
+fileprivate let FOUNDATION_IPPROTO_TCP = Int32(WinSDK.IPPROTO_TCP.rawValue) | ||
#endif | ||
|
||
// MARK: Darwin representation of socket addresses | ||
@@ -484,7 +489,7 @@ open class SocketPort : Port { | ||
|
||
let data = withUnsafeBytes(of: address) { Data($0) } | ||
|
||
- self.init(protocolFamily: PF_INET, socketType: SOCK_STREAM, protocol: IPPROTO_TCP, address: data) | ||
+ self.init(protocolFamily: PF_INET, socketType: FOUNDATION_SOCK_STREAM, protocol: FOUNDATION_IPPROTO_TCP, address: data) | ||
} | ||
|
||
private final func createNonuniquedCore(from socket: CFSocket, protocolFamily family: Int32, socketType type: Int32, protocol: Int32) { | ||
@@ -500,7 +505,7 @@ open class SocketPort : Port { | ||
var context = CFSocketContext() | ||
context.info = Unmanaged.passUnretained(self).toOpaque() | ||
var s: CFSocket | ||
- if type == SOCK_STREAM { | ||
+ if type == FOUNDATION_SOCK_STREAM { | ||
s = CFSocketCreate(nil, family, type, `protocol`, CFOptionFlags(kCFSocketAcceptCallBack), __NSFireSocketAccept, &context) | ||
} else { | ||
s = CFSocketCreate(nil, family, type, `protocol`, CFOptionFlags(kCFSocketDataCallBack), __NSFireSocketDatagram, &context) | ||
@@ -519,7 +524,7 @@ open class SocketPort : Port { | ||
var context = CFSocketContext() | ||
context.info = Unmanaged.passUnretained(self).toOpaque() | ||
var s: CFSocket | ||
- if type == SOCK_STREAM { | ||
+ if type == FOUNDATION_SOCK_STREAM { | ||
s = CFSocketCreateWithNative(nil, CFSocketNativeHandle(sock), CFOptionFlags(kCFSocketAcceptCallBack), __NSFireSocketAccept, &context) | ||
} else { | ||
s = CFSocketCreateWithNative(nil, CFSocketNativeHandle(sock), CFOptionFlags(kCFSocketDataCallBack), __NSFireSocketDatagram, &context) | ||
@@ -543,7 +548,7 @@ open class SocketPort : Port { | ||
sinAddr.sin_addr = inAddr | ||
|
||
let data = withUnsafeBytes(of: sinAddr) { Data($0) } | ||
- self.init(remoteWithProtocolFamily: PF_INET, socketType: SOCK_STREAM, protocol: IPPROTO_TCP, address: data) | ||
+ self.init(remoteWithProtocolFamily: PF_INET, socketType: FOUNDATION_SOCK_STREAM, protocol: FOUNDATION_IPPROTO_TCP, address: data) | ||
return | ||
} | ||
} | ||
@@ -556,7 +561,7 @@ open class SocketPort : Port { | ||
sinAddr.sin6_addr = in6Addr | ||
|
||
let data = withUnsafeBytes(of: sinAddr) { Data($0) } | ||
- self.init(remoteWithProtocolFamily: PF_INET, socketType: SOCK_STREAM, protocol: IPPROTO_TCP, address: data) | ||
+ self.init(remoteWithProtocolFamily: PF_INET, socketType: FOUNDATION_SOCK_STREAM, protocol: FOUNDATION_IPPROTO_TCP, address: data) | ||
return | ||
} | ||
} | ||
@@ -573,7 +578,7 @@ open class SocketPort : Port { | ||
withUnsafeBytes(of: in_addr_t(INADDR_LOOPBACK).bigEndian) { buffer.copyMemory(from: $0) } | ||
} | ||
let data = withUnsafeBytes(of: sinAddr) { Data($0) } | ||
- self.init(remoteWithProtocolFamily: PF_INET, socketType: SOCK_STREAM, protocol: IPPROTO_TCP, address: data) | ||
+ self.init(remoteWithProtocolFamily: PF_INET, socketType: FOUNDATION_SOCK_STREAM, protocol: FOUNDATION_IPPROTO_TCP, address: data) | ||
} | ||
|
||
private static let remoteSocketCoresLock = NSLock() | ||
@@ -1049,7 +1054,7 @@ open class SocketPort : Port { | ||
if let connector = core.connectors[signature], CFSocketIsValid(connector) { | ||
return connector | ||
} else { | ||
- if signature.socketType == SOCK_STREAM { | ||
+ if signature.socketType == FOUNDATION_SOCK_STREAM { | ||
if let connector = CFSocketCreate(nil, socketKind.protocolFamily, socketKind.socketType, socketKind.protocol, CFOptionFlags(kCFSocketDataCallBack), __NSFireSocketData, &context), CFSocketIsValid(connector) { | ||
var timeout = time - Date.timeIntervalSinceReferenceDate | ||
if timeout < 0 || timeout >= SocketPort.maximumTimeout { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
diff --git a/Sources/NIOPosix/System.swift b/Sources/NIOPosix/System.swift | ||
index 33b3be73..b97fa645 100644 | ||
--- a/Sources/NIOPosix/System.swift | ||
+++ b/Sources/NIOPosix/System.swift | ||
@@ -125,15 +125,15 @@ private let sysWritev = sysWritev_wrapper | ||
private let sysWritev: @convention(c) (Int32, UnsafePointer<iovec>?, CInt) -> CLong = writev | ||
#endif | ||
#if !os(Windows) | ||
-private let sysRecvMsg: @convention(c) (CInt, UnsafeMutablePointer<msghdr>?, CInt) -> ssize_t = recvmsg | ||
-private let sysSendMsg: @convention(c) (CInt, UnsafePointer<msghdr>?, CInt) -> ssize_t = sendmsg | ||
+private let sysRecvMsg: @convention(c) (CInt, UnsafeMutablePointer<msghdr>, CInt) -> ssize_t = recvmsg | ||
+private let sysSendMsg: @convention(c) (CInt, UnsafePointer<msghdr>, CInt) -> ssize_t = sendmsg | ||
#endif | ||
private let sysDup: @convention(c) (CInt) -> CInt = dup | ||
#if !os(Windows) | ||
private let sysGetpeername: | ||
- @convention(c) (CInt, UnsafeMutablePointer<sockaddr>?, UnsafeMutablePointer<socklen_t>?) -> CInt = getpeername | ||
+ @convention(c) (CInt, UnsafeMutablePointer<sockaddr>, UnsafeMutablePointer<socklen_t>) -> CInt = getpeername | ||
private let sysGetsockname: | ||
- @convention(c) (CInt, UnsafeMutablePointer<sockaddr>?, UnsafeMutablePointer<socklen_t>?) -> CInt = getsockname | ||
+ @convention(c) (CInt, UnsafeMutablePointer<sockaddr>, UnsafeMutablePointer<socklen_t>) -> CInt = getsockname | ||
#endif | ||
|
||
#if os(Android) | ||
@@ -142,7 +142,7 @@ private let sysIfNameToIndex: @convention(c) (UnsafePointer<CChar>) -> CUnsigned | ||
private let sysIfNameToIndex: @convention(c) (UnsafePointer<CChar>?) -> CUnsignedInt = if_nametoindex | ||
#endif | ||
#if !os(Windows) | ||
-private let sysSocketpair: @convention(c) (CInt, CInt, CInt, UnsafeMutablePointer<CInt>?) -> CInt = socketpair | ||
+private let sysSocketpair: @convention(c) (CInt, CInt, CInt, UnsafeMutablePointer<CInt>) -> CInt = socketpair | ||
#endif | ||
|
||
#if os(Linux) || os(Android) || canImport(Darwin) | ||
@@ -966,7 +966,7 @@ internal enum Posix { | ||
socketVector: UnsafeMutablePointer<CInt>? | ||
) throws { | ||
_ = try syscall(blocking: false) { | ||
- sysSocketpair(domain.rawValue, type.rawValue, protocolSubtype.rawValue, socketVector) | ||
+ sysSocketpair(domain.rawValue, type.rawValue, protocolSubtype.rawValue, socketVector!) | ||
} | ||
} | ||
#endif |