swift-nio-sslがビルドできない
omochi opened this issue · comments
scipio create
コマンドを swift-nio-ssl
に対して使用したところ、ビルドエラーが発生しました。
オプションとしては --disable-library-evolution
と --static
を使用しています。
xcodeは Xcode15 beta5 を使用しています。
scipioは xcode-beta3
ブランチを使用しています。
swift-nio-sslは最新のコミットです。
commit 678b6412f590a8f902ab1dacba0a78c45eade335 (HEAD -> main, origin/main, origin/HEAD)
Author: Felix Schlegel <fefefe152@gmail.com>
Date: Mon Jun 26 14:36:35 2023 +0100
以下にログを貼ります。
GitHubのissueの文字数制限を超えたので、途中の警告出力をカットしました。
[omochi@omochi-iMacPro swift-nio-ssl (main =)]$ scipio create --platforms macOS --disable-library-evolution --static
🔁 Resolving Dependencies...
📦 Building CNIODarwin for macOS
🚀 Combining into XCFramework...
📦 Building NIO for macOS
🚀 Combining into XCFramework...
📦 Building Atomics for macOS
🚀 Combining into XCFramework...
📦 Building NIOFoundationCompat for macOS
🚀 Combining into XCFramework...
📦 Building CNIOAtomics for macOS
🚀 Combining into XCFramework...
📦 Building CNIOWindows for macOS
🚀 Combining into XCFramework...
📦 Building NIOHTTP1 for macOS
🚀 Combining into XCFramework...
📦 Building NIOEmbedded for macOS
🚀 Combining into XCFramework...
📦 Building NIOTLS for macOS
🚀 Combining into XCFramework...
📦 Building _NIODataStructures for macOS
🚀 Combining into XCFramework...
📦 Building NIOSSL for macOS
Unable to build for macOS
⚠️ Execution was terminated:
Building targets in dependency order
Target dependency graph (23 targets)
Build description signature: bd1b31e7e9f71a86bbbf02a15a5e358e
Build description path: /Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData/Intermediates.noindex/XCBuildData/bd1b31e7e9f71a86bbbf02a15a5e358e.xcbuilddata
DEFINES_MODULE was set, but no umbrella header could be found to generate the module map
DEFINES_MODULE was set, but no umbrella header could be found to generate the module map
(大量の警告を省略、以下がエラー部分でした)
cannot find 'ssl_private_key_failure' in scope
cannot find 'ssl_private_key_retry' in scope
cannot find 'ssl_private_key_retry' in scope
cannot find 'ssl_private_key_retry' in scope
cannot find 'ssl_private_key_failure' in scope
cannot find 'ssl_private_key_failure' in scope
cannot find 'ssl_private_key_success' in scope
cannot find 'ssl_private_key_success' in scope
cannot find 'ssl_verify_ok' in scope
cannot find 'ssl_verify_invalid' in scope
cannot find 'ssl_verify_retry' in scope
cannot find 'ssl_verify_retry' in scope
cannot find 'ssl_renegotiate_never' in scope
cannot find 'ssl_renegotiate_once' in scope
cannot find 'ssl_renegotiate_freely' in scope
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:145:20: error: cannot find 'ssl_private_key_failure' in scope
return ssl_private_key_failure
^~~~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:158:16: error: cannot find 'ssl_private_key_retry' in scope
return ssl_private_key_retry
^~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:180:16: error: cannot find 'ssl_private_key_retry' in scope
return ssl_private_key_retry
^~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:186:20: error: cannot find 'ssl_private_key_retry' in scope
return ssl_private_key_retry
^~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:188:20: error: cannot find 'ssl_private_key_failure' in scope
return ssl_private_key_failure
^~~~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:191:24: error: cannot find 'ssl_private_key_failure' in scope
return ssl_private_key_failure
^~~~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:196:20: error: cannot find 'ssl_private_key_success' in scope
return ssl_private_key_success
^~~~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:270:18: error: cannot find 'ssl_private_key_success' in scope
if result != ssl_private_key_success {
^~~~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLCallbacks.swift:236:20: error: cannot find 'ssl_verify_ok' in scope
return ssl_verify_ok
^~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLCallbacks.swift:238:20: error: cannot find 'ssl_verify_invalid' in scope
return ssl_verify_invalid
^~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLCallbacks.swift:241:20: error: cannot find 'ssl_verify_retry' in scope
return ssl_verify_retry
^~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLCallbacks.swift:274:16: error: cannot find 'ssl_verify_retry' in scope
return ssl_verify_retry
^~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLConnection.swift:183:25: error: cannot find 'ssl_renegotiate_never' in scope
baseState = ssl_renegotiate_never
^~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLConnection.swift:185:25: error: cannot find 'ssl_renegotiate_once' in scope
baseState = ssl_renegotiate_once
^~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLConnection.swift:187:25: error: cannot find 'ssl_renegotiate_freely' in scope
baseState = ssl_renegotiate_freely
^~~~~~~~~~~~~~~~~~~~~~
cannot find 'ssl_private_key_failure' in scope
cannot find 'ssl_private_key_retry' in scope
cannot find 'ssl_private_key_retry' in scope
cannot find 'ssl_private_key_retry' in scope
cannot find 'ssl_private_key_failure' in scope
cannot find 'ssl_private_key_failure' in scope
cannot find 'ssl_private_key_success' in scope
cannot find 'ssl_private_key_success' in scope
cannot find 'ssl_verify_ok' in scope
cannot find 'ssl_verify_invalid' in scope
cannot find 'ssl_verify_retry' in scope
cannot find 'ssl_verify_retry' in scope
cannot find 'ssl_renegotiate_never' in scope
cannot find 'ssl_renegotiate_once' in scope
cannot find 'ssl_renegotiate_freely' in scope
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:145:20: error: cannot find 'ssl_private_key_failure' in scope
return ssl_private_key_failure
^~~~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:158:16: error: cannot find 'ssl_private_key_retry' in scope
return ssl_private_key_retry
^~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:180:16: error: cannot find 'ssl_private_key_retry' in scope
return ssl_private_key_retry
^~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:186:20: error: cannot find 'ssl_private_key_retry' in scope
return ssl_private_key_retry
^~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:188:20: error: cannot find 'ssl_private_key_failure' in scope
return ssl_private_key_failure
^~~~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:191:24: error: cannot find 'ssl_private_key_failure' in scope
return ssl_private_key_failure
^~~~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:196:20: error: cannot find 'ssl_private_key_success' in scope
return ssl_private_key_success
^~~~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/CustomPrivateKey.swift:270:18: error: cannot find 'ssl_private_key_success' in scope
if result != ssl_private_key_success {
^~~~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLCallbacks.swift:236:20: error: cannot find 'ssl_verify_ok' in scope
return ssl_verify_ok
^~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLCallbacks.swift:238:20: error: cannot find 'ssl_verify_invalid' in scope
return ssl_verify_invalid
^~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLCallbacks.swift:241:20: error: cannot find 'ssl_verify_retry' in scope
return ssl_verify_retry
^~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLCallbacks.swift:274:16: error: cannot find 'ssl_verify_retry' in scope
return ssl_verify_retry
^~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLConnection.swift:183:25: error: cannot find 'ssl_renegotiate_never' in scope
baseState = ssl_renegotiate_never
^~~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLConnection.swift:185:25: error: cannot find 'ssl_renegotiate_once' in scope
baseState = ssl_renegotiate_once
^~~~~~~~~~~~~~~~~~~~
/Users/omochi/github/apple/swift-nio-ssl/Sources/NIOSSL/SSLConnection.swift:187:25: error: cannot find 'ssl_renegotiate_freely' in scope
baseState = ssl_renegotiate_freely
^~~~~~~~~~~~~~~~~~~~~~
🚀 Combining into XCFramework...
Something went wrong during building
Please execute with --verbose option.
Execution was terminated:
error: unable to read the file at '/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData/Products/Release/PackageFrameworks/NIOSSL.framework/NIOSSL'
Error: Execution was terminated:
error: unable to read the file at '/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData/Products/Release/PackageFrameworks/NIOSSL.framework/NIOSSL'
NIOSSL
のビルド時に、 CNIOBoringSSL
から提供されるシンボルが見えてないようです。
CNIOBoringSSL.xcframework
は問題なくビルドできているように見えるし、
内部の Headers
ディレクトリにも各種ヘッダーファイルが取り込まれていて、ちゃんとできてそうなので、不思議です。
エラーメッセージに出てきた xcbuilddata
の中の build-request.json
を見る限り、
FRAMEWORK_SEARCH_PATHS
から、すでにビルドされた CNIOBoringSSL.framework
を参照できそうで、
それには module.modulemap
も含まれているので、なぜシンボルが見えないのか不思議です。
$(BUILT_PRODUCTS_DIR)
の値が想定と違う可能性が考えられますが、
ビルド時変数を見る方法はあるのでしょうか・・・?
{
"buildCommand" : {
"command" : "build",
"skipDependencies" : false,
"style" : "buildOnly"
},
"configuredTargets" : [
{
"guid" : "PACKAGE-TARGET:NIOSSL@11",
"parameters" : {
"action" : "build",
"activeRunDestination" : {
"disableOnlyActiveArch" : true,
"platform" : "macosx",
"sdk" : "macosx",
"supportedArchitectures" : [
],
"targetArchitecture" : "arm64"
},
"arenaInfo" : {
"buildIntermediatesPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData/Intermediates.noindex",
"buildProductsPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData/Products",
"derivedDataPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData",
"indexDataStoreFolderPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData",
"indexEnableDataStore" : false,
"indexPCHPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData",
"pchPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData"
},
"configurationName" : "Release",
"overrides" : {
"synthesized" : {
"table" : {
"CC" : "/Applications/Xcode15-beta.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang",
"FRAMEWORK_SEARCH_PATHS" : "$(inherited) $(BUILT_PRODUCTS_DIR)/PackageFrameworks",
"LIBRARY_SEARCH_PATHS" : "$(inherited) /Applications/Xcode15-beta.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib",
"OTHER_CFLAGS" : "$(inherited) -isysroot /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -F /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks",
"OTHER_CPLUSPLUSFLAGS" : "$(inherited)",
"OTHER_LDFLAGS" : "$(inherited)",
"OTHER_SWIFT_FLAGS" : "$(inherited) -sdk /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -F /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -I /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -L /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib",
"SWIFT_EXEC" : "/Applications/Xcode15-beta.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc"
}
}
}
}
}
],
"continueBuildingAfterErrors" : false,
"enableIndexBuildArena" : false,
"hideShellScriptEnvironment" : true,
"parameters" : {
"action" : "build",
"activeRunDestination" : {
"disableOnlyActiveArch" : true,
"platform" : "macosx",
"sdk" : "macosx",
"supportedArchitectures" : [
],
"targetArchitecture" : "arm64"
},
"arenaInfo" : {
"buildIntermediatesPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData/Intermediates.noindex",
"buildProductsPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData/Products",
"derivedDataPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData",
"indexDataStoreFolderPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData",
"indexEnableDataStore" : false,
"indexPCHPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData",
"pchPath" : "/Users/omochi/github/apple/swift-nio-ssl/.build/scipio/DerivedData"
},
"configurationName" : "Release",
"overrides" : {
"synthesized" : {
"table" : {
"CC" : "/Applications/Xcode15-beta.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang",
"FRAMEWORK_SEARCH_PATHS" : "$(inherited) $(BUILT_PRODUCTS_DIR)/PackageFrameworks",
"LIBRARY_SEARCH_PATHS" : "$(inherited) /Applications/Xcode15-beta.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib",
"OTHER_CFLAGS" : "$(inherited) -isysroot /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -F /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks",
"OTHER_CPLUSPLUSFLAGS" : "$(inherited)",
"OTHER_LDFLAGS" : "$(inherited)",
"OTHER_SWIFT_FLAGS" : "$(inherited) -sdk /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -F /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -I /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -L /Applications/Xcode15-beta.5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib",
"SWIFT_EXEC" : "/Applications/Xcode15-beta.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc"
}
}
}
},
"schemeCommand" : "launch",
"showNonLoggedProgress" : true,
"useDryRun" : false,
"useImplicitDependencies" : false,
"useLegacyBuildLocations" : false,
"useParallelTargets" : true
}
この問題は実は私と @freddi-kit も取り組んでいて困っています。
仰るとおり、Cからbindingしたprimitiveなenumがちゃんとシンボルとして認識されておらず悩んでおります・・・・・・。
今度再調査して共有します。
そうなんですね。
$ swift build --build-system xcode
を実行して、
SwiftPMが作るPIFと見比べてみたのですが、
これは .o
と DEFINES_MODULE
の構成でした。
一方Scipioは .framework
で、ヘッダファイルのリストなども構築されていたので、
Scipio固有の動作の影響が大きい部分のようでした。
PIFのJSONを見ながらxcodeprojの場合のGUIを想像して考えていますが、
ただのJSONなので見通しが悪くて難しいです。。
Cからbindingしたprimitiveなenum
エラーがたくさん出るのですべてのシンボルが見えていないのかと思っていましたが、
enum ssl_private_key_result_t { ... }
形式で宣言されたシンボル特有の問題なんですね。
とすると、サーチパス等は正しく設定できているんですね。
Vaporフレームワークが事前ビルドできると、
サーバサイドSwift開発でとても役に立ちそうなので、
(Vaporの依存先の一つである)swift-nio-sslがビルドできるようになると嬉しいです。
Vaporは依存先も含めるととてもコード量が多くて、
フルビルドに結構時間がかかってしまうのです。
たしかに SSLConnection.swift
で CNIOBoringSSL_SSL_free
などを呼び出していますが、ここについてはエラーが出ていないですね。enum
だけが見えていない・・・
CNIOBoringSSL.h
は C と C++ のクロス言語対応で書かれていて、
通常ビルドするときはC++言語モードとして読み込まれているようです。
これがC言語モードになってしまっていて、それでうまくいかないとか・・・?
XCFrameworks
に生成された CNIOBoringSSL.xcframework
の中から CNIOBoringSSL.framework
を取り出して、
macOSのプロジェクトに突っ込んで、 import CNIOBoringSSL
からXcodeでジャンプしてみたところ、
ちゃんとimportされた ssl_private_key_result_t
が見えていました。
なので、少なくとも生成されたframeworkについては問題無さそうです。
PIF内部において、
NIOSSLターゲットから依存先としてCNIOBoringSSL frameworkターゲットに依存している場合の問題のようです。
原因はわかって対応を実装したのですが、
実装の別の問題(?)との兼ね合いで、ビルド成功するかどうかが運次第になってしまったので、
これを安定させるための改修をしています。
ビルドできるようになった
テストもつけた