Skip to content

Commit 57ae206

Browse files
committed
[cxx-interop] Link against -lc++ on Darwin and -lstdc++ on Linux.
1 parent bb00e8d commit 57ae206

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,14 @@ void IRGenModule::emitSourceFile(SourceFile &SF) {
469469
if (ObjCInterop)
470470
this->addLinkLibrary(LinkLibrary("objc", LibraryKind::Library));
471471

472-
// Automatically with libc++ when possible.
473-
if (Context.LangOpts.EnableCXXInterop && Context.LangOpts.Target.isOSDarwin())
474-
this->addLinkLibrary(LinkLibrary("c++", LibraryKind::Library));
475-
472+
// If C++ interop is enabled, add -lc++ on Darwin and -lstdc++ on linux.
473+
if (Context.LangOpts.EnableCXXInterop) {
474+
if (Context.LangOpts.Target.isOSDarwin())
475+
this->addLinkLibrary(LinkLibrary("c++", LibraryKind::Library));
476+
else if (Context.LangOpts.Target.isOSLinux())
477+
this->addLinkLibrary(LinkLibrary("stdc++", LibraryKind::Library));
478+
}
479+
476480
// FIXME: It'd be better to have the driver invocation or build system that
477481
// executes the linker introduce these compatibility libraries, since at
478482
// that point we know whether we're building an executable, which is the only

0 commit comments

Comments
 (0)