Skip to content

Commit 9359df8

Browse files
committed
[Clang][Darwin] Introduce SubFrameworks as a SDK default location
* Have clang always append & pass `System/Library/SubFrameworks` when determining default sdk search paths. * Teach `clang-installapi` to traverse there for framework input. * Teach `llvm-readtapi` that the library files (TBD or binary) in there should be considered private. resolves: <rdar://137457006>
1 parent e8644e3 commit 9359df8

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

clang/lib/InstallAPI/DirectoryScanner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ llvm::Error DirectoryScanner::scanForFrameworks(StringRef Directory) {
277277
// Expect a certain directory structure and naming convention to find
278278
// frameworks.
279279
static const char *SubDirectories[] = {"System/Library/Frameworks/",
280-
"System/Library/PrivateFrameworks/"};
280+
"System/Library/PrivateFrameworks/",
281+
"System/Library/SubFrameworks"};
281282

282283
// Check if the directory is already a framework.
283284
if (isFramework(Directory)) {

clang/lib/Lex/InitHeaderSearch.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ void InitHeaderSearch::AddDefaultIncludePaths(
347347
} else {
348348
AddPath("/System/Library/Frameworks", System, true);
349349
AddPath("/Library/Frameworks", System, true);
350+
AddPath("/System/Library/SubFrameworks", System, true);
350351
}
351352
}
352353
return;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Add default directories before running clang to check default
2+
// search paths.
3+
// RUN: rm -rf %t && mkdir -p %t
4+
// RUN: cp -R %S/Inputs/MacOSX15.1.sdk %t/
5+
// RUN: mkdir -p %t/MacOSX15.1.sdk/System/Library/Frameworks
6+
// RUN: mkdir -p %t/MacOSX15.1.sdk/System/Library/SubFrameworks
7+
// RUN: mkdir -p %t/MacOSX15.1.sdk/usr/include
8+
9+
// RUN: %clang %s -target arm64-apple-darwin13.0 -isysroot %t/MacOSX15.1.sdk -E -v 2>&1 | FileCheck %s
10+
11+
// CHECK: -isysroot [[PATH:[^ ]*/MacOSX15.1.sdk]]
12+
// CHECK: #include <...> search starts here:
13+
// CHECK: [[PATH]]/usr/include
14+
// CHECK: [[PATH]]/System/Library/Frameworks (framework directory)
15+
// CHECK: [[PATH]]/System/Library/SubFrameworks (framework directory)

llvm/lib/TextAPI/Utils.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ bool llvm::MachO::isPrivateLibrary(StringRef Path, bool IsSymLink) {
120120
if (Path.starts_with("/System/Library/PrivateFrameworks"))
121121
return true;
122122

123+
if (Path.starts_with("/System/Library/SubFrameworks"))
124+
return true;
125+
123126
// Everything in /usr/lib/swift (including sub-directories) are considered
124127
// public.
125128
if (Path.consume_front("/usr/lib/swift/"))

llvm/test/tools/llvm-readtapi/stubify-delete.test

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
# Setup a mix of public and private libraries that resemble apple sdk.
33
; RUN: mkdir -p %t/sysroot/usr/local/lib/ %t/sysroot/usr/lib/
44
; RUN: mkdir -p %t/sysroot/System/Library/Frameworks/System.framework %t/sysroot/System/Library/PrivateFrameworks/Fat.framework
5+
; RUN: mkdir -p %t/sysroot/System/Library/SubFrameworks/Fat.framework/Headers
56
; RUN: yaml2obj %S/Inputs/libSystem.1.yaml -o %t/sysroot/System/Library/Frameworks/System.framework/System
67
; RUN: yaml2obj %S/Inputs/objc.yaml -o %t/sysroot/usr/lib/libobjc.dylib
78
; RUN: cp %t/sysroot/usr/lib/libobjc.dylib %t/sysroot/usr/local/lib/libobjc-unstable.dylib
89
; RUN: yaml2obj %S/Inputs/universal.yaml -o %t/sysroot/System/Library/PrivateFrameworks/Fat.framework/Fat
10+
; RUN: cp %t/sysroot/System/Library/PrivateFrameworks/Fat.framework/Fat %t/sysroot/System/Library/SubFrameworks/Fat.framework/Fat
11+
; RUN: touch %t/sysroot/System/Library/SubFrameworks/Fat.framework/Headers/Fat.h
912
; RUN: llvm-readtapi -stubify %t/sysroot --delete-input --delete-private-libraries 2>&1 | FileCheck %s --allow-empty --implicit-check-not warning: --implicit-check-not error:
1013
# Validate expected files are removed.
1114
; RUN: not test -f %t/sysroot/System/Library/PrivateFrameworks
1215
; RUN: not test -f %t/sysroot/usr/local
1316
; RUN: not test -f %t/sysroot/usr/lib/libobjc.dylib
1417
; RUN: not test -f %t/sysroot/System/Library/Frameworks/System.framework/System
18+
; RUN: not test -f %t/sysroot/System/Library/SubFrameworks/Fat.framework/Fat
1519
; RUN: test -f %t/sysroot/System/Library/Frameworks/System.framework/System.tbd
1620
; RUN: test -f %t/sysroot/usr/lib/libobjc.tbd
17-
18-
21+
; RUN: test -f %t/sysroot/System/Library/SubFrameworks/Fat.framework/Headers/Fat.h

0 commit comments

Comments
 (0)