[clang] [Multilib] Extend the Multilib system to support an IncludeDirs field. (PR #146651)
Simi Pallipurath via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 29 00:06:17 PDT 2025
https://github.com/simpal01 updated https://github.com/llvm/llvm-project/pull/146651
>From 30c353052c35f01171111818aca3241e3dea6be2 Mon Sep 17 00:00:00 2001
From: Simi Pallipurath <simi.pallipurath at arm.com>
Date: Tue, 1 Jul 2025 21:25:00 +0100
Subject: [PATCH 1/7] [Multilib] Extend the Multilib system to support an
IncludepPath field.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch extends the Multilib Yaml format to allow
specifying an IncludePath for the header path/s per
multilib variant. The goal is to enable fine-grained
control over header search paths for each multilib variant.
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.
In the Clang driver, GCCSuffix, OSSuffix and IncludeSuffix
are path suffixes that help the compiler locate the correct
set of headers and libraries for the selected target.
Clang’s multilib infrastructure uses the Multilib class to
encapsulate these suffixes. Currently, in the bare-metal
Clang driver, all of these suffixes — GCCSuffix, OSSuffix, and
IncludeSuffix — are effectively mapped to the Dir field specified
in the multilib.yaml configuration.
This patch allows it to be configured independently of Dir,
enabling finer-grained control over header search paths for each multilib variant.
Key Changes:
New Field: IncludePath in multilib.yaml (header path or list of header
paths, strings, optional). When present, this path is passed to the
Multilib constructor and appended to the sysroot during header path resolution.
If omitted, behaviour defaults to preserving current behaviour.
For example,
- Dir: aarch64-none-elf/aarch64a_exn_rtti_unaligned
Flags:
- --target=aarch64-unknown-none-elf
IncludePath:
- include
- include-libunwind
- aarch64-none-elf/include
- aarch64-none-elf/aarch64a_exn_rtti_unaligned/include
Implementation Notes:
1. Extend the YAML parser to read the IncludePath key.
2. Update the Multilib constructor to store the content from this field.
3. Ensure the driver logic reads and applies IncludePath correctly.
---
clang/include/clang/Driver/Multilib.h | 7 +++++
clang/lib/Driver/Multilib.cpp | 15 +++++++--
clang/lib/Driver/ToolChains/BareMetal.cpp | 37 ++++++++++++++++++-----
3 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/clang/include/clang/Driver/Multilib.h b/clang/include/clang/Driver/Multilib.h
index fc071ef48ca0f..1f1372508c480 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -35,12 +35,14 @@ class Driver;
class Multilib {
public:
using flags_list = std::vector<std::string>;
+ using includepath_list = std::vector<std::string>;
private:
std::string GCCSuffix;
std::string OSSuffix;
std::string IncludeSuffix;
flags_list Flags;
+ includepath_list IncludePath;
// Optionally, a multilib can be assigned a string tag indicating that it's
// part of a group of mutually exclusive possibilities. If two or more
@@ -62,6 +64,7 @@ class Multilib {
/// This is enforced with an assert in the constructor.
Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
StringRef IncludeSuffix = {}, const flags_list &Flags = flags_list(),
+ const includepath_list &IncludePath = includepath_list(),
StringRef ExclusiveGroup = {},
std::optional<StringRef> Error = std::nullopt);
@@ -81,6 +84,10 @@ class Multilib {
/// All elements begin with either '-' or '!'
const flags_list &flags() const { return Flags; }
+ /// Get the include paths specified in multilib.yaml under the 'IncludePath'
+ /// field
+ const includepath_list &includePath() const { return IncludePath; }
+
/// Get the exclusive group label.
const std::string &exclusiveGroup() const { return ExclusiveGroup; }
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index 87fa1af54a8ea..2cbb47dd7acdb 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -29,9 +29,11 @@ using namespace llvm::sys;
Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
StringRef IncludeSuffix, const flags_list &Flags,
+ const includepath_list &IncludePath,
StringRef ExclusiveGroup, std::optional<StringRef> Error)
: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix),
- Flags(Flags), ExclusiveGroup(ExclusiveGroup), Error(Error) {
+ Flags(Flags), IncludePath(IncludePath), ExclusiveGroup(ExclusiveGroup),
+ Error(Error) {
assert(GCCSuffix.empty() ||
(StringRef(GCCSuffix).front() == '/' && GCCSuffix.size() > 1));
assert(OSSuffix.empty() ||
@@ -299,6 +301,7 @@ struct MultilibSerialization {
std::string Dir; // if this record successfully selects a library dir
std::string Error; // if this record reports a fatal error message
std::vector<std::string> Flags;
+ std::vector<std::string> IncludePath;
std::string Group;
};
@@ -350,6 +353,7 @@ template <> struct llvm::yaml::MappingTraits<MultilibSerialization> {
io.mapOptional("Dir", V.Dir);
io.mapOptional("Error", V.Error);
io.mapRequired("Flags", V.Flags);
+ io.mapOptional("IncludePath", V.IncludePath);
io.mapOptional("Group", V.Group);
}
static std::string validate(IO &io, MultilibSerialization &V) {
@@ -359,6 +363,10 @@ template <> struct llvm::yaml::MappingTraits<MultilibSerialization> {
return "the 'Dir' and 'Error' keys may not both be specified";
if (StringRef(V.Dir).starts_with("/"))
return "paths must be relative but \"" + V.Dir + "\" starts with \"/\"";
+ for (const auto &Path : V.IncludePath) {
+ if (StringRef(Path).starts_with("/"))
+ return "paths must be relative but \"" + Path + "\" starts with \"/\"";
+ }
return std::string{};
}
};
@@ -489,7 +497,8 @@ MultilibSet::parseYaml(llvm::MemoryBufferRef Input,
Multilibs.reserve(MS.Multilibs.size());
for (const auto &M : MS.Multilibs) {
if (!M.Error.empty()) {
- Multilibs.emplace_back("", "", "", M.Flags, M.Group, M.Error);
+ Multilibs.emplace_back("", "", "", M.Flags, M.IncludePath, M.Group,
+ M.Error);
} else {
std::string Dir;
if (M.Dir != ".")
@@ -498,7 +507,7 @@ MultilibSet::parseYaml(llvm::MemoryBufferRef Input,
// Multilib constructor. If we later support more than one type of group,
// we'll have to look up the group name in MS.Groups, check its type, and
// decide what to do here.
- Multilibs.emplace_back(Dir, Dir, Dir, M.Flags, M.Group);
+ Multilibs.emplace_back(Dir, Dir, Dir, M.Flags, M.IncludePath, M.Group);
}
}
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 981395deb9dbc..dfa801ce887c7 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -417,10 +417,20 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
const SmallString<128> SysRootDir(computeSysRoot());
if (!SysRootDir.empty()) {
for (const Multilib &M : getOrderedMultilibs()) {
- SmallString<128> Dir(SysRootDir);
- llvm::sys::path::append(Dir, M.includeSuffix());
- llvm::sys::path::append(Dir, "include");
- addSystemInclude(DriverArgs, CC1Args, Dir.str());
+ // Add include paths specified in multilib.yaml under the 'IncludePath'
+ // field
+ if (!M.includePath().empty()) {
+ for (const std::string &Path : M.includePath()) {
+ SmallString<128> Dir(SysRoot);
+ llvm::sys::path::append(Dir, Path);
+ addSystemInclude(DriverArgs, CC1Args, Dir.str());
+ }
+ } else {
+ SmallString<128> Dir(SysRootDir);
+ llvm::sys::path::append(Dir, M.includeSuffix());
+ llvm::sys::path::append(Dir, "include");
+ addSystemInclude(DriverArgs, CC1Args, Dir.str());
+ }
}
}
}
@@ -501,10 +511,21 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
addSystemInclude(DriverArgs, CC1Args, TargetDir.str());
break;
}
- // Add generic path if nothing else succeeded so far.
- llvm::sys::path::append(Dir, "include", "c++", "v1");
- addSystemInclude(DriverArgs, CC1Args, Dir.str());
- break;
+ if (!M.includePath().empty()) {
+ // Add include paths specified in multilib.yaml under the 'IncludePath'
+ // field
+ for (const std::string &Path : M.includePath()) {
+ Dir = SysRoot;
+ llvm::sys::path::append(Dir, Path, "c++", "v1");
+ addSystemInclude(DriverArgs, CC1Args, Dir.str());
+ }
+ break;
+ } else {
+ // Add generic path if nothing else succeeded so far.
+ llvm::sys::path::append(Dir, "include", "c++", "v1");
+ addSystemInclude(DriverArgs, CC1Args, Dir.str());
+ break;
+ }
}
case ToolChain::CST_Libstdcxx: {
llvm::sys::path::append(Dir, "include", "c++");
>From 50952444c2066d2d1d82cd7c30effa914d2ef8f2 Mon Sep 17 00:00:00 2001
From: Simi Pallipurath <simi.pallipurath at arm.com>
Date: Thu, 3 Jul 2025 11:49:59 +0100
Subject: [PATCH 2/7] fixup! [Multilib] Add basic tests for new 'IncludePath'
field in multilib.yaml.
---
clang/lib/Driver/ToolChains/BareMetal.cpp | 4 +--
.../baremetal-multilib-includepath-error.yaml | 28 +++++++++++++++++
.../baremetal-multilib-includepath.yaml | 31 +++++++++++++++++++
3 files changed, 61 insertions(+), 2 deletions(-)
create mode 100644 clang/test/Driver/baremetal-multilib-includepath-error.yaml
create mode 100644 clang/test/Driver/baremetal-multilib-includepath.yaml
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index dfa801ce887c7..139e137c0838e 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -417,9 +417,9 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
const SmallString<128> SysRootDir(computeSysRoot());
if (!SysRootDir.empty()) {
for (const Multilib &M : getOrderedMultilibs()) {
- // Add include paths specified in multilib.yaml under the 'IncludePath'
- // field
if (!M.includePath().empty()) {
+ // Add include paths specified in multilib.yaml under the 'IncludePath'
+ // field
for (const std::string &Path : M.includePath()) {
SmallString<128> Dir(SysRoot);
llvm::sys::path::append(Dir, Path);
diff --git a/clang/test/Driver/baremetal-multilib-includepath-error.yaml b/clang/test/Driver/baremetal-multilib-includepath-error.yaml
new file mode 100644
index 0000000000000..5a1152bcd6aba
--- /dev/null
+++ b/clang/test/Driver/baremetal-multilib-includepath-error.yaml
@@ -0,0 +1,28 @@
+
+# REQUIRES: shell
+# UNSUPPORTED: system-windows
+
+# This test demonstrates the new "IncludePath" field.
+# This field allows specifying include paths through
+# multilib.yaml configuration using relative paths.
+# Absolute paths should be rejected by the driver
+# with an appropriate diagnostic message.
+#
+# This test verifies that passing an absolute path
+# (/include) to IncludePath triggers the expected
+# error.
+
+# # RUN: %clang --target=aarch64-none-elf --multi-lib-config=%s %s -### -o /dev/null 2>&1 \
+# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
+# CHECK-ERROR: error: paths must be relative but "/include" starts with "/"
+
+
+MultilibVersion: 1.0
+Variants:
+- Dir: aarch64-none-elf/aarch64a_exn_rtti_unaligned
+ Flags:
+ - --target=aarch64-unknown-none-elf
+ - -munaligned-access
+ IncludePath:
+ - /include
+ - aarch64-none-elf/include
diff --git a/clang/test/Driver/baremetal-multilib-includepath.yaml b/clang/test/Driver/baremetal-multilib-includepath.yaml
new file mode 100644
index 0000000000000..36ea873d7cd58
--- /dev/null
+++ b/clang/test/Driver/baremetal-multilib-includepath.yaml
@@ -0,0 +1,31 @@
+# REQUIRES: shell
+# UNSUPPORTED: system-windows
+
+# This test demonstrates the new "IncludePath" field.
+# This field allows specifying include paths through
+# multilib.yaml configuration. When this field is present
+# it is appended to the sysroot during header path
+# resolution ignoring the default bare-metal assumptions.
+
+# RUN: %clang --multi-lib-config=%s -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \
+# RUN: --target=thumbv7m-none-eabi -mfloat-abi=soft --sysroot= \
+# RUN: | FileCheck %s
+# CHECK: "-cc1" "-triple" "thumbv7m-unknown-none-eabi"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT:[^"]*]]/bin/../lib/clang-runtimes/include/c++/v1"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/include-libunwind/c++/v1"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/soft/include/c++/v1"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/include"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/include-libunwind"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/soft/include"
+
+---
+MultilibVersion: 1.0
+Variants:
+- Dir: soft
+ Flags:
+ - -mfloat-abi=soft
+ IncludePath:
+ - include
+ - include-libunwind
+ - soft/include
+...
>From fe8fcbffbfc7c8a16285d3100f089b6528fb1329 Mon Sep 17 00:00:00 2001
From: Simi Pallipurath <simi.pallipurath at arm.com>
Date: Thu, 10 Jul 2025 15:20:23 +0100
Subject: [PATCH 3/7] fixup! fixup! [Multilib] Add basic tests for new
'IncludePath' field in multilib.yaml.
---
clang/lib/Driver/ToolChains/BareMetal.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 139e137c0838e..00ae5a7705149 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -520,12 +520,11 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
addSystemInclude(DriverArgs, CC1Args, Dir.str());
}
break;
- } else {
- // Add generic path if nothing else succeeded so far.
- llvm::sys::path::append(Dir, "include", "c++", "v1");
- addSystemInclude(DriverArgs, CC1Args, Dir.str());
- break;
}
+ // Add generic path if nothing else succeeded so far.
+ llvm::sys::path::append(Dir, "include", "c++", "v1");
+ addSystemInclude(DriverArgs, CC1Args, Dir.str());
+ break;
}
case ToolChain::CST_Libstdcxx: {
llvm::sys::path::append(Dir, "include", "c++");
>From 61ca60b496bba40f1371262dc73e3afbeddf61cb Mon Sep 17 00:00:00 2001
From: Simi Pallipurath <simi.pallipurath at arm.com>
Date: Fri, 11 Jul 2025 13:17:54 +0100
Subject: [PATCH 4/7] fixup! Remove `-###` and add missing `not` .
The `-###` flag was unintentionally included,
causing the compiler to only print the driver
command sequence without performing compilation.
This masked the need for the `not` command in the llvm-lit test.
After removing `-###`, the missing `not` was added to correctly
expect a failing compile, ensuring the test behaves as intended.
---
clang/test/Driver/baremetal-multilib-includepath-error.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/Driver/baremetal-multilib-includepath-error.yaml b/clang/test/Driver/baremetal-multilib-includepath-error.yaml
index 5a1152bcd6aba..bf30dabf9039a 100644
--- a/clang/test/Driver/baremetal-multilib-includepath-error.yaml
+++ b/clang/test/Driver/baremetal-multilib-includepath-error.yaml
@@ -12,7 +12,7 @@
# (/include) to IncludePath triggers the expected
# error.
-# # RUN: %clang --target=aarch64-none-elf --multi-lib-config=%s %s -### -o /dev/null 2>&1 \
+# RUN: not %clang --target=aarch64-none-elf --multi-lib-config=%s %s -o /dev/null 2>&1 \
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
# CHECK-ERROR: error: paths must be relative but "/include" starts with "/"
>From 40398fd8d382855907ce8a974516f851d495f7d3 Mon Sep 17 00:00:00 2001
From: Simi Pallipurath <simi.pallipurath at arm.com>
Date: Mon, 28 Jul 2025 13:46:43 +0100
Subject: [PATCH 5/7] fixup! Using IncludeDirs instead of IncludePath.
---
clang/include/clang/Driver/Multilib.h | 10 +++++-----
clang/lib/Driver/Multilib.cpp | 14 +++++++-------
clang/lib/Driver/ToolChains/BareMetal.cpp | 12 ++++++------
.../baremetal-multilib-includepath-error.yaml | 8 ++++----
.../Driver/baremetal-multilib-includepath.yaml | 6 +++---
5 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/clang/include/clang/Driver/Multilib.h b/clang/include/clang/Driver/Multilib.h
index 1f1372508c480..b4580c6c43a18 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -35,14 +35,14 @@ class Driver;
class Multilib {
public:
using flags_list = std::vector<std::string>;
- using includepath_list = std::vector<std::string>;
+ using includedirs_list = std::vector<std::string>;
private:
std::string GCCSuffix;
std::string OSSuffix;
std::string IncludeSuffix;
flags_list Flags;
- includepath_list IncludePath;
+ includedirs_list IncludeDirs;
// Optionally, a multilib can be assigned a string tag indicating that it's
// part of a group of mutually exclusive possibilities. If two or more
@@ -64,7 +64,7 @@ class Multilib {
/// This is enforced with an assert in the constructor.
Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
StringRef IncludeSuffix = {}, const flags_list &Flags = flags_list(),
- const includepath_list &IncludePath = includepath_list(),
+ const includedirs_list &IncludeDirs = includedirs_list(),
StringRef ExclusiveGroup = {},
std::optional<StringRef> Error = std::nullopt);
@@ -84,9 +84,9 @@ class Multilib {
/// All elements begin with either '-' or '!'
const flags_list &flags() const { return Flags; }
- /// Get the include paths specified in multilib.yaml under the 'IncludePath'
+ /// Get the include directories specified in multilib.yaml under the 'IncludeDirs'
/// field
- const includepath_list &includePath() const { return IncludePath; }
+ const includedirs_list &includeDirs() const { return IncludeDirs; }
/// Get the exclusive group label.
const std::string &exclusiveGroup() const { return ExclusiveGroup; }
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index 2cbb47dd7acdb..05ab26fb402bf 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -29,10 +29,10 @@ using namespace llvm::sys;
Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
StringRef IncludeSuffix, const flags_list &Flags,
- const includepath_list &IncludePath,
+ const includedirs_list &IncludeDirs,
StringRef ExclusiveGroup, std::optional<StringRef> Error)
: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix),
- Flags(Flags), IncludePath(IncludePath), ExclusiveGroup(ExclusiveGroup),
+ Flags(Flags), IncludeDirs(IncludeDirs), ExclusiveGroup(ExclusiveGroup),
Error(Error) {
assert(GCCSuffix.empty() ||
(StringRef(GCCSuffix).front() == '/' && GCCSuffix.size() > 1));
@@ -301,7 +301,7 @@ struct MultilibSerialization {
std::string Dir; // if this record successfully selects a library dir
std::string Error; // if this record reports a fatal error message
std::vector<std::string> Flags;
- std::vector<std::string> IncludePath;
+ std::vector<std::string> IncludeDirs;
std::string Group;
};
@@ -353,7 +353,7 @@ template <> struct llvm::yaml::MappingTraits<MultilibSerialization> {
io.mapOptional("Dir", V.Dir);
io.mapOptional("Error", V.Error);
io.mapRequired("Flags", V.Flags);
- io.mapOptional("IncludePath", V.IncludePath);
+ io.mapOptional("IncludeDirs", V.IncludeDirs);
io.mapOptional("Group", V.Group);
}
static std::string validate(IO &io, MultilibSerialization &V) {
@@ -363,7 +363,7 @@ template <> struct llvm::yaml::MappingTraits<MultilibSerialization> {
return "the 'Dir' and 'Error' keys may not both be specified";
if (StringRef(V.Dir).starts_with("/"))
return "paths must be relative but \"" + V.Dir + "\" starts with \"/\"";
- for (const auto &Path : V.IncludePath) {
+ for (const auto &Path : V.IncludeDirs) {
if (StringRef(Path).starts_with("/"))
return "paths must be relative but \"" + Path + "\" starts with \"/\"";
}
@@ -497,7 +497,7 @@ MultilibSet::parseYaml(llvm::MemoryBufferRef Input,
Multilibs.reserve(MS.Multilibs.size());
for (const auto &M : MS.Multilibs) {
if (!M.Error.empty()) {
- Multilibs.emplace_back("", "", "", M.Flags, M.IncludePath, M.Group,
+ Multilibs.emplace_back("", "", "", M.Flags, M.IncludeDirs, M.Group,
M.Error);
} else {
std::string Dir;
@@ -507,7 +507,7 @@ MultilibSet::parseYaml(llvm::MemoryBufferRef Input,
// Multilib constructor. If we later support more than one type of group,
// we'll have to look up the group name in MS.Groups, check its type, and
// decide what to do here.
- Multilibs.emplace_back(Dir, Dir, Dir, M.Flags, M.IncludePath, M.Group);
+ Multilibs.emplace_back(Dir, Dir, Dir, M.Flags, M.IncludeDirs, M.Group);
}
}
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 00ae5a7705149..56eb3137ba3df 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -417,10 +417,10 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
const SmallString<128> SysRootDir(computeSysRoot());
if (!SysRootDir.empty()) {
for (const Multilib &M : getOrderedMultilibs()) {
- if (!M.includePath().empty()) {
- // Add include paths specified in multilib.yaml under the 'IncludePath'
+ if (!M.includeDirs().empty()) {
+ // Add include directories specified in multilib.yaml under the 'IncludeDirs'
// field
- for (const std::string &Path : M.includePath()) {
+ for (const std::string &Path : M.includeDirs()) {
SmallString<128> Dir(SysRoot);
llvm::sys::path::append(Dir, Path);
addSystemInclude(DriverArgs, CC1Args, Dir.str());
@@ -511,10 +511,10 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
addSystemInclude(DriverArgs, CC1Args, TargetDir.str());
break;
}
- if (!M.includePath().empty()) {
- // Add include paths specified in multilib.yaml under the 'IncludePath'
+ if (!M.includeDirs().empty()) {
+ // Add include directories specified in multilib.yaml under the 'IncludeDirs'
// field
- for (const std::string &Path : M.includePath()) {
+ for (const std::string &Path : M.includeDirs()) {
Dir = SysRoot;
llvm::sys::path::append(Dir, Path, "c++", "v1");
addSystemInclude(DriverArgs, CC1Args, Dir.str());
diff --git a/clang/test/Driver/baremetal-multilib-includepath-error.yaml b/clang/test/Driver/baremetal-multilib-includepath-error.yaml
index bf30dabf9039a..5a5e59bdc5cde 100644
--- a/clang/test/Driver/baremetal-multilib-includepath-error.yaml
+++ b/clang/test/Driver/baremetal-multilib-includepath-error.yaml
@@ -2,14 +2,14 @@
# REQUIRES: shell
# UNSUPPORTED: system-windows
-# This test demonstrates the new "IncludePath" field.
-# This field allows specifying include paths through
+# This test demonstrates the new "IncludeDirs" field.
+# This field allows specifying include directories through
# multilib.yaml configuration using relative paths.
# Absolute paths should be rejected by the driver
# with an appropriate diagnostic message.
#
# This test verifies that passing an absolute path
-# (/include) to IncludePath triggers the expected
+# (/include) to IncludeDirs triggers the expected
# error.
# RUN: not %clang --target=aarch64-none-elf --multi-lib-config=%s %s -o /dev/null 2>&1 \
@@ -23,6 +23,6 @@ Variants:
Flags:
- --target=aarch64-unknown-none-elf
- -munaligned-access
- IncludePath:
+ IncludeDirs:
- /include
- aarch64-none-elf/include
diff --git a/clang/test/Driver/baremetal-multilib-includepath.yaml b/clang/test/Driver/baremetal-multilib-includepath.yaml
index 36ea873d7cd58..4a53b36cffb4c 100644
--- a/clang/test/Driver/baremetal-multilib-includepath.yaml
+++ b/clang/test/Driver/baremetal-multilib-includepath.yaml
@@ -1,8 +1,8 @@
# REQUIRES: shell
# UNSUPPORTED: system-windows
-# This test demonstrates the new "IncludePath" field.
-# This field allows specifying include paths through
+# This test demonstrates the new "IncludeDirs" field.
+# This field allows specifying include directories through
# multilib.yaml configuration. When this field is present
# it is appended to the sysroot during header path
# resolution ignoring the default bare-metal assumptions.
@@ -24,7 +24,7 @@ Variants:
- Dir: soft
Flags:
- -mfloat-abi=soft
- IncludePath:
+ IncludeDirs:
- include
- include-libunwind
- soft/include
>From dce6fedd9fef882d62be09038b6787ebd67f77f0 Mon Sep 17 00:00:00 2001
From: Simi Pallipurath <simi.pallipurath at arm.com>
Date: Mon, 28 Jul 2025 14:08:18 +0100
Subject: [PATCH 6/7] fixup! Apply clang format.
---
clang/include/clang/Driver/Multilib.h | 4 ++--
clang/lib/Driver/ToolChains/BareMetal.cpp | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/clang/include/clang/Driver/Multilib.h b/clang/include/clang/Driver/Multilib.h
index b4580c6c43a18..7c643b996d9c9 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -84,8 +84,8 @@ class Multilib {
/// All elements begin with either '-' or '!'
const flags_list &flags() const { return Flags; }
- /// Get the include directories specified in multilib.yaml under the 'IncludeDirs'
- /// field
+ /// Get the include directories specified in multilib.yaml under the
+ /// 'IncludeDirs' field
const includedirs_list &includeDirs() const { return IncludeDirs; }
/// Get the exclusive group label.
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 56eb3137ba3df..a50e514b359e6 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -418,8 +418,8 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
if (!SysRootDir.empty()) {
for (const Multilib &M : getOrderedMultilibs()) {
if (!M.includeDirs().empty()) {
- // Add include directories specified in multilib.yaml under the 'IncludeDirs'
- // field
+ // Add include directories specified in multilib.yaml under the
+ // 'IncludeDirs' field
for (const std::string &Path : M.includeDirs()) {
SmallString<128> Dir(SysRoot);
llvm::sys::path::append(Dir, Path);
@@ -512,8 +512,8 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
break;
}
if (!M.includeDirs().empty()) {
- // Add include directories specified in multilib.yaml under the 'IncludeDirs'
- // field
+ // Add include directories specified in multilib.yaml under the
+ // 'IncludeDirs' field
for (const std::string &Path : M.includeDirs()) {
Dir = SysRoot;
llvm::sys::path::append(Dir, Path, "c++", "v1");
>From 5934caf9e7ab0d87c1ab5145e56f4a03d6aec83a Mon Sep 17 00:00:00 2001
From: Simi Pallipurath <simi.pallipurath at arm.com>
Date: Mon, 28 Jul 2025 20:17:19 +0100
Subject: [PATCH 7/7] fixup! Rename the test files
---
...-error.yaml => baremetal-multilib-includedirs-error.yaml} | 5 +++--
...-includepath.yaml => baremetal-multilib-includedirs.yaml} | 1 +
2 files changed, 4 insertions(+), 2 deletions(-)
rename clang/test/Driver/{baremetal-multilib-includepath-error.yaml => baremetal-multilib-includedirs-error.yaml} (99%)
rename clang/test/Driver/{baremetal-multilib-includepath.yaml => baremetal-multilib-includedirs.yaml} (99%)
diff --git a/clang/test/Driver/baremetal-multilib-includepath-error.yaml b/clang/test/Driver/baremetal-multilib-includedirs-error.yaml
similarity index 99%
rename from clang/test/Driver/baremetal-multilib-includepath-error.yaml
rename to clang/test/Driver/baremetal-multilib-includedirs-error.yaml
index 5a5e59bdc5cde..f6360135f8c88 100644
--- a/clang/test/Driver/baremetal-multilib-includepath-error.yaml
+++ b/clang/test/Driver/baremetal-multilib-includedirs-error.yaml
@@ -1,4 +1,3 @@
-
# REQUIRES: shell
# UNSUPPORTED: system-windows
@@ -16,7 +15,7 @@
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
# CHECK-ERROR: error: paths must be relative but "/include" starts with "/"
-
+---
MultilibVersion: 1.0
Variants:
- Dir: aarch64-none-elf/aarch64a_exn_rtti_unaligned
@@ -26,3 +25,5 @@ Variants:
IncludeDirs:
- /include
- aarch64-none-elf/include
+
+...
diff --git a/clang/test/Driver/baremetal-multilib-includepath.yaml b/clang/test/Driver/baremetal-multilib-includedirs.yaml
similarity index 99%
rename from clang/test/Driver/baremetal-multilib-includepath.yaml
rename to clang/test/Driver/baremetal-multilib-includedirs.yaml
index 4a53b36cffb4c..2c5a4bc622c4f 100644
--- a/clang/test/Driver/baremetal-multilib-includepath.yaml
+++ b/clang/test/Driver/baremetal-multilib-includedirs.yaml
@@ -28,4 +28,5 @@ Variants:
- include
- include-libunwind
- soft/include
+
...
More information about the cfe-commits
mailing list