Skip to content

Commit ba44bfe

Browse files
committed
[cxx-interop] Add -lc++ when C++ interop is enabled on Darwin.
1 parent 323e2b1 commit ba44bfe

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,10 @@ void IRGenModule::emitSourceFile(SourceFile &SF) {
468468

469469
if (ObjCInterop)
470470
this->addLinkLibrary(LinkLibrary("objc", LibraryKind::Library));
471+
472+
// Automatically with libc++ when possible.
473+
if (Context.LangOpts.EnableCXXInterop && Context.LangOpts.Target.isOSDarwin())
474+
this->addLinkLibrary(LinkLibrary("c++", LibraryKind::Library));
471475

472476
// FIXME: It'd be better to have the driver invocation or build system that
473477
// executes the linker introduce these compatibility libraries, since at

test/Interop/Cxx/stdlib/use-std-vector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop -lc++)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop)
22
//
33
// REQUIRES: executable_test
44
//

0 commit comments

Comments
 (0)