-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Clang][Darwin] Centralize framework search paths for headers & libraries. #118543
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,3 +150,23 @@ clang::parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath) { | |
return llvm::make_error<llvm::StringError>("invalid SDKSettings.json", | ||
llvm::inconvertibleErrorCode()); | ||
} | ||
|
||
// For certain platforms/environments almost all resources (e.g., headers) are | ||
// located in sub-directories, e.g., for DriverKit they live in | ||
// <SYSROOT>/System/DriverKit/usr/include (instead of <SYSROOT>/usr/include). | ||
StringRef clang::getSystemPrefix(const llvm::Triple &T) { | ||
if (T.isDriverKit()) | ||
return "/System/DriverKit"; | ||
return ""; | ||
} | ||
|
||
KnownSystemPaths clang::getCommonSystemPaths(llvm::Triple T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like this function might be slightly misnamed, unless I don't properly understand its purpose. If this will only ever return framework paths, perhaps a name like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I was initially thinking any common paths between header & linker search which in practice is only frameworks but could be extended in the future. That feels unlikely though. I can apply your suggestion, assuming it's still relevant, after rebasing your patch. |
||
KnownSystemPaths CommonSysPaths = {"/System/Library/Frameworks", | ||
"/System/Library/SubFrameworks"}; | ||
|
||
const StringRef Prefix = getSystemPrefix(T); | ||
for (std::string &SysPath : CommonSysPaths) | ||
SysPath = (Prefix + SysPath).str(); | ||
|
||
return CommonSysPaths; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "clang/Basic/DarwinSDKInfo.h" | ||
#include "clang/Basic/FileManager.h" | ||
#include "clang/Basic/LangOptions.h" | ||
#include "clang/Config/config.h" // C_INCLUDE_DIRS | ||
|
@@ -339,13 +340,11 @@ void InitHeaderSearch::AddDefaultIncludePaths( | |
if (triple.isOSDarwin()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think we can just clean up this code block by moving all logics to driver? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into this a bit more. IMO the only way to move all this code to the driver is to either
Both feel out of scope to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW I agree with your assessment @cyndyishida. I just did the exercise of picking up #75841 and we basically need to pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to revive this as #120149 |
||
if (HSOpts.UseStandardSystemIncludes) { | ||
// Add the default framework include paths on Darwin. | ||
if (triple.isDriverKit()) { | ||
AddPath("/System/DriverKit/System/Library/Frameworks", System, true); | ||
} else { | ||
AddPath("/System/Library/Frameworks", System, true); | ||
AddPath("/System/Library/SubFrameworks", System, true); | ||
for (const StringRef Path : getCommonSystemPaths(triple)) | ||
AddPath(Path, System, true); | ||
|
||
if (!triple.isDriverKit()) | ||
AddPath("/Library/Frameworks", System, true); | ||
} | ||
} | ||
return; | ||
} | ||
|
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.
I feel this header is used for parsing
SDKSettings.json
only. I don't feel like these functions are in the correct place.If we can do the cleanup for where my other comment is, we can just limit these function to be local to
Driver/Toolchains/Darwin.cpp
. No other file needs to have this information.