Skip to content

Commit b7ec9c8

Browse files
committed
[ClangImporter] Make sure the -resource-dir is checked before the -sdk, as done everywhere else in the compiler
Otherwise, these module maps can be pulled from a system SDK instead when building a fresh Swift stdlib, fixes #74696.
1 parent 993becc commit b7ec9c8

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/ClangImporter/ClangIncludePaths.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ static std::optional<Path> getActualModuleMapPath(
3535

3636
Path result;
3737

38-
StringRef SDKPath = Opts.getSDKPath();
39-
if (!SDKPath.empty()) {
40-
result.append(SDKPath.begin(), SDKPath.end());
41-
llvm::sys::path::append(result, "usr", "lib", "swift");
38+
if (!Opts.RuntimeResourcePath.empty()) {
39+
result.append(Opts.RuntimeResourcePath.begin(),
40+
Opts.RuntimeResourcePath.end());
4241
llvm::sys::path::append(result, platform);
4342
if (isArchSpecific) {
4443
llvm::sys::path::append(result, arch);
@@ -52,10 +51,11 @@ static std::optional<Path> getActualModuleMapPath(
5251
return result;
5352
}
5453

55-
if (!Opts.RuntimeResourcePath.empty()) {
54+
StringRef SDKPath = Opts.getSDKPath();
55+
if (!SDKPath.empty()) {
5656
result.clear();
57-
result.append(Opts.RuntimeResourcePath.begin(),
58-
Opts.RuntimeResourcePath.end());
57+
result.append(SDKPath.begin(), SDKPath.end());
58+
llvm::sys::path::append(result, "usr", "lib", "swift");
5959
llvm::sys::path::append(result, platform);
6060
if (isArchSpecific) {
6161
llvm::sys::path::append(result, arch);

0 commit comments

Comments
 (0)