Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build error on Ubuntu 18, Swift 5.1 : "reference to 'SHA256_CTX' is ambiguous" #116

Closed
glaurent opened this issue Jul 12, 2019 · 6 comments · Fixed by #117
Closed

build error on Ubuntu 18, Swift 5.1 : "reference to 'SHA256_CTX' is ambiguous" #116

glaurent opened this issue Jul 12, 2019 · 6 comments · Fixed by #117

Comments

@glaurent
Copy link

I'm trying to build swift-nio-ssl on an Ubuntu 18 machine, using Swift 5.1, as part of a server based on Vapor 4 alpha (yes I know). Everything builds fine except for the following error :

<unknown>:0: error: reference to 'SHA256_CTX' is ambiguous /srv/datadisk01/www/VideoSaverServer/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL/base.h:411:32: note: candidate found by name lookup is 'SHA256_CTX' typedef struct sha256_state_st SHA256_CTX; ^ //usr/include/openssl/sha.h:56:3: note: candidate found by name lookup is 'SHA256_CTX' } SHA256_CTX; ^ Failed to reconstruct type for $sSo10SHA256_CTXaD Original type: (type_alias_type decl=CAPNSOpenSSL.(file).SHA256_CTX)

Is that error expected somehow ? I have libssl 1.1 installed on this server, on which the vapor package depends.

@Lukasa
Copy link
Contributor

Lukasa commented Jul 12, 2019

This error seems surprising: we seem to be conflicting with libssl. I’m a bit surprised that the libssl is being included at all though. Can you provide the verbose output for this build?

@glaurent
Copy link
Author

Sure, here it is

warning: 'fetch' command is deprecated; use 'resolve' instead
Fetching https://github.com/vapor/vapor.git
Fetching https://github.com/vapor/crypto-kit.git
Fetching https://github.com/vapor/routing-kit.git
Fetching https://github.com/vapor/async-kit.git
Fetching https://github.com/vapor/nio-websocket-client.git
Fetching https://github.com/kylebrowning/APNSwift
Fetching https://github.com/apple/swift-nio-extras.git
Fetching https://github.com/vapor/swift-nio-http-client.git
Fetching https://github.com/apple/swift-nio-ssl.git
Fetching https://github.com/apple/swift-log.git
Fetching https://github.com/apple/swift-nio-http2.git
Fetching https://github.com/vapor/console-kit.git
Fetching https://github.com/apple/swift-nio.git
Completed resolution in 28.70s
Cloning https://github.com/vapor/console-kit.git
Resolving https://github.com/vapor/console-kit.git at 4.0.0-alpha.1
Cloning https://github.com/vapor/nio-websocket-client.git
Resolving https://github.com/vapor/nio-websocket-client.git at 1.0.0-alpha.1
Cloning https://github.com/apple/swift-nio-ssl.git
Resolving https://github.com/apple/swift-nio-ssl.git at 2.1.1
Cloning https://github.com/apple/swift-log.git
Resolving https://github.com/apple/swift-log.git at 1.1.0
Cloning https://github.com/vapor/vapor.git
Resolving https://github.com/vapor/vapor.git at 4.0.0-alpha.1.5
Cloning https://github.com/vapor/swift-nio-http-client.git
Resolving https://github.com/vapor/swift-nio-http-client.git at 0.0.0
Cloning https://github.com/kylebrowning/APNSwift
Resolving https://github.com/kylebrowning/APNSwift at 1.0.0
Cloning https://github.com/vapor/crypto-kit.git
Resolving https://github.com/vapor/crypto-kit.git at 4.0.0-alpha.1
Cloning https://github.com/apple/swift-nio-http2.git
Resolving https://github.com/apple/swift-nio-http2.git at 1.3.0
Cloning https://github.com/apple/swift-nio-extras.git
Resolving https://github.com/apple/swift-nio-extras.git at 1.1.0
Cloning https://github.com/vapor/routing-kit.git
Resolving https://github.com/vapor/routing-kit.git at 4.0.0-alpha.1
Cloning https://github.com/vapor/async-kit.git
Resolving https://github.com/vapor/async-kit.git at 1.0.0-alpha.1
Cloning https://github.com/apple/swift-nio.git
Resolving https://github.com/apple/swift-nio.git at 2.4.0
Fetching Dependencies [Done]
Building Project ...
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketClient.swift:24:31: warning: conformance of 'HTTPRequestEncoder' to protocol 'RemovableChannelHandler' was already stated in the type's module 'NIOHTTP1'
extension HTTPRequestEncoder: RemovableChannelHandler { }
                              ^
NIOHTTP1.HTTPRequestEncoder:1:20: note: 'HTTPRequestEncoder' declares conformance to protocol 'RemovableChannelHandler' here
final public class HTTPRequestEncoder : NIO.ChannelOutboundHandler, NIO.RemovableChannelHandler {
                   ^
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketHandler.swift:29:13: warning: variable 'frame' was never mutated; consider changing to 'let' constant
        var frame = self.unwrapInboundIn(data)
        ~~~ ^
        let
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketClient.swift:24:31: warning: conformance of 'HTTPRequestEncoder' to protocol 'RemovableChannelHandler' was already stated in the type's module 'NIOHTTP1'
extension HTTPRequestEncoder: RemovableChannelHandler { }
                              ^
NIOHTTP1.HTTPRequestEncoder:1:20: note: 'HTTPRequestEncoder' declares conformance to protocol 'RemovableChannelHandler' here
final public class HTTPRequestEncoder : NIO.ChannelOutboundHandler, NIO.RemovableChannelHandler {
                   ^
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketHandler.swift:29:13: warning: variable 'frame' was never mutated; consider changing to 'let' constant
        var frame = self.unwrapInboundIn(data)
        ~~~ ^
        let
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketClient.swift:24:31: warning: conformance of 'HTTPRequestEncoder' to protocol 'RemovableChannelHandler' was already stated in the type's module 'NIOHTTP1'
extension HTTPRequestEncoder: RemovableChannelHandler { }
                              ^
NIOHTTP1.HTTPRequestEncoder:1:20: note: 'HTTPRequestEncoder' declares conformance to protocol 'RemovableChannelHandler' here
final public class HTTPRequestEncoder : NIO.ChannelOutboundHandler, NIO.RemovableChannelHandler {
                   ^
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketHandler.swift:29:13: warning: variable 'frame' was never mutated; consider changing to 'let' constant
        var frame = self.unwrapInboundIn(data)
        ~~~ ^
        let
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketClient.swift:24:31: warning: conformance of 'HTTPRequestEncoder' to protocol 'RemovableChannelHandler' was already stated in the type's module 'NIOHTTP1'
extension HTTPRequestEncoder: RemovableChannelHandler { }
                              ^
NIOHTTP1.HTTPRequestEncoder:1:20: note: 'HTTPRequestEncoder' declares conformance to protocol 'RemovableChannelHandler' here
final public class HTTPRequestEncoder : NIO.ChannelOutboundHandler, NIO.RemovableChannelHandler {
                   ^
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketHandler.swift:29:13: warning: variable 'frame' was never mutated; consider changing to 'let' constant
        var frame = self.unwrapInboundIn(data)
        ~~~ ^
        let
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketClient.swift:24:31: warning: conformance of 'HTTPRequestEncoder' to protocol 'RemovableChannelHandler' was already stated in the type's module 'NIOHTTP1'
extension HTTPRequestEncoder: RemovableChannelHandler { }
                              ^
NIOHTTP1.HTTPRequestEncoder:1:20: note: 'HTTPRequestEncoder' declares conformance to protocol 'RemovableChannelHandler' here
final public class HTTPRequestEncoder : NIO.ChannelOutboundHandler, NIO.RemovableChannelHandler {
                   ^
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketHandler.swift:29:13: warning: variable 'frame' was never mutated; consider changing to 'let' constant
        var frame = self.unwrapInboundIn(data)
        ~~~ ^
        let
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketClient.swift:24:31: warning: conformance of 'HTTPRequestEncoder' to protocol 'RemovableChannelHandler' was already stated in the type's module 'NIOHTTP1'
extension HTTPRequestEncoder: RemovableChannelHandler { }
                              ^
NIOHTTP1.HTTPRequestEncoder:1:20: note: 'HTTPRequestEncoder' declares conformance to protocol 'RemovableChannelHandler' here
final public class HTTPRequestEncoder : NIO.ChannelOutboundHandler, NIO.RemovableChannelHandler {
                   ^
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/nio-websocket-client/Sources/NIOWebSocketClient/WebSocketHandler.swift:29:13: warning: variable 'frame' was never mutated; consider changing to 'let' constant
        var frame = self.unwrapInboundIn(data)
        ~~~ ^
        let
<unknown>:0: error: reference to 'SHA256_CTX' is ambiguous
/srv/datadisk01/www/VideoSaverServer/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL/base.h:411:32: note: candidate found by name lookup is 'SHA256_CTX'
typedef struct sha256_state_st SHA256_CTX;
                               ^
//usr/include/openssl/sha.h:56:3: note: candidate found by name lookup is 'SHA256_CTX'
} SHA256_CTX;
  ^
Failed to reconstruct type for $sSo10SHA256_CTXaD
Original type:
(type_alias_type decl=CAPNSOpenSSL.(file).SHA256_CTX)
Stack dump:
0.	Program arguments: /usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift -frontend -c -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSSwiftJWT/APNSwiftJWT.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSSwiftJWT/APNSwiftJWTError.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSSwiftJWT/Data+Base64URL.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftConfiguration.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftConnection.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftErrors.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftPointerTricks.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftRequest.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftRequestContext.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftRequestEncoder.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftResponse.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftResponseDecoder.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftSigner.swift -primary-file /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftStreamHandler.swift -supplementary-output-file-map /tmp/supplementaryOutputs-8a97b3 -target x86_64-unknown-linux -disable-objc-interop -sdk / -I /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug -I /srv/datadisk01/www/VideoSaverServer/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /srv/datadisk01/www/VideoSaverServer/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include -I /srv/datadisk01/www/VideoSaverServer/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include -I /srv/datadisk01/www/VideoSaverServer/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /srv/datadisk01/www/VideoSaverServer/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /srv/datadisk01/www/VideoSaverServer/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /srv/datadisk01/www/VideoSaverServer/.build/checkouts/swift-nio/Sources/CNIOLinux/include -enable-testing -g -module-cache-path /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=/srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/CNIOBoringSSLShims.build/module.modulemap -Xcc -fmodule-map-file=/srv/datadisk01/www/VideoSaverServer/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include/module.modulemap -Xcc -fmodule-map-file=/srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/CAPNSOpenSSL/module.modulemap -parse-as-library -module-name APNSwift -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSSwiftJWT/APNSwiftJWT.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSSwiftJWT/APNSwiftJWTError.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSSwiftJWT/Data+Base64URL.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftConfiguration.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftConnection.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftErrors.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftPointerTricks.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftRequest.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftRequestContext.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftRequestEncoder.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftResponse.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftResponseDecoder.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftSigner.swift.o -o /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/APNSwift.build/APNSwiftStreamHandler.swift.o -index-store-path /srv/datadisk01/www/VideoSaverServer/.build/x86_64-unknown-linux/debug/index/store -index-system-modules 
1.	While emitting IR SIL function "@$s8APNSwift0A3JWTV6sha25633_AAE6F96E24F1CD18F931B2288965D25BLL7message3NIO10ByteBufferVAI_tF".
 for 'sha256(message:)' (at /srv/datadisk01/www/VideoSaverServer/.build/checkouts/APNSwift/Sources/APNSwift/APNSSwiftJWT/APNSwiftJWT.swift:70:13)
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x4517774]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x45153ce]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x4517b88]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7f975deaa890]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f975c30de97]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f975c30f801]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x6a7dc3]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x6a112d]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x6a0f91]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x6c7eb3]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x6c44d9]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x6b2d55]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x5e260b]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x54e0c7]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x54e601]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x4d4ff2]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x4d0c0e]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x473b16]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f975c2f0b97]
/usr/local/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-09-a-ubuntu18.04/usr/bin/swift[0x47377a]

Building Project [Failed]
Error: execute(code: 1)
admin@server01:~/www/VideoSaverServer$ 

@weissi
Copy link
Member

weissi commented Jul 13, 2019

I can reproduce. This looks like a new bug in Swift 5.1. Here's my repro project:

Package.swift

// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "qwer",
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://github.com/vapor/console-kit.git", from: "4.0.0-alpha.1"),
        .package(url: "https://github.com/vapor/nio-websocket-client.git", from: "1.0.0-alpha.1"),
        .package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.1.1"),
        .package(url: "https://github.com/apple/swift-log.git", from: "1.1.0"),
        .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0-alpha.1.5"),
        .package(url: "https://github.com/vapor/swift-nio-http-client.git", from: "0.0.0"),
        .package(url: "https://github.com/kylebrowning/APNSwift", from: "1.0.0"),
        .package(url: "https://github.com/vapor/crypto-kit.git", from: "4.0.0-alpha.1"),
        .package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.3.0"),
        .package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.1.0"),
        .package(url: "https://github.com/vapor/routing-kit.git", from: "4.0.0-alpha.1"),
        .package(url: "https://github.com/vapor/async-kit.git", from: "1.0.0-alpha.1"),
        .package(url: "https://github.com/apple/swift-nio.git", from: "2.4.0"),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "qwer",
            dependencies: [
"APNSwift",
"Vapor",
"NIOWebSocketClient",
"NIOHTTPClient",
"NIOExtras",
"NIOHTTPCompression",
"ConsoleKit",
"RoutingKit",
"NIO",
"_NIO1APIShims",
"NIOTLS",
"NIOHTTP1",
"NIOConcurrencyHelpers",
"NIOFoundationCompat",
"NIOWebSocket",
"NIOTestUtils",
"Logging",
"AsyncKit",
"NIOHTTP2",
"NIOSSL",
"CryptoKit",
            ]),
        .testTarget(
            name: "qwerTests",
            dependencies: ["qwer"]),
    ]
)

and main.swift

import APNSwift
import Vapor
import NIOWebSocketClient
import NIOHTTPClient
import NIOExtras
import NIOHTTPCompression
import ConsoleKit
import RoutingKit
import NIO
import _NIO1APIShims
import NIOTLS
import NIOHTTP1
import NIOConcurrencyHelpers
import NIOFoundationCompat
import NIOWebSocket
import NIOTestUtils
import Logging
import AsyncKit
import NIOHTTP2
import NIOSSL
import CryptoKit
print("Hello, world!")

when compiled with swift 5.1 from Xcode 11 beta 3 (Apple Swift version 5.1 (swiftlang-1100.0.212.5 clang-1100.0.28.2)), then everything goes okay but when compiling with the 12th July 5.1 snapshot (Apple Swift version 5.1-dev (LLVM 688b71e2f9, Swift a062b3ca64)), then we get errors similar to what you've seen:

<unknown>:0: error: reference to 'ECDSA_SIG' is ambiguous
/private/tmp/qwer/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include/CNIOBoringSSL/base.h:388:29: note: candidate found by name lookup is 'ECDSA_SIG'
typedef struct ecdsa_sig_st ECDSA_SIG;
                            ^
/usr/local/Cellar/openssl/1.0.2r/include/openssl/ecdsa.h:81:3: note: candidate found by name lookup is 'ECDSA_SIG'
} ECDSA_SIG;
  ^

followed by a Swift compiler crasher

Failed to reconstruct type for $sSpySo9ECDSA_SIGaGSgD
Original type:
(bound_generic_enum_type decl=Swift.(file).Optional
  (bound_generic_struct_type decl=Swift.(file).UnsafeMutablePointer
    (type_alias_type decl=CAPNSOpenSSL.(file).ECDSA_SIG)))
Stack dump:
0.	Program arguments: /Library/Developer/Toolchains/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-07-12-a.xctoolchain/usr/bin/swift -frontend -c /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSSwiftJWT/APNSwiftJWT.swift /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSSwiftJWT/APNSwiftJWTError.swift /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSSwiftJWT/Data+Base64URL.swift /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftConfiguration.swift /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftConnection.swift /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftErrors.swift /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftPointerTricks.swift /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftRequest.swift /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftRequestContext.swift /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftRequestEncoder.swift /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftResponse.swift -primary-file /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftResponseDecoder.swift -primary-file /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftSigner.swift -primary-file /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftStreamHandler.swift -emit-module-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftResponseDecoder~partial.swiftmodule -emit-module-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftSigner~partial.swiftmodule -emit-module-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftStreamHandler~partial.swiftmodule -emit-module-doc-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftResponseDecoder~partial.swiftdoc -emit-module-doc-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftSigner~partial.swiftdoc -emit-module-doc-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftStreamHandler~partial.swiftdoc -emit-dependencies-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftResponseDecoder.d -emit-dependencies-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftSigner.d -emit-dependencies-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftStreamHandler.d -emit-reference-dependencies-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftResponseDecoder.swiftdeps -emit-reference-dependencies-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftSigner.swiftdeps -emit-reference-dependencies-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftStreamHandler.swiftdeps -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I /private/tmp/qwer/.build/x86_64-apple-macosx/debug -I /private/tmp/qwer/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /private/tmp/qwer/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include -I /private/tmp/qwer/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include -I /private/tmp/qwer/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /private/tmp/qwer/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /private/tmp/qwer/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /private/tmp/qwer/.build/checkouts/swift-nio/Sources/CNIOLinux/include -I /usr/local/Cellar/openssl/1.0.2r/include -I /usr/local/Cellar/openssl/1.0.2r/include -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=/private/tmp/qwer/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/private/tmp/qwer/.build/x86_64-apple-macosx/debug/CNIOBoringSSLShims.build/module.modulemap -Xcc -fmodule-map-file=/private/tmp/qwer/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include/module.modulemap -Xcc -fmodule-map-file=/private/tmp/qwer/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/private/tmp/qwer/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/private/tmp/qwer/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/private/tmp/qwer/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/private/tmp/qwer/.build/checkouts/APNSwift/Sources/CAPNSOpenSSL/module.modulemap -parse-as-library -module-name APNSwift -o /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftResponseDecoder.swift.o -o /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftSigner.swift.o -o /private/tmp/qwer/.build/x86_64-apple-macosx/debug/APNSwift.build/APNSwiftStreamHandler.swift.o -index-store-path /private/tmp/qwer/.build/x86_64-apple-macosx/debug/index/store -index-system-modules 
1.	While emitting IR SIL function "@$s8APNSwift0A6SignerV4sign6digest3NIO10ByteBufferVAH_tKF".
 for 'sign(digest:)' (at /private/tmp/qwer/.build/checkouts/APNSwift/Sources/APNSwift/APNSwiftSigner.swift:35:14)
0  swift                    0x00000001132eff15 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x00000001132ef205 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x00000001132f04f8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff67ae2b1d _sigtramp + 29
4  libsystem_platform.dylib 0x000000011ce699cc _sigtramp + 3040374476
5  libsystem_c.dylib        0x00007fff679b8a5c abort + 120
6  swift                    0x00000001133e8f1c (anonymous namespace)::IRGenDebugInfoImpl::getOrCreateType(swift::irgen::DebugTypeInfo) (.cold.2) + 92
7  swift                    0x000000010fc042b3 (anonymous namespace)::IRGenDebugInfoImpl::getOrCreateType(swift::irgen::DebugTypeInfo) + 3667
8  swift                    0x000000010fbfe825 (anonymous namespace)::IRGenDebugInfoImpl::emitVariableDeclaration(swift::irgen::IRBuilder&, llvm::ArrayRef<llvm::Value*>, swift::irgen::DebugTypeInfo, swift::SILDebugScope const*, swift::ValueDecl*, llvm::StringRef, unsigned int, swift::irgen::IndirectionKind, swift::irgen::ArtificialKind) + 373
9  swift                    0x000000010fc2d640 swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 55248
10 swift                    0x000000010fc1cd43 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8051
11 swift                    0x000000010fb392ce swift::irgen::IRGenerator::emitGlobalTopLevel() + 734
12 swift                    0x000000010fbf7a32 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1282
13 swift                    0x000000010fbf7f22 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::GlobalVariable**) + 82
14 swift                    0x000000010faa62d7 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13943
15 swift                    0x000000010faa1d3a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3002
16 swift                    0x000000010fa4a908 main + 696
17 libdyld.dylib            0x00007fff678e1c49 start + 1

filed as https://bugs.swift.org/browse/SR-11125 .

weissi pushed a commit to weissi/swift-nio-ssl that referenced this issue Jul 16, 2019
Motivation:

If we don't import CNIOBoringSSL @_implementationOnly, then some details
of libssl's C structs might leak into NIOSSL's ABI which might lead to
clashes further down the line.

Modification:
- make all CNIOBoringSSL(Shims) imports @_implementationOnly
- remove all concrete libssl types from instance variables

Result:
- fixes apple#116
- works around SR-11125
weissi pushed a commit to weissi/swift-nio-ssl that referenced this issue Jul 17, 2019
Motivation:

If we don't import CNIOBoringSSL @_implementationOnly, then some details
of libssl's C structs might leak into NIOSSL's ABI which might lead to
clashes further down the line.

Modification:
- make all CNIOBoringSSL(Shims) imports @_implementationOnly
- remove all concrete libssl types from instance variables

Result:
- fixes apple#116
- works around SR-11125
Lukasa pushed a commit that referenced this issue Jul 17, 2019
Motivation:

If we don't import CNIOBoringSSL @_implementationOnly, then some details
of libssl's C structs might leak into NIOSSL's ABI which might lead to
clashes further down the line.

Modification:
- make all CNIOBoringSSL(Shims) imports @_implementationOnly
- remove all concrete libssl types from instance variables

Result:
- fixes #116
- works around SR-11125
@weissi
Copy link
Member

weissi commented Jul 24, 2019

@glaurent we released the workaround. Mind trying again?

@glaurent
Copy link
Author

@weissi I just did. I confirm that it works fine now, thanks a lot 👍

@weissi
Copy link
Member

weissi commented Jul 24, 2019

Amazing, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants