[clang] [Driver] Teach Barmetal toolchain about GCC installation (PR #121829)
Peter Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 5 11:08:39 PDT 2025
================
@@ -110,56 +144,99 @@ static std::string computeBaseSysRoot(const Driver &D, bool IncludeTriple) {
return std::string(SysRootDir);
}
-BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
- const ArgList &Args)
- : ToolChain(D, Triple, Args),
- SysRoot(computeBaseSysRoot(D, /*IncludeTriple=*/true)) {
- getProgramPaths().push_back(getDriver().Dir);
-
- findMultilibs(D, Triple, Args);
- SmallString<128> SysRoot(computeSysRoot());
- if (!SysRoot.empty()) {
- for (const Multilib &M : getOrderedMultilibs()) {
- SmallString<128> Dir(SysRoot);
- llvm::sys::path::append(Dir, M.osSuffix(), "lib");
- getFilePaths().push_back(std::string(Dir));
- getLibraryPaths().push_back(std::string(Dir));
- }
- }
+static bool hasGCCToolChainAlongSideClang(const Driver &D) {
+ SmallString<128> GCCDir;
+ llvm::sys::path::append(GCCDir, D.Dir, "..", D.getTargetTriple(),
+ "lib/crt0.o");
+ return llvm::sys::fs::exists(GCCDir);
}
-/// Is the triple {aarch64.aarch64_be}-none-elf?
-static bool isAArch64BareMetal(const llvm::Triple &Triple) {
- if (Triple.getArch() != llvm::Triple::aarch64 &&
- Triple.getArch() != llvm::Triple::aarch64_be)
- return false;
+// Users can specify their GCC toolchain using `-gcc-install-dir` or
+// `--gcc-toolchain`. If no sysroot is explicitly provided, the driver will
----------------
smithp35 wrote:
I've got a mild preference for putting the sysroot part first. For example:
```
If no sysroot is provided the driver will first attempt to infer it from the values of `--gcc-install-dir` or `--gcc-toolchain`, which specify the location of a GCC toolchain.
If neither flag is used ...
```
https://github.com/llvm/llvm-project/pull/121829
More information about the cfe-commits
mailing list