forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Modules] Don't search for modulemaps in the immediate sub-directorie…
…s of search paths for recent Apple SDKs. (llvm#100005) Such searches can be costly and non-intuitive. We've seen complaints from developers that they don't expect clang to find modules on their own and not in search paths that developers provide. Keeping the search of modulemaps in subdirectories for code completion as it provides better user experience. If you are defining module "UsefulCode" in "include/UnrelatedName/module.modulemap", it is recommended to rename the directory "UnrelatedName" to "UsefulCode". If you cannot do so, you can add to "include/module.modulemap" a line like `extern module UsefulCode "UnrelatedName/module.modulemap"`, so clang can find module "UsefulCode" without checking each subdirectory in "include/". rdar://106677321 --------- Co-authored-by: Jan Svoboda <jan@svoboda.ai>
- Loading branch information
1 parent
d0c8e26
commit cbd5ba2
Showing
7 changed files
with
103 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// RUN: rm -rf %t | ||
// RUN: split-file %s %t | ||
|
||
// Check that with a sufficiently new SDK not searching for module maps in subdirectories. | ||
|
||
// New SDK. | ||
// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %t/MacOSX15.0.sdk -fmodules %t/test.c -### 2>&1 \ | ||
// RUN: | FileCheck --check-prefix=NO-SUBDIRECTORIES %t/test.c | ||
// Old SDK. | ||
// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %t/MacOSX14.0.sdk -fmodules %t/test.c -### 2>&1 \ | ||
// RUN: | FileCheck --check-prefix=SEARCH-SUBDIRECTORIES %t/test.c | ||
// Non-Darwin platform. | ||
// RUN: %clang -target i386-unknown-linux -isysroot %t/MacOSX15.0.sdk -fmodules %t/test.c -### 2>&1 \ | ||
// RUN: | FileCheck --check-prefix=SEARCH-SUBDIRECTORIES %t/test.c | ||
// New SDK overriding the default. | ||
// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %t/MacOSX15.0.sdk -fmodules %t/test.c -fmodulemap-allow-subdirectory-search -### 2>&1 \ | ||
// RUN: | FileCheck --check-prefix=SEARCH-SUBDIRECTORIES %t/test.c | ||
|
||
//--- test.c | ||
// NO-SUBDIRECTORIES: "-fno-modulemap-allow-subdirectory-search" | ||
// SEARCH-SUBDIRECTORIES-NOT: "-fno-modulemap-allow-subdirectory-search" | ||
|
||
//--- MacOSX15.0.sdk/SDKSettings.json | ||
{"Version":"15.0", "MaximumDeploymentTarget": "15.0.99"} | ||
|
||
//--- MacOSX14.0.sdk/SDKSettings.json | ||
{"Version":"14.0", "MaximumDeploymentTarget": "14.0.99"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// RUN: rm -rf %t | ||
// RUN: split-file %s %t | ||
|
||
// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -I %t/include %t/test.m | ||
// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -I %t/include %t/test.m -fmodulemap-allow-subdirectory-search | ||
// RUN: not %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -I %t/include %t/test.m -fno-modulemap-allow-subdirectory-search | ||
|
||
//--- include/UnrelatedName/Header.h | ||
// empty | ||
|
||
//--- include/UnrelatedName/module.modulemap | ||
module UsefulCode { | ||
header "Header.h" | ||
export * | ||
} | ||
|
||
//--- test.m | ||
@import UsefulCode; |