[ClangImporter] clang's -iframework comes before builtin usr/local/include, but Swift's -Fsystem comes after

When Swift passes search paths to clang, it does so directly into the HeaderSearch. That means that those paths get ordered inconsistently compared to the equivalent clang flag, and causes inconsistencies when building clang modules with clang and with Swift. Instead of touching the HeaderSearch directly, pass Swift search paths as driver flags, just do them after the -Xcc ones.

Swift doesn't have a way to pass a search path to clang as -isystem, only as -I which usually isn't the right flag. Add an -Isystem Swift flag so that those paths can be passed to clang as -isystem.

rdar://93951328
This commit is contained in:
Ian Anderson
2024-12-19 14:20:29 -08:00
parent 55189bae8e
commit cdb42c3535
30 changed files with 257 additions and 143 deletions

View File

@@ -99,7 +99,7 @@ std::optional<bool> forEachModuleSearchPath(
callback) {
for (const auto &path : Ctx.SearchPathOpts.getImportSearchPaths())
if (auto result =
callback(path, ModuleSearchPathKind::Import, /*isSystem=*/false))
callback(path.Path, ModuleSearchPathKind::Import, path.IsSystem))
return result;
for (const auto &path : Ctx.SearchPathOpts.getFrameworkSearchPaths())