I only seem to be able to install Swift 5.1.5 on Raspbian GNU/Linux 10 (buster) so have set my dependency on NIO as .upToNextMinor(from: "2.29.0") since 2.30.0 requires 5.2. But when I build I get compile errors for missing symbols:
.build/checkouts/swift-nio/Sources/NIO/BSDSocketAPI.swift:393:43: error: use of unresolved identifier 'SO_RCVTIMEO'
NIOBSDSocket.Option(rawValue: SO_RCVTIMEO)
^~~~~~~~~~~
.build/checkouts/swift-nio/Sources/NIO/BSDSocketAPI.swift:404:43: error: use of unresolved identifier 'SO_TIMESTAMP'
NIOBSDSocket.Option(rawValue: SO_TIMESTAMP)
^~~~~~~~~~~~
.build/checkouts/swift-nio/Sources/NIO/BSDSocketAPI.swift:393:43: error: use of unresolved identifier 'SO_RCVTIMEO'
NIOBSDSocket.Option(rawValue: SO_RCVTIMEO)
^~~~~~~~~~~
.build/checkouts/swift-nio/Sources/NIO/BSDSocketAPI.swift:404:43: error: use of unresolved identifier 'SO_TIMESTAMP'
NIOBSDSocket.Option(rawValue: SO_TIMESTAMP)
^~~~~~~~~~~~
.build/checkouts/swift-nio/Sources/NIO/BSDSocketAPI.swift:393:43: error: use of unresolved identifier 'SO_RCVTIMEO'
NIOBSDSocket.Option(rawValue: SO_RCVTIMEO)
^~~~~~~~~~~
.build/checkouts/swift-nio/Sources/NIO/BSDSocketAPI.swift:404:43: error: use of unresolved identifier 'SO_TIMESTAMP'
NIOBSDSocket.Option(rawValue: SO_TIMESTAMP)
^~~~~~~~~~~~
.build/checkouts/swift-nio/Sources/NIO/BSDSocketAPI.swift:393:43: error: use of unresolved identifier 'SO_RCVTIMEO'
NIOBSDSocket.Option(rawValue: SO_RCVTIMEO)
^~~~~~~~~~~
.build/checkouts/swift-nio/Sources/NIO/BSDSocketAPI.swift:404:43: error: use of unresolved identifier 'SO_TIMESTAMP'
NIOBSDSocket.Option(rawValue: SO_TIMESTAMP)
^~~~~~~~~~~~
.build/checkouts/swift-nio/Sources/NIO/BSDSocketAPI.swift:393:43: error: use of unresolved identifier 'SO_RCVTIMEO'
NIOBSDSocket.Option(rawValue: SO_RCVTIMEO)
Any clues on what is missing for these symbols? TIA
lukasa
(Cory Benfield)
2
I believe this is a bug that got fixed in 2.30.0 affecting only 32-bit arm systems.
What's the concern with installing later Swift versions on Raspbian?
What's the concern with installing later Swift versions on Raspbian?
pi@raspberrypi4:~ $ sudo apt upgrade swift5
Reading package lists... Done
Building dependency tree
Reading state information... Done
swift5 is already the newest version (5.1.5-v0.1).
I've tried upgrading via packagecloud but admit I'm not that familiar with apt and can't get it to install.
But it does look like I should be able to patch in this change, no?
Patching that in I get it to build on the Pi, but it fails before the bind on the Pi where it works ok on Mac.
init(port: UInt) {
listeningPort = port
// Set up the server using a Bootstrap
let bootstrap = ServerBootstrap(group: group)
// Define backlog and enable SO_REUSEADDR options atethe server level
.serverChannelOption(ChannelOptions.backlog, value: 256)
.serverChannelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1)
// Handler Pipeline: handlers that are processing events from accepted Channels
// To demonstrate that we can have several reusable handlers we start with a Swift-NIO default
// handler that limits the speed at which we read from the client if we cannot keep up with the
// processing through EchoHandler.
// This is to protect the server from overload.
.childChannelInitializer { channel in
channel.pipeline.addHandlers([BackPressureHandler(),TCPSocketClientHandler(channels: self.connectedChannels)])
}
// Enable common socket options at the channel level (TCP_NODELAY and SO_REUSEADDR).
// These options are applied to accepted Channels
.childChannelOption(ChannelOptions.socket(IPPROTO_TCP, TCP_NODELAY), value: 1)
.childChannelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1)
// Message grouping
.childChannelOption(ChannelOptions.maxMessagesPerRead, value: 16)
// Let Swift-NIO adjust the buffer size, based on actual trafic.
.childChannelOption(ChannelOptions.recvAllocator, value: AdaptiveRecvByteBufferAllocator())
// Bind the port and run the server
do {
channel = try bootstrap.bind(host: "0.0.0.0", port: Int(listeningPort)).wait()
print("Server started and listening on \(channel!.localAddress!)")
}
catch let error {
print("Server failed to start: \(error.localizedDescription)")
channel = nil
}
}
I simply get an Illegal Instruction before the binding call.
You could try the Swift 5.4 build for Raspbian Buster linked here. I have not tried it, just saw the link. @uraimo has probably been too busy to get those Swift 5.4 arm builds out into the apt repos.
You could try the Swift 5.4 build for Raspbian Buster linked here. I have not tried it, just saw the link. @uraimo has probably been too busy to get those Swift 5.4 arm builds out into the apt repos.
Thanks, I will give that a try.
Those targets are vapor at the moment. 5.1.5 is the last release.
More investigation that removing this line from the bootstrap
.childChannelOption(ChannelOptions.recvAllocator, value: AdaptiveRecvByteBufferAllocator())
lets it get to the bind, but the bind then also fails with an illegal instruction. I imagine its a 32bit vs 64bit conundrum.
I imagine its a 32bit vs 64bit conundrum.
No, I regularly build and test NIO on Android armv7 without a problem, using the Termux Swift toolchain package that runs on Android phones. I think your problem is more related to your outdated armv6 target or something.
No, I regularly build and test NIO on Android armv7 without a problem, using the Termux Swift toolchain package that runs on Android phones. I think your problem is more related to your outdated armv6 target or something.
Ok, off the ubuntu I go I guess. I hope my HAT is supported there :)
ea7kir
(Michael Naylor)
11
Hi. this is the first time I've ever able to offer help on this forum. I'm developing a server app on a Raspberry Pi 4, but I installed RaspiOS Lite Arm 64 Beta raspberrypi.org and everything I need is working just fine. Of course, this might has nothing to do with your Vapor problem.
1 Like
lukasa
(Cory Benfield)
12
I doubt this is a 32-bit vs 64-bit issue, I'm pretty sure you're hitting a fatalError of some kind. Can I recommend running this under a debugger and printing out the crashing call stack?
I'm on a headless Pi. I'm gonna have to brush up on my command line lldb skills...