Skip to content

Commit 27ff49f

Browse files
authored
Merge pull request #60804 from buttaface/cross-sysroot
[ClangImporter] Add the sysroot directly to the clang Driver used to find the libc header path
2 parents 28644db + f82a4e7 commit 27ff49f

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

lib/ClangImporter/ClangIncludePaths.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,8 @@ createClangArgs(const ASTContext &ctx, clang::driver::Driver &clangDriver) {
162162
// If an SDK path was explicitly passed to Swift, make sure to pass it to
163163
// Clang driver as well. It affects the resulting include paths.
164164
auto sdkPath = ctx.SearchPathOpts.getSDKPath();
165-
if (!sdkPath.empty()) {
166-
unsigned argIndex = clangDriverArgs.MakeIndex("--sysroot", sdkPath);
167-
clangDriverArgs.append(new llvm::opt::Arg(
168-
clangDriver.getOpts().getOption(clang::driver::options::OPT__sysroot),
169-
sdkPath, argIndex));
170-
}
165+
if (!sdkPath.empty())
166+
clangDriver.SysRoot = sdkPath.str();
171167
return clangDriverArgs;
172168
}
173169

@@ -212,13 +208,6 @@ getGlibcFileMapping(ASTContext &ctx) {
212208
// FIXME: Emit a warning of some kind.
213209
return {};
214210

215-
// Only inject the module map if it actually exists. It may not, for example
216-
// if `swiftc -target x86_64-unknown-linux-gnu -emit-ir` is invoked using
217-
// a Swift compiler not built for Linux targets.
218-
if (!llvm::sys::fs::exists(actualModuleMapPath))
219-
// FIXME: emit a warning of some kind.
220-
return {};
221-
222211
// TODO: remove the SwiftGlibc.h header and reference all Glibc headers
223212
// directly from the modulemap.
224213
Path actualHeaderPath = actualModuleMapPath;

0 commit comments

Comments
 (0)