Felix Singer has submitted this change. ( https://review.coreboot.org/c/coreboot/+/84032?usp=email )
Change subject: util/crossgcc: Patch clang to enable linking x86 bare metal targets ......................................................................
util/crossgcc: Patch clang to enable linking x86 bare metal targets
This allows clang to link x86 bare metal targets.
TESTED: Qemu i440fx and q35 boot to payload with both 32 and 64bit code compiled with clang and LTO enabled with updated linker script.
Change-Id: I943215c8714e392e52ea35667f2bf21e517c4255 Signed-off-by: Arthur Heymans arthur@aheymans.xyz Reviewed-on: https://review.coreboot.org/c/coreboot/+/84032 Reviewed-by: Nico Huber nico.h@gmx.de Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Felix Singer service+coreboot-gerrit@felixsinger.de --- A util/crossgcc/patches/clang-18.1.8.src_x86_baremetal.patch 1 file changed, 29 insertions(+), 0 deletions(-)
Approvals: Felix Singer: Looks good to me, approved build bot (Jenkins): Verified Nico Huber: Looks good to me, approved
diff --git a/util/crossgcc/patches/clang-18.1.8.src_x86_baremetal.patch b/util/crossgcc/patches/clang-18.1.8.src_x86_baremetal.patch new file mode 100644 index 0000000..61c608c --- /dev/null +++ b/util/crossgcc/patches/clang-18.1.8.src_x86_baremetal.patch @@ -0,0 +1,29 @@ +diff --git a/lib/Driver/ToolChains/BareMetal.cpp b/lib/Driver/ToolChains/BareMetal.cpp +index 852e0442..eb84a785 100644 +--- a/lib/Driver/ToolChains/BareMetal.cpp ++++ b/lib/Driver/ToolChains/BareMetal.cpp +@@ -169,6 +169,12 @@ static bool isPPCBareMetal(const llvm::Triple &Triple) { + Triple.getEnvironment() == llvm::Triple::EABI; + } + ++/// Is the triple x86_32 or x86_64 -*-none-elf? ++static bool isX86BareMetal(const llvm::Triple &Triple) { ++ return Triple.isX86() && Triple.getOS() == llvm::Triple::UnknownOS && ++ Triple.getEnvironmentName() == "elf"; ++} ++ + static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D, + StringRef MultilibPath, const ArgList &Args, + DetectedMultilibs &Result) { +@@ -234,9 +240,10 @@ void BareMetal::findMultilibs(const Driver &D, const llvm::Triple &Triple, + + bool BareMetal::handlesTarget(const llvm::Triple &Triple) { + return isARMBareMetal(Triple) || isAArch64BareMetal(Triple) || +- isRISCVBareMetal(Triple) || isPPCBareMetal(Triple); ++ isRISCVBareMetal(Triple) || isPPCBareMetal(Triple) || isX86BareMetal(Triple); + } + ++ + Tool *BareMetal::buildLinker() const { + return new tools::baremetal::Linker(*this); + }