diff options
author | Arthur Heymans <arthur@aheymans.xyz> | 2024-08-22 20:00:42 +0200 |
---|---|---|
committer | Felix Singer <service+coreboot-gerrit@felixsinger.de> | 2024-08-28 07:02:39 +0000 |
commit | 0abdb8b8a9498369dde32f55792e6bf9cd8c8dc0 (patch) | |
tree | 0ef286807760ac0a4eec4907b0700bb5440368cb /util/crossgcc | |
parent | 99d35a30fb8defbefe047208e2320116a8147935 (diff) |
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>
Diffstat (limited to 'util/crossgcc')
-rw-r--r-- | util/crossgcc/patches/clang-18.1.8.src_x86_baremetal.patch | 29 |
1 files changed, 29 insertions, 0 deletions
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 0000000000..61c608cbbe --- /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); + } |