https://github.com/simpal01 created https://github.com/llvm/llvm-project/pull/165321
The current baremetal driver implementation does not have a way to derive the target-triple-level include path within the sysroot. This feature is especially useful in setups where header paths deviate from the default bare-metal assumptions. For example, when headers are shared across target triples, it becomes necessary to organize them under target-triple-specific directories to ensure correct resolution.. >From c664b02fc81fda697b09abb5987312097d63618b Mon Sep 17 00:00:00 2001 From: Simi Pallipurath <[email protected]> Date: Mon, 27 Oct 2025 14:44:20 +0000 Subject: [PATCH] [Clang][Driver] Fix the missing Target-Triple-Level include path resolution in Baremetal Driver The current baremetal driver implementation does not have a way to derive the target-triple-level include path within the sysroot. This feature is especially useful in setups where header paths deviate from the default bare-metal assumptions. For example, when headers are shared across target triples, it becomes necessary to organize them under target-triple-specific directories to ensure correct resolution.. --- clang/lib/Driver/ToolChains/BareMetal.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp index 9b7f58c392885..d048f228f4572 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -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); @@ -418,6 +420,13 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs, llvm::sys::path::append(Dir, M.includeSuffix()); llvm::sys::path::append(Dir, "include"); addSystemInclude(DriverArgs, CC1Args, Dir.str()); + + 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 +507,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()); break; } case ToolChain::CST_Libstdcxx: { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
