Skip to content

Commit e4315e0

Browse files
authored
Merge pull request #68239 from compnerd/the-binding-is-fragile-5.9.0
Build the fragile swiftCxx statically on all platforms
2 parents 404a69d + 84a9733 commit e4315e0

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

lib/IRGen/GenDecl.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,15 @@ void IRGenModule::emitSourceFile(SourceFile &SF) {
487487
this->addLinkLibrary(LinkLibrary("stdc++", LibraryKind::Library));
488488

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

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

stdlib/public/Cxx/CMakeLists.txt

+1-6
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
9+
add_swift_target_library(swiftCxx STATIC NO_LINK_NAME IS_STDLIB IS_SWIFT_ONLY
1510
CxxConvertibleToCollection.swift
1611
CxxDictionary.swift
1712
CxxPair.swift

test/Interop/Cxx/class/constructors-copy-irgen-macosx.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Target-specific tests for C++ copy constructor code generation.
22

3-
// RUN: %swift -module-name MySwift -target x86_64-apple-macosx10.9 -dump-clang-diagnostics -I %S/Inputs -enable-experimental-cxx-interop -emit-ir %s -parse-stdlib -parse-as-library -disable-legacy-type-info -Xcc -fignore-exceptions | %FileCheck %s -check-prefix=ITANIUM_X64
3+
// RUN: %swift -module-name MySwift -target x86_64-apple-macosx10.13 -dump-clang-diagnostics -I %S/Inputs -enable-experimental-cxx-interop -emit-ir %s -parse-stdlib -parse-as-library -disable-legacy-type-info -Xcc -fignore-exceptions | %FileCheck %s -check-prefix=ITANIUM_X64
44

55
// REQUIRES: OS=macosx
66
// REQUIRES: CPU=x86_64

test/Interop/Cxx/class/constructors-irgen-macosx.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Target-specific tests for C++ constructor call code generation.
22

3-
// RUN: %swift -module-name MySwift -target x86_64-apple-macosx10.9 -dump-clang-diagnostics -I %S/Inputs -enable-experimental-cxx-interop -emit-ir %s -parse-stdlib -parse-as-library -disable-legacy-type-info -Xcc -fignore-exceptions | %FileCheck %s -check-prefix=ITANIUM_X64
3+
// RUN: %swift -module-name MySwift -target x86_64-apple-macosx10.13 -dump-clang-diagnostics -I %S/Inputs -enable-experimental-cxx-interop -emit-ir %s -parse-stdlib -parse-as-library -disable-legacy-type-info -Xcc -fignore-exceptions | %FileCheck %s -check-prefix=ITANIUM_X64
44

55
// REQUIRES: OS=macosx
66
// REQUIRES: CPU=x86_64

validation-test/SIL/verify_all_overlays.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
continue
2929
# Skip the C++ standard library overlay because it's not yet shipped
3030
# in any released SDK.
31-
if module_name == "CxxStdlib":
31+
if module_name in ("Cxx", "CxxStdlib"):
3232
continue
3333
# TODO(TF-1229): Fix the "_Differentiation" module.
3434
if module_name == "_Differentiation":

0 commit comments

Comments
 (0)