-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang][Darwin] Introduce SubFrameworks
as a SDK default location
#115048
[Clang][Darwin] Introduce SubFrameworks
as a SDK default location
#115048
Conversation
@llvm/pr-subscribers-clang Author: Cyndy Ishida (cyndyishida) Changes
resolves: <rdar://137457006> Full diff: https://github.com/llvm/llvm-project/pull/115048.diff 5 Files Affected:
diff --git a/clang/lib/InstallAPI/DirectoryScanner.cpp b/clang/lib/InstallAPI/DirectoryScanner.cpp
index 03a8208c7364e9..be43a96f3d97d1 100644
--- a/clang/lib/InstallAPI/DirectoryScanner.cpp
+++ b/clang/lib/InstallAPI/DirectoryScanner.cpp
@@ -277,7 +277,8 @@ llvm::Error DirectoryScanner::scanForFrameworks(StringRef Directory) {
// Expect a certain directory structure and naming convention to find
// frameworks.
static const char *SubDirectories[] = {"System/Library/Frameworks/",
- "System/Library/PrivateFrameworks/"};
+ "System/Library/PrivateFrameworks/",
+ "System/Library/SubFrameworks"};
// Check if the directory is already a framework.
if (isFramework(Directory)) {
diff --git a/clang/lib/Lex/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp
index 86c2ecdf9e36eb..c1769c84887b5f 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -347,6 +347,7 @@ void InitHeaderSearch::AddDefaultIncludePaths(
} else {
AddPath("/System/Library/Frameworks", System, true);
AddPath("/Library/Frameworks", System, true);
+ AddPath("/System/Library/SubFrameworks", System, true);
}
}
return;
diff --git a/clang/test/Driver/darwin-subframeworks.c b/clang/test/Driver/darwin-subframeworks.c
new file mode 100644
index 00000000000000..62d3ab50f44741
--- /dev/null
+++ b/clang/test/Driver/darwin-subframeworks.c
@@ -0,0 +1,15 @@
+// Add default directories before running clang to check default
+// search paths.
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: cp -R %S/Inputs/MacOSX15.1.sdk %t/
+// RUN: mkdir -p %t/MacOSX15.1.sdk/System/Library/Frameworks
+// RUN: mkdir -p %t/MacOSX15.1.sdk/System/Library/SubFrameworks
+// RUN: mkdir -p %t/MacOSX15.1.sdk/usr/include
+
+// RUN: %clang %s -target arm64-apple-darwin13.0 -isysroot %t/MacOSX15.1.sdk -E -v 2>&1 | FileCheck %s
+
+// CHECK: -isysroot [[PATH:[^ ]*/MacOSX15.1.sdk]]
+// CHECK: #include <...> search starts here:
+// CHECK: [[PATH]]/usr/include
+// CHECK: [[PATH]]/System/Library/Frameworks (framework directory)
+// CHECK: [[PATH]]/System/Library/SubFrameworks (framework directory)
diff --git a/llvm/lib/TextAPI/Utils.cpp b/llvm/lib/TextAPI/Utils.cpp
index 8a06d53942a947..68d73eac86691d 100644
--- a/llvm/lib/TextAPI/Utils.cpp
+++ b/llvm/lib/TextAPI/Utils.cpp
@@ -120,6 +120,9 @@ bool llvm::MachO::isPrivateLibrary(StringRef Path, bool IsSymLink) {
if (Path.starts_with("/System/Library/PrivateFrameworks"))
return true;
+ if (Path.starts_with("/System/Library/SubFrameworks"))
+ return true;
+
// Everything in /usr/lib/swift (including sub-directories) are considered
// public.
if (Path.consume_front("/usr/lib/swift/"))
diff --git a/llvm/test/tools/llvm-readtapi/stubify-delete.test b/llvm/test/tools/llvm-readtapi/stubify-delete.test
index 666d740560cbfe..d91b0df06d3d8f 100644
--- a/llvm/test/tools/llvm-readtapi/stubify-delete.test
+++ b/llvm/test/tools/llvm-readtapi/stubify-delete.test
@@ -2,17 +2,20 @@
# Setup a mix of public and private libraries that resemble apple sdk.
; RUN: mkdir -p %t/sysroot/usr/local/lib/ %t/sysroot/usr/lib/
; RUN: mkdir -p %t/sysroot/System/Library/Frameworks/System.framework %t/sysroot/System/Library/PrivateFrameworks/Fat.framework
+; RUN: mkdir -p %t/sysroot/System/Library/SubFrameworks/Fat.framework/Headers
; RUN: yaml2obj %S/Inputs/libSystem.1.yaml -o %t/sysroot/System/Library/Frameworks/System.framework/System
; RUN: yaml2obj %S/Inputs/objc.yaml -o %t/sysroot/usr/lib/libobjc.dylib
; RUN: cp %t/sysroot/usr/lib/libobjc.dylib %t/sysroot/usr/local/lib/libobjc-unstable.dylib
; RUN: yaml2obj %S/Inputs/universal.yaml -o %t/sysroot/System/Library/PrivateFrameworks/Fat.framework/Fat
+; RUN: cp %t/sysroot/System/Library/PrivateFrameworks/Fat.framework/Fat %t/sysroot/System/Library/SubFrameworks/Fat.framework/Fat
+; RUN: touch %t/sysroot/System/Library/SubFrameworks/Fat.framework/Headers/Fat.h
; 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:
# Validate expected files are removed.
; RUN: not test -f %t/sysroot/System/Library/PrivateFrameworks
; RUN: not test -f %t/sysroot/usr/local
; RUN: not test -f %t/sysroot/usr/lib/libobjc.dylib
; RUN: not test -f %t/sysroot/System/Library/Frameworks/System.framework/System
+; RUN: not test -f %t/sysroot/System/Library/SubFrameworks/Fat.framework/Fat
; RUN: test -f %t/sysroot/System/Library/Frameworks/System.framework/System.tbd
; RUN: test -f %t/sysroot/usr/lib/libobjc.tbd
-
-
+; RUN: test -f %t/sysroot/System/Library/SubFrameworks/Fat.framework/Headers/Fat.h
|
@llvm/pr-subscribers-clang-driver Author: Cyndy Ishida (cyndyishida) Changes
resolves: <rdar://137457006> Full diff: https://github.com/llvm/llvm-project/pull/115048.diff 5 Files Affected:
diff --git a/clang/lib/InstallAPI/DirectoryScanner.cpp b/clang/lib/InstallAPI/DirectoryScanner.cpp
index 03a8208c7364e9..be43a96f3d97d1 100644
--- a/clang/lib/InstallAPI/DirectoryScanner.cpp
+++ b/clang/lib/InstallAPI/DirectoryScanner.cpp
@@ -277,7 +277,8 @@ llvm::Error DirectoryScanner::scanForFrameworks(StringRef Directory) {
// Expect a certain directory structure and naming convention to find
// frameworks.
static const char *SubDirectories[] = {"System/Library/Frameworks/",
- "System/Library/PrivateFrameworks/"};
+ "System/Library/PrivateFrameworks/",
+ "System/Library/SubFrameworks"};
// Check if the directory is already a framework.
if (isFramework(Directory)) {
diff --git a/clang/lib/Lex/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp
index 86c2ecdf9e36eb..c1769c84887b5f 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -347,6 +347,7 @@ void InitHeaderSearch::AddDefaultIncludePaths(
} else {
AddPath("/System/Library/Frameworks", System, true);
AddPath("/Library/Frameworks", System, true);
+ AddPath("/System/Library/SubFrameworks", System, true);
}
}
return;
diff --git a/clang/test/Driver/darwin-subframeworks.c b/clang/test/Driver/darwin-subframeworks.c
new file mode 100644
index 00000000000000..62d3ab50f44741
--- /dev/null
+++ b/clang/test/Driver/darwin-subframeworks.c
@@ -0,0 +1,15 @@
+// Add default directories before running clang to check default
+// search paths.
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: cp -R %S/Inputs/MacOSX15.1.sdk %t/
+// RUN: mkdir -p %t/MacOSX15.1.sdk/System/Library/Frameworks
+// RUN: mkdir -p %t/MacOSX15.1.sdk/System/Library/SubFrameworks
+// RUN: mkdir -p %t/MacOSX15.1.sdk/usr/include
+
+// RUN: %clang %s -target arm64-apple-darwin13.0 -isysroot %t/MacOSX15.1.sdk -E -v 2>&1 | FileCheck %s
+
+// CHECK: -isysroot [[PATH:[^ ]*/MacOSX15.1.sdk]]
+// CHECK: #include <...> search starts here:
+// CHECK: [[PATH]]/usr/include
+// CHECK: [[PATH]]/System/Library/Frameworks (framework directory)
+// CHECK: [[PATH]]/System/Library/SubFrameworks (framework directory)
diff --git a/llvm/lib/TextAPI/Utils.cpp b/llvm/lib/TextAPI/Utils.cpp
index 8a06d53942a947..68d73eac86691d 100644
--- a/llvm/lib/TextAPI/Utils.cpp
+++ b/llvm/lib/TextAPI/Utils.cpp
@@ -120,6 +120,9 @@ bool llvm::MachO::isPrivateLibrary(StringRef Path, bool IsSymLink) {
if (Path.starts_with("/System/Library/PrivateFrameworks"))
return true;
+ if (Path.starts_with("/System/Library/SubFrameworks"))
+ return true;
+
// Everything in /usr/lib/swift (including sub-directories) are considered
// public.
if (Path.consume_front("/usr/lib/swift/"))
diff --git a/llvm/test/tools/llvm-readtapi/stubify-delete.test b/llvm/test/tools/llvm-readtapi/stubify-delete.test
index 666d740560cbfe..d91b0df06d3d8f 100644
--- a/llvm/test/tools/llvm-readtapi/stubify-delete.test
+++ b/llvm/test/tools/llvm-readtapi/stubify-delete.test
@@ -2,17 +2,20 @@
# Setup a mix of public and private libraries that resemble apple sdk.
; RUN: mkdir -p %t/sysroot/usr/local/lib/ %t/sysroot/usr/lib/
; RUN: mkdir -p %t/sysroot/System/Library/Frameworks/System.framework %t/sysroot/System/Library/PrivateFrameworks/Fat.framework
+; RUN: mkdir -p %t/sysroot/System/Library/SubFrameworks/Fat.framework/Headers
; RUN: yaml2obj %S/Inputs/libSystem.1.yaml -o %t/sysroot/System/Library/Frameworks/System.framework/System
; RUN: yaml2obj %S/Inputs/objc.yaml -o %t/sysroot/usr/lib/libobjc.dylib
; RUN: cp %t/sysroot/usr/lib/libobjc.dylib %t/sysroot/usr/local/lib/libobjc-unstable.dylib
; RUN: yaml2obj %S/Inputs/universal.yaml -o %t/sysroot/System/Library/PrivateFrameworks/Fat.framework/Fat
+; RUN: cp %t/sysroot/System/Library/PrivateFrameworks/Fat.framework/Fat %t/sysroot/System/Library/SubFrameworks/Fat.framework/Fat
+; RUN: touch %t/sysroot/System/Library/SubFrameworks/Fat.framework/Headers/Fat.h
; 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:
# Validate expected files are removed.
; RUN: not test -f %t/sysroot/System/Library/PrivateFrameworks
; RUN: not test -f %t/sysroot/usr/local
; RUN: not test -f %t/sysroot/usr/lib/libobjc.dylib
; RUN: not test -f %t/sysroot/System/Library/Frameworks/System.framework/System
+; RUN: not test -f %t/sysroot/System/Library/SubFrameworks/Fat.framework/Fat
; RUN: test -f %t/sysroot/System/Library/Frameworks/System.framework/System.tbd
; RUN: test -f %t/sysroot/usr/lib/libobjc.tbd
-
-
+; RUN: test -f %t/sysroot/System/Library/SubFrameworks/Fat.framework/Headers/Fat.h
|
Do we also need to update |
I thought about it, but clang already doesn't for today's default paths so I decided against it. It seems only pass extra paths to the linker for platform-specific directories like |
* 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>
baecb5c
to
25e30d6
Compare
Seems like an unrelated issue is happening on the windows bot, noticed the same in a different PR. https://buildkite.com/llvm-project/github-pull-requests/builds/116688#0192fe1c-1484-47e8-b14c-7f3da7038b76 |
styles
25e30d6
to
4207ffe
Compare
ping |
ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…lvm#115048) * 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 (cherry picked from commit 2d48489)
…lvm#115048) * 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 (cherry picked from commit 2d48489)
…lvm#115048) * 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 (cherry picked from commit 2d48489)
System/Library/SubFrameworks
when determining default sdk search paths.clang-installapi
to traverse there for framework input.llvm-readtapi
that the library files (TBD or binary) in there should be considered private.resolves: rdar://137457006