Skip to content

Commit 81b18d2

Browse files
committed
[cxx-interop] Pass --gcc-toolchain to Clang driver when determining include paths
1 parent 0ced5ec commit 81b18d2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,14 @@ getClangInvocationFileMapping(ASTContext &ctx) {
902902
new clang::DiagnosticOptions());
903903
clang::driver::Driver clangDriver(ctx.ClangImporterOpts.clangPath,
904904
triple.str(), *clangDiags);
905-
llvm::opt::InputArgList clangDriverArgs;
905+
// Flags passed to Swift with `-Xcc` might affect include paths.
906+
unsigned unused1, unused2;
907+
std::vector<const char *> clangArgs;
908+
for (const auto &each : ctx.ClangImporterOpts.ExtraArgs) {
909+
clangArgs.push_back(each.c_str());
910+
}
911+
llvm::opt::InputArgList clangDriverArgs =
912+
clangDriver.getOpts().ParseArgs(clangArgs, unused1, unused2);
906913
// If an SDK path was explicitly passed to Swift, make sure to pass it to
907914
// Clang driver as well. It affects the resulting include paths.
908915
auto sdkPath = ctx.SearchPathOpts.getSDKPath();

0 commit comments

Comments
 (0)