Skip to content

Commit 6e48b1d

Browse files
committed
[ClangImporter][ModuleWrap] Turn off libc warnings.
`swift-modulewrap` uses the `ClangImporter` to obtain a module loader, but it doesn't take an SDK argument (nor does anything bother to pass one), which means that when cross-compiling you get warnings about not being able to find the C library. Suppress the warning by telling the `ClangImporter` that we don't care about the C library here. rdar://115918181
1 parent 365b72f commit 6e48b1d

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

include/swift/ClangImporter/ClangImporter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ class ClangImporter final : public ClangModuleLoader {
188188
static std::unique_ptr<ClangImporter>
189189
create(ASTContext &ctx,
190190
std::string swiftPCHHash = "", DependencyTracker *tracker = nullptr,
191-
DWARFImporterDelegate *dwarfImporterDelegate = nullptr);
191+
DWARFImporterDelegate *dwarfImporterDelegate = nullptr,
192+
bool ignoreFileMapping = false);
192193

193194
static std::vector<std::string>
194195
getClangDriverArguments(ASTContext &ctx, bool ignoreClangTarget = false);

lib/ClangImporter/ClangImporter.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,8 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
12751275
std::unique_ptr<ClangImporter>
12761276
ClangImporter::create(ASTContext &ctx,
12771277
std::string swiftPCHHash, DependencyTracker *tracker,
1278-
DWARFImporterDelegate *dwarfImporterDelegate) {
1278+
DWARFImporterDelegate *dwarfImporterDelegate,
1279+
bool ignoreFileMapping) {
12791280
std::unique_ptr<ClangImporter> importer{
12801281
new ClangImporter(ctx, tracker, dwarfImporterDelegate)};
12811282
auto &importerOpts = ctx.ClangImporterOpts;
@@ -1296,7 +1297,11 @@ ClangImporter::create(ASTContext &ctx,
12961297
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
12971298
ctx.SourceMgr.getFileSystem();
12981299

1299-
auto fileMapping = getClangInvocationFileMapping(ctx);
1300+
ClangInvocationFileMapping fileMapping;
1301+
1302+
if (!ignoreFileMapping)
1303+
fileMapping = getClangInvocationFileMapping(ctx);
1304+
13001305
// Avoid creating indirect file system when using include tree.
13011306
if (!ctx.ClangImporterOpts.HasClangIncludeTreeRoot) {
13021307
// Wrap Swift's FS to allow Clang to override the working directory

lib/DriverTool/modulewrap_main.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,11 @@ int modulewrap_main(ArrayRef<const char *> Args, const char *Argv0,
196196
llvm::makeIntrusiveRefCnt<llvm::vfs::OnDiskOutputBackend>());
197197
registerParseRequestFunctions(ASTCtx.evaluator);
198198
registerTypeCheckerRequestFunctions(ASTCtx.evaluator);
199-
200-
ASTCtx.addModuleLoader(ClangImporter::create(ASTCtx, ""), true);
199+
200+
ASTCtx.addModuleLoader(ClangImporter::create(ASTCtx, "",
201+
nullptr, nullptr,
202+
true),
203+
true);
201204
ModuleDecl *M = ModuleDecl::create(ASTCtx.getIdentifier("swiftmodule"), ASTCtx);
202205
std::unique_ptr<Lowering::TypeConverter> TC(
203206
new Lowering::TypeConverter(*M, ASTCtx.SILOpts.EnableSILOpaqueValues));

0 commit comments

Comments
 (0)