Skip to content

Commit 7f3fdb3

Browse files
authored
Merge pull request #82355 from etcwilde/ewilde/fbsd-cxx-interop-runtime
FreeBSD: Link C++ runtimes when Cxx interop is enabled
2 parents 25585c0 + 3a48d6e commit 7f3fdb3

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

lib/AST/ModuleDependencies.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,8 @@ void swift::dependencies::registerCxxInteropLibraries(
585585
return mainModuleName == Name;
586586
})) {
587587
// Only link with CxxStdlib on platforms where the overlay is available.
588-
if (Target.isOSDarwin() || Target.isOSLinux() || Target.isOSWindows())
588+
if (Target.isOSDarwin() || Target.isOSLinux() || Target.isOSWindows() ||
589+
Target.isOSFreeBSD())
589590
RegistrationCallback(LinkLibrary{"swiftCxxStdlib", LibraryKind::Library,
590591
hasStaticCxxStdlib});
591592
}

lib/Driver/ToolChains.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,9 +1650,10 @@ const char *ToolChain::getClangLinkerDriver(
16501650
// a C++ standard library if it's not needed, in particular because the
16511651
// standard library that `clang++` selects by default may not be the one that
16521652
// is desired.
1653-
const char *LinkerDriver =
1654-
Args.hasArg(options::OPT_enable_experimental_cxx_interop) ? "clang++"
1655-
: "clang";
1653+
bool useCxxLinker = Args.hasArg(options::OPT_enable_experimental_cxx_interop);
1654+
if (Arg *arg = Args.getLastArg(options::OPT_cxx_interoperability_mode))
1655+
useCxxLinker |= StringRef(arg->getValue()) != "off";
1656+
const char *LinkerDriver = useCxxLinker ? "clang++" : "clang";
16561657
if (const Arg *A = Args.getLastArg(options::OPT_tools_directory)) {
16571658
StringRef toolchainPath(A->getValue());
16581659

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ void CompilerInvocation::computeCXXStdlibOptions() {
391391
// (see https://reviews.llvm.org/D101479).
392392
LangOpts.CXXStdlib = CXXStdlibKind::Msvcprt;
393393
LangOpts.PlatformDefaultCXXStdlib = CXXStdlibKind::Msvcprt;
394-
} else if (LangOpts.Target.isOSLinux() || LangOpts.Target.isOSDarwin()) {
394+
} else if (LangOpts.Target.isOSLinux() || LangOpts.Target.isOSDarwin() ||
395+
LangOpts.Target.isOSFreeBSD()) {
395396
auto [clangDriver, clangDiagEngine] =
396397
ClangImporter::createClangDriver(LangOpts, ClangImporterOpts);
397398
auto clangDriverArgs = ClangImporter::createClangArgs(

test/Interop/Cxx/stdlib/avoid-import-cxx-math.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %target-swift-frontend %s -typecheck -verify -cxx-interoperability-mode=swift-6
33
// RUN: %target-swift-frontend %s -typecheck -verify -cxx-interoperability-mode=upcoming-swift
44

5-
// REQUIRES: OS=macosx || OS=linux-gnu
5+
// REQUIRES: OS=macosx || OS=linux-gnu || OS=freebsd
66

77
import CxxStdlib
88

test/Interop/Cxx/stdlib/overlay/custom-sequence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22
//
33
// REQUIRES: executable_test
4-
// REQUIRES: OS=macosx || OS=linux-gnu
4+
// REQUIRES: OS=macosx || OS=linux-gnu || OS=freebsd
55

66
// REQUIRES: rdar102364960
77

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
// REQUIRES: executable_test
1313
//
14-
// REQUIRES: OS=macosx || OS=linux-gnu
14+
// REQUIRES: OS=macosx || OS=linux-gnu || OS=freebsd
1515

1616
import StdlibUnittest
1717
#if !BRIDGING_HEADER

0 commit comments

Comments
 (0)