[clang] [clang]: baremetal `multilib.yaml` discovery (PR #227965)

Mythreya Kuricheti via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 13 02:03:20 PDT 2026


================
@@ -202,10 +202,10 @@ ToolChain::findMultilibsYAML(const llvm::opt::ArgList &Args, const Driver &D,
   }
 
   SmallString<128> MultilibPath;
-  if (!FallbackDir.empty())
----------------
MythreyaK wrote:

> are both the triple/multilib.yaml and multilib.yaml loaded, or only the first one found?

Only the first one that's found, no merging. If the root multilib.yaml is preferred over the per-triple one, happy to swap out the ordering

> in the baremetal `multilib.yaml`, right now the main paths in the config are relative to the single `multilib.yaml` itself (which is in a top-level directory), rather than applying somewhere else (though resource dir path management is different and not very well tested). What's the plan here in the per-triple directories?

I hope I understood this right: 

Unless I'm mistaken, it's relative to the directory in which the `multilib.yaml` is found, so per-triple `multilib.yaml` in say `/sysroot/usr/lib/<triple>/multilib.yaml` with `Dir: rv64gc` resolves to `/sysroot/usr/lib/riscv64-unknown-none-elf/rv64gc/` for library search. 

For the resource-dir search, yeah I ran into that issue. I was thinking of addressing that in a separate PR because I haven't yet mapped out {sysroot, multilib}-relative paths and their ordering yet.

```
# /sysroot/usr/bin/clang    \
    --sysroot=/sysroot      \
    -march=rv64gc           \
    --target=riscv64-unknown-none-elf \
    -print-search-dirs
programs: =
    /sysroot/usr/bin
    /sysroot/usr/bin
libraries: =
    /sysroot/usr/lib/clang/24
    /sysroot/usr/bin/../lib/riscv64-unknown-none-elf/rv64gc
    /sysroot/usr/bin/../lib/riscv64-unknown-none-elf
    /sysroot/usr/lib/clang/24/lib/riscv64-unknown-none-elf <--- needs yaml dir?
    /sysroot/rv64gc/lib
```

If there are per-multilib headers: the include path resolution for [Baremetal.cpp toolchain computes multilib-variant includes relative to the sysroot](https://github.com/MythreyaK/llvm-project/blob/766dfab7e90ce011f96c3cd179ef95c21bc17100/clang/lib/Driver/ToolChains/BareMetal.cpp#L343-L356) (instead of relative to the yaml file), so `/sysroot/rv64gc/include` is searched after (`/sysroot/usr/include/riscv64-unknown-none-elf` [here](https://github.com/MythreyaK/llvm-project/blob/766dfab7e90ce011f96c3cd179ef95c21bc17100/clang/lib/Driver/ToolChains/BareMetal.cpp#L340-L341)). Is this be orthogonal to this (and maybe the resource dir) fix? 

https://github.com/llvm/llvm-project/pull/227965


More information about the cfe-commits mailing list