Skip to content

Adding import CxxStdlib makes diagnostic about not enabling C++ interoperability harder to understand #83148

@maddyadams

Description

@maddyadams

Description

If module A enables Swift-Cxx interoperability, module B does not enable Swift-Cxx interoperability, and B imports A, then the compiler emits the error message:
Module 'A' was built with C++ interoperability enabled, but current compilation does not enable C++ interoperability.

But, if A imports CxxStdlib, the error message becomes harder to understand and resolve:
<unknown>:0: error: cannot load underlying module for 'CxxStdlib'

Reproduction

// A.swift, Swift-Cxx interop enabled
import Foundation
import CxxStdlib

// B.swift, Swift-Cxx interop disabled
import A

Expected behavior

I expected that the compiler would emit the error Module 'A' was built with C++ interoperability enabled, but current compilation does not enable C++ interoperability

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0

Additional information

rdar://139033386

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions