Skip to content

Commit

Permalink
Link CgRPC with openssl instead of BoringSSL under Linux.
Browse files Browse the repository at this point in the history
Under Linux, `libFoundation.so` already links with the system OpenSSL; so we need to use that one.
Using two `libssl`-style libraries in the same binary can cause all sorts of mayhem; see apple/swift-nio-ssl#16 (comment) for details.
  • Loading branch information
MrMage committed May 29, 2018
1 parent 53c32e4 commit d56e1ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
UNAME_S = $(shell uname -s)

CFLAGS = -Xcc -ISources/BoringSSL/include
ifeq ($(UNAME_S),Linux)
CFLAGS = -Xcc -DTSI_OPENSSL_ALPN_SUPPORT=0
else
CFLAGS = -Xcc -ISources/BoringSSL/include
endif

all:
swift build -v $(CFLAGS)
Expand Down
11 changes: 10 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/kylef/Commander.git", from: "0.8.0")
]

var cGRPCDependencies: [Target.Dependency] = []
#if os(Linux)
// On Linux, Foundation links with openssl, so we'll need to use that instead of BoringSSL.
// See https://github.com/apple/swift-nio-ssl/issues/16#issuecomment-392705505 for details.
dependencies.append(.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"))
#else
cGRPCDependencies.append("BoringSSL")
#endif

/*
* `swift-nio-zlib-support` uses `pkgConfig` to find `zlib` on
* non-Apple platforms. Details here:
Expand All @@ -45,7 +54,7 @@ let package = Package(
.target(name: "SwiftGRPC",
dependencies: ["CgRPC", "SwiftProtobuf"]),
.target(name: "CgRPC",
dependencies: ["BoringSSL"]),
dependencies: cGRPCDependencies),
.target(name: "RootsEncoder"),
.target(name: "protoc-gen-swiftgrpc",
dependencies: [
Expand Down

0 comments on commit d56e1ca

Please sign in to comment.