diff --git a/lib/AST/ModuleDependencies.cpp b/lib/AST/ModuleDependencies.cpp index dbd5e44c65ffb..6d5746e74bcf6 100644 --- a/lib/AST/ModuleDependencies.cpp +++ b/lib/AST/ModuleDependencies.cpp @@ -573,7 +573,8 @@ void swift::dependencies::registerCxxInteropLibraries( return mainModuleName == Name; })) { // Only link with CxxStdlib on platforms where the overlay is available. - if (Target.isOSDarwin() || Target.isOSLinux() || Target.isOSWindows()) + if (Target.isOSDarwin() || Target.isOSLinux() || Target.isOSWindows() || + Target.isOSFreeBSD()) RegistrationCallback(LinkLibrary{"swiftCxxStdlib", LibraryKind::Library, hasStaticCxxStdlib}); } diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index e7f6fb8a48bca..69fbf27ce16e6 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1656,9 +1656,10 @@ const char *ToolChain::getClangLinkerDriver( // a C++ standard library if it's not needed, in particular because the // standard library that `clang++` selects by default may not be the one that // is desired. - const char *LinkerDriver = - Args.hasArg(options::OPT_enable_experimental_cxx_interop) ? "clang++" - : "clang"; + bool useCxxLinker = Args.hasArg(options::OPT_enable_experimental_cxx_interop); + if (Arg *arg = Args.getLastArg(options::OPT_cxx_interoperability_mode)) + useCxxLinker |= StringRef(arg->getValue()) != "off"; + const char *LinkerDriver = useCxxLinker ? "clang++" : "clang"; if (const Arg *A = Args.getLastArg(options::OPT_tools_directory)) { StringRef toolchainPath(A->getValue()); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index ad9e5587e2584..29483feea4881 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -391,7 +391,8 @@ void CompilerInvocation::computeCXXStdlibOptions() { // (see https://reviews.llvm.org/D101479). LangOpts.CXXStdlib = CXXStdlibKind::Msvcprt; LangOpts.PlatformDefaultCXXStdlib = CXXStdlibKind::Msvcprt; - } else if (LangOpts.Target.isOSLinux() || LangOpts.Target.isOSDarwin()) { + } else if (LangOpts.Target.isOSLinux() || LangOpts.Target.isOSDarwin() || + LangOpts.Target.isOSFreeBSD()) { auto [clangDriver, clangDiagEngine] = ClangImporter::createClangDriver(LangOpts, ClangImporterOpts); auto clangDriverArgs = ClangImporter::createClangArgs( diff --git a/test/Interop/Cxx/stdlib/avoid-import-cxx-math.swift b/test/Interop/Cxx/stdlib/avoid-import-cxx-math.swift index 325640ee20bcb..c13588aa98ce2 100644 --- a/test/Interop/Cxx/stdlib/avoid-import-cxx-math.swift +++ b/test/Interop/Cxx/stdlib/avoid-import-cxx-math.swift @@ -2,7 +2,7 @@ // RUN: %target-swift-frontend %s -typecheck -verify -cxx-interoperability-mode=swift-6 // RUN: %target-swift-frontend %s -typecheck -verify -cxx-interoperability-mode=upcoming-swift -// REQUIRES: OS=macosx || OS=linux-gnu +// REQUIRES: OS=macosx || OS=linux-gnu || OS=freebsd import CxxStdlib diff --git a/test/Interop/Cxx/stdlib/overlay/custom-sequence.swift b/test/Interop/Cxx/stdlib/overlay/custom-sequence.swift index 7f6ca4e0b6315..b9e2572845c7c 100644 --- a/test/Interop/Cxx/stdlib/overlay/custom-sequence.swift +++ b/test/Interop/Cxx/stdlib/overlay/custom-sequence.swift @@ -1,7 +1,7 @@ // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop) // // REQUIRES: executable_test -// REQUIRES: OS=macosx || OS=linux-gnu +// REQUIRES: OS=macosx || OS=linux-gnu || OS=freebsd // REQUIRES: rdar102364960 diff --git a/test/Interop/Cxx/stdlib/use-std-map.swift b/test/Interop/Cxx/stdlib/use-std-map.swift index ba933d89339e4..99320a109f53f 100644 --- a/test/Interop/Cxx/stdlib/use-std-map.swift +++ b/test/Interop/Cxx/stdlib/use-std-map.swift @@ -11,7 +11,7 @@ // REQUIRES: executable_test // -// REQUIRES: OS=macosx || OS=linux-gnu +// REQUIRES: OS=macosx || OS=linux-gnu || OS=freebsd import StdlibUnittest #if !BRIDGING_HEADER