Files
swift-mirror/include/swift/Basic/CXXStdlibKind.h
Egor Zhdan 059f0f97d1 [cxx-interop] Allow compiling with libc++ on Linux
This makes sure that Swift respects `-Xcc -stdlib=libc++` flags.

Clang already has existing logic to discover the system-wide libc++ installation on Linux. We rely on that logic here.

Importing a Swift module that was built with a different C++ stdlib is not supported and emits an error.

The Cxx module can be imported when compiling with any C++ stdlib. The synthesized conformances, e.g. to CxxRandomAccessCollection also work. However, CxxStdlib currently cannot be imported when compiling with libc++, since on Linux it refers to symbols from libstdc++ which have different mangled names in libc++.

rdar://118357548 / https://github.com/swiftlang/swift/issues/69825
2024-08-08 16:24:58 +01:00

49 lines
1.4 KiB
C++

//===--- CXXStdlibKind.h ----------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_BASIC_CXX_STDLIB_KIND_H
#define SWIFT_BASIC_CXX_STDLIB_KIND_H
namespace swift {
enum class CXXStdlibKind : uint8_t {
Unknown = 0,
/// libc++ is the default C++ stdlib on Darwin platforms. It is also supported
/// on Linux when explicitly requested via `-Xcc -stdlib=libc++` flag.
Libcxx = 1,
/// libstdc++ is the default C++ stdlib on most Linux distributions.
Libstdcxx = 2,
/// msvcprt is used when targeting Windows.
Msvcprt = 3,
};
inline std::string to_string(CXXStdlibKind kind) {
switch (kind) {
case CXXStdlibKind::Unknown:
return "unknown C++ stdlib";
case CXXStdlibKind::Libcxx:
return "libc++";
case CXXStdlibKind::Libstdcxx:
return "libstdc++";
case CXXStdlibKind::Msvcprt:
return "msvcprt";
}
llvm_unreachable("unhandled CXXStdlibKind");
}
} // namespace swift
#endif // SWIFT_BASIC_CXX_STDLIB_KIND_H