Skip to content

Commit 4eb52e7

Browse files
committed
Cxx: build Cxx module statically on all platforms
This adjusts Cxx to be built statically on all platforms including Windows. The static library support is sufficient to support this module linking statically on Windows.
1 parent 9268736 commit 4eb52e7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,13 @@ void IRGenModule::emitSourceFile(SourceFile &SF) {
488488
this->addLinkLibrary(LinkLibrary("stdc++", LibraryKind::Library));
489489

490490
// Do not try to link Cxx with itself.
491-
if (!getSwiftModule()->getName().is("Cxx"))
492-
this->addLinkLibrary(LinkLibrary("swiftCxx", LibraryKind::Library));
491+
if (!getSwiftModule()->getName().is("Cxx")) {
492+
bool isStatic = Context.getModuleByName("Cxx")->isStaticLibrary();
493+
this->addLinkLibrary(LinkLibrary(target.isOSWindows() && isStatic
494+
? "libswiftCxx"
495+
: "swiftCxx",
496+
LibraryKind::Library));
497+
}
493498

494499
// Do not try to link CxxStdlib with the C++ standard library, Cxx or
495500
// itself.

stdlib/public/Cxx/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../cmake/modules)
22
include(StdlibOptions)
33

4-
set(SWIFT_CXX_LIBRARY_KIND STATIC)
5-
if("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WINDOWS")
6-
set(SWIFT_CXX_LIBRARY_KIND SHARED)
7-
endif()
8-
94
set(SWIFT_CXX_DEPS symlink_clang_headers)
105
if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
116
list(APPEND SWIFT_CXX_DEPS copy-legacy-layouts)
127
endif()
138

14-
add_swift_target_library(swiftCxx ${SWIFT_CXX_LIBRARY_KIND} NO_LINK_NAME IS_STDLIB IS_SWIFT_ONLY IS_FRAGILE
9+
add_swift_target_library(swiftCxx STATIC NO_LINK_NAME IS_STDLIB IS_SWIFT_ONLY IS_FRAGILE
1510
CxxConvertibleToCollection.swift
1611
CxxDictionary.swift
1712
CxxPair.swift

0 commit comments

Comments
 (0)