swift run --reps crashes with C/C++ dependencies

Number:rdar://FB7654249 Date Originated:06.04.2020
Status:Open Resolved:
Product:Swift Compiler Product Version:5.2
Classification:Crash Reproducible:Always
The swift compiler with versions 5.2, 5.1.3 crashes if you run any project containing C/C++ dependencies with --repl attribute. This behavior appears on macOS only. On Ubuntu 18 same packages works well with the `swift run --repl`. The crash appears on import Swift Package that contains the C/C++ dependencies into repl.

The `swift test` command within the same setup works properly.
The same project, but as executable (e.g. MyLibrary.swift renamed to main.swift) works properly with `swift run` command.

Steps to reproduce:
1. `swift package init --type library MyLibrary`.
2.1 Add the following dependency to the package dependencies: `.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.0.0")`.
2.2 Add follow dependency to MyLibrary target dependencies: `.product(name: "AsyncHTTPClient", package: "async-http-client"),`.
3. Run `swift run --repl`.
4. In swift console console type: `import MyLibrary`.

Expected behavior:
Package loads and its public types and methods are available within repl runtime.

Current behavior:
Repl crashes with the following stacktrace:
warning: Swift error in fallback scratch context: <module-includes>:1:9: note: in file included from <module-includes>:1:
#import "./.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h"

error: ./.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSLShims/include/CNIOBoringSSLShims.h:22:10: error: 'CNIOBoringSSL.h' file not found
#include "CNIOBoringSSL.h"

error: could not build Objective-C module 'CNIOBoringSSLShims'

note: This error message is displayed only once. If the error displayed above is due to conflicting search paths to Clang modules in different images of the debugged executable, this can slow down debugging of Swift code significantly, since a fresh Swift context has to be created every time a conflict is encountered.

0  lldb                     0x0000000103a43f08 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  lldb                     0x0000000103a434c5 llvm::sys::RunSignalHandlers() + 85
2  lldb                     0x0000000103a44550 SignalHandler(int) + 272
3  libsystem_platform.dylib 0x00007fff7218f5fd _sigtramp + 29
4  libsystem_platform.dylib 0x000070000baca650 _sigtramp + 2576593008
5  LLDB                     0x0000000103caa957 lldb_private::IOHandlerEditline::Run() + 375
6  LLDB                     0x0000000103c92b89 lldb_private::Debugger::ExecuteIOHandlers() + 105
7  LLDB                     0x0000000103c95463 lldb_private::Debugger::IOHandlerThread(void*) + 19
8  LLDB                     0x0000000103d3c547 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 103
9  libsystem_pthread.dylib  0x00007fff7219b109 _pthread_start + 148
10 libsystem_pthread.dylib  0x00007fff72196b8b thread_start + 15
[1]    7804 segmentation fault  swift run --repl


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!