[PATCH] D105414: Add x86 and x86_64 to the BareMetal toolchain
Alejandro G. Vallejo via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 4 17:15:59 PDT 2021
agvallejo created this revision.
Herald added subscribers: pengfei, s.egerton, abidh, simoncook.
agvallejo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
x86_64-unknown-elf should provide an freestanding environment usable
in kernel development. Currently it defaults to Generic_ELF, which
inherits from Generic_GCC, which is tied to the host platform. The
Baremetal toolchain seems like a better choice to add support for
x86 kernel cross-compilation without adding a lot of overrides on
the command line
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105414
Files:
clang/lib/Driver/ToolChains/BareMetal.cpp
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===================================================================
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -139,6 +139,20 @@
return Triple.getEnvironmentName() == "elf";
}
+static bool isX86BareMetal(const llvm::Triple &Triple) {
+ if (Triple.getArch() != llvm::Triple::x86 &&
+ Triple.getArch() != llvm::Triple::x86_64)
+ return false;
+
+ if (Triple.getVendor() != llvm::Triple::UnknownVendor)
+ return false;
+
+ if (Triple.getOS() != llvm::Triple::UnknownOS)
+ return false;
+
+ return Triple.getEnvironmentName() == "elf";
+}
+
void BareMetal::findMultilibs(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args) {
DetectedMultilibs Result;
@@ -151,7 +165,9 @@
}
bool BareMetal::handlesTarget(const llvm::Triple &Triple) {
- return isARMBareMetal(Triple) || isRISCVBareMetal(Triple);
+ return isARMBareMetal(Triple) ||
+ isRISCVBareMetal(Triple) ||
+ isX86BareMetal(Triple);
}
Tool *BareMetal::buildLinker() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105414.356408.patch
Type: text/x-patch
Size: 1124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210705/0347991a/attachment.bin>
More information about the cfe-commits
mailing list