Skip to content

Revert "[interop] Configure libstdc++ module map at runtime" #64239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions include/swift/AST/DiagnosticsClangImporter.def
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ WARNING(glibc_not_found, none,
WARNING(libstdcxx_not_found, none,
"libstdc++ not found for '%0'; C++ stdlib may be unavailable",
(StringRef))
WARNING(libstdcxx_modulemap_not_found, none,
"module map for libstdc++ not found for '%0'; C++ stdlib may be unavailable",
(StringRef))

WARNING(too_many_class_template_instantiations, none,
"template instantiation for '%0' not imported: too many instantiations",
Expand Down
13 changes: 0 additions & 13 deletions include/swift/ClangImporter/ClangImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#define SWIFT_CLANG_IMPORTER_H

#include "swift/AST/ClangModuleLoader.h"
#include "llvm/Support/VirtualFileSystem.h"

/// The maximum number of SIMD vector elements we currently try to import.
#define SWIFT_MAX_IMPORTED_SIMD_ELEMENTS 4
Expand Down Expand Up @@ -581,18 +580,6 @@ bool requiresCPlusPlus(const clang::Module *module);

} // namespace importer

struct ClangInvocationFileMapping {
SmallVector<std::pair<std::string, std::string>, 2> redirectedFiles;
SmallVector<std::pair<std::string, std::string>, 1> overridenFiles;
};

/// On Linux, some platform libraries (glibc, libstdc++) are not modularized.
/// We inject modulemaps for those libraries into their include directories
/// to allow using them from Swift.
ClangInvocationFileMapping getClangInvocationFileMapping(
ASTContext &ctx,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs = nullptr);

} // end namespace swift

#endif
21 changes: 2 additions & 19 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,25 +1119,8 @@ ClangImporter::create(ASTContext &ctx,
auto fileMapping = getClangInvocationFileMapping(ctx);
// Wrap Swift's FS to allow Clang to override the working directory
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
llvm::vfs::RedirectingFileSystem::create(
fileMapping.redirectedFiles, true, *ctx.SourceMgr.getFileSystem());
if (!fileMapping.overridenFiles.empty()) {
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> overridenVFS =
new llvm::vfs::InMemoryFileSystem();
for (const auto &file : fileMapping.overridenFiles) {
auto contents = ctx.Allocate<char>(file.second.size() + 1);
std::copy(file.second.begin(), file.second.end(), contents.begin());
// null terminate the buffer.
contents[contents.size() - 1] = '\0';
overridenVFS->addFile(file.first, 0,
llvm::MemoryBuffer::getMemBuffer(
StringRef(contents.begin(), contents.size() - 1)));
}
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> overlayVFS =
new llvm::vfs::OverlayFileSystem(VFS);
VFS = overlayVFS;
overlayVFS->pushOverlay(overridenVFS);
}
llvm::vfs::RedirectingFileSystem::create(fileMapping, true,
*ctx.SourceMgr.getFileSystem());

// Create a new Clang compiler invocation.
{
Expand Down
Loading