swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.49k stars 10.35k forks source link

[SR-12694] Swift does not link in the C++ standard library anymore #54925

Open swift-ci opened 4 years ago

swift-ci commented 4 years ago
Previous ID SR-12694
Radar rdar://problem/62894492
Original Reporter kencarroll (JIRA User)
Type Bug
Environment Linux Mint 19.1. Swift 5.2.1
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: f12fe375ba7b9ad5b139225df5684fb3

Issue Description:

Since moving to swift 5.2.1 my application no longer links. The following error is given (amongst) others:

error: undefined reference to 'std:: cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'.
dan-zheng commented 4 years ago

This issue seems unrelated to Swift for TensorFlow, so I'll move it to the Swift project (SR).

beccadax commented 4 years ago

@swift-ci create

beccadax commented 4 years ago

@gribozavr Any chance this might have something to do with C++ interop?

gribozavr commented 4 years ago

We haven't made any changes to the driver for the sake of C++ interop (yet).

The symbol mentioned in the error comes from libstdc+\. The Swift driver used to link in the default C+ standard library, but since https://github.com/apple/swift/pull/26110 it does not.

For C++ interop, we're trying to restore the old behavior in https://github.com/apple/swift/pull/30914, but it will be a while until it lands, and the current plan is to only link in the C++ standard library when C++ interop is enabled.

cc @compnerd

compnerd commented 4 years ago

If your application is using `{{C+`}}, you should explicitly link against the `{{C`}} runtime (and any supporting libraries that it may required such as the ABI library). Although, I do understand how you are adding C dependencies into Swift code currently.