@@ -680,7 +680,8 @@ static void diagnoseCxxInteropCompatMode(Arg *verArg, ArgList &Args,
680680}
681681
682682void LangOptions::setCxxInteropFromArgs (ArgList &Args,
683- swift::DiagnosticEngine &Diags) {
683+ swift::DiagnosticEngine &Diags,
684+ const FrontendOptions &FrontendOpts) {
684685 if (Arg *A = Args.getLastArg (options::OPT_cxx_interoperability_mode)) {
685686 if (Args.hasArg (options::OPT_enable_experimental_cxx_interop)) {
686687 Diags.diagnose (SourceLoc (), diag::dont_enable_interop_and_compat);
@@ -735,7 +736,12 @@ void LangOptions::setCxxInteropFromArgs(ArgList &Args,
735736 // version, and is either 4, 5, 6, or 7 (even though only 5.9 and 6.* make
736737 // any sense). For now, we don't actually care about the version, so we'll
737738 // just use version 6 (i.e., 'swift-6') to mean that C++ interop mode is on.
738- if (EnableCXXInterop)
739+ //
740+ // FIXME: We always declare the 'Darwin' module as formally having been built
741+ // without C++Interop, for compatibility with prior versions. Once we are certain
742+ // that we are only building against modules built with support of
743+ // '-formal-cxx-interoperability-mode', this hard-coded check should be removed.
744+ if (EnableCXXInterop && (FrontendOpts.ModuleName .compare (" Darwin" ) != 0 ))
739745 FormalCxxInteropMode = {6 };
740746 else
741747 FormalCxxInteropMode = std::nullopt ;
@@ -1558,7 +1564,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
15581564 if (const Arg *A = Args.getLastArg (OPT_clang_target_variant))
15591565 Opts.ClangTargetVariant = llvm::Triple (A->getValue ());
15601566
1561- Opts.setCxxInteropFromArgs (Args, Diags);
1567+ Opts.setCxxInteropFromArgs (Args, Diags, FrontendOpts );
15621568 if (!Args.hasArg (options::OPT_formal_cxx_interoperability_mode))
15631569 ModuleInterfaceOpts.PublicFlags .IgnorableFlags +=
15641570 " " + printFormalCxxInteropVersion (Opts);
0 commit comments