-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[Clang][Driver] Fix the missing Target-Triple-Level include path resolution in Baremetal Driver #165321
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?
[Clang][Driver] Fix the missing Target-Triple-Level include path resolution in Baremetal Driver #165321
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 |
|---|---|---|
|
|
@@ -408,6 +408,8 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs, | |
| if (DriverArgs.hasArg(options::OPT_nostdlibinc)) | ||
| return; | ||
|
|
||
| const Driver &D = getDriver(); | ||
|
|
||
| if (std::optional<std::string> Path = getStdlibIncludePath()) | ||
| addSystemInclude(DriverArgs, CC1Args, *Path); | ||
|
|
||
|
|
@@ -419,6 +421,12 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs, | |
| llvm::sys::path::append(Dir, "include"); | ||
| addSystemInclude(DriverArgs, CC1Args, Dir.str()); | ||
| } | ||
| SmallString<128> Dir = SysRootDir; | ||
| llvm::sys::path::append(Dir, getTripleString()); | ||
| if (D.getVFS().exists(Dir)) { | ||
| llvm::sys::path::append(Dir, "include"); | ||
| addSystemInclude(DriverArgs, CC1Args, Dir.str()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -498,9 +506,13 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, | |
| addSystemInclude(DriverArgs, CC1Args, TargetDir.str()); | ||
| break; | ||
| } | ||
| // Add generic path if nothing else succeeded so far. | ||
| // Add generic paths if nothing else succeeded so far. | ||
| llvm::sys::path::append(Dir, "include", "c++", "v1"); | ||
| addSystemInclude(DriverArgs, CC1Args, Dir.str()); | ||
| Dir = SysRootDir; | ||
| llvm::sys::path::append(Dir, Target, "include", "c++", "v1"); | ||
| if (D.getVFS().exists(Dir)) | ||
| addSystemInclude(DriverArgs, CC1Args, Dir.str()); | ||
|
Comment on lines
+512
to
+515
Member
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. Since this logic is unrelated to multilibs, this should be done inside
Contributor
Author
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. AddCXXIncludePath(Path) is currently passed a path derived from a top-level include directory that isn’t rooted in the active --sysroot. What this PR is actually aiming for is to derive the target-triple-level include path within the sysroot itself. But here the sysroot computation happens after the AddCXXIncludePath(Path) call.
Member
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 see, I still think we need to move this logic outside of the multilib loop to avoid adding the include directory multiple times. I think this entire loop might need to be restructured since I don't think it's actually correct, so it might be probably easiest for now to just move the new logic outside. |
||
| break; | ||
| } | ||
| case ToolChain::CST_Libstdcxx: { | ||
|
|
||
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.
Nit: I'd use copy constructor over assignment operator for consistency with the existing code.