From 9deb377993c92278809a18da77a9a120ffebc430 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Sun, 26 Jan 2025 21:08:16 +0800 Subject: [PATCH] tools/x86_64: Add LLVM target definitions Summary: - Added LLVM target definitions (`LLVM_ARCH`, `LLVM_CPU`, `LLVM_ABI`) to `arch/x86_64/src/cmake/Toolchain.cmake` and `arch/x86_64/src/common/Toolchain.defs` - These definitions are necessary for compatibility with LLVM-based toolchains and ensure proper target architecture, CPU, and ABI settings Impact: - Enables support for LLVM-based toolchains when building for x86_64 architecture - No functional changes for existing GNU-based toolchains - Improves maintainability by centralizing LLVM-specific configurations in the toolchain files Signed-off-by: Huang Qi --- arch/x86_64/src/cmake/Toolchain.cmake | 5 +++++ arch/x86_64/src/common/Toolchain.defs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/arch/x86_64/src/cmake/Toolchain.cmake b/arch/x86_64/src/cmake/Toolchain.cmake index 9ed22f1c0ddd8..3ee38a3d03679 100644 --- a/arch/x86_64/src/cmake/Toolchain.cmake +++ b/arch/x86_64/src/cmake/Toolchain.cmake @@ -122,6 +122,11 @@ add_compile_options( -Wno-unknown-pragmas $<$:-Wstrict-prototypes>) +# LLVM target definitions +set(LLVM_ARCH "x86_64") +set(LLVM_CPU "x86-64") +set(LLVM_ABI "elf") + if(CONFIG_CXX_STANDARD) add_compile_options($<$:-std=${CONFIG_CXX_STANDARD}>) endif() diff --git a/arch/x86_64/src/common/Toolchain.defs b/arch/x86_64/src/common/Toolchain.defs index 5661577374aba..be3490a122777 100644 --- a/arch/x86_64/src/common/Toolchain.defs +++ b/arch/x86_64/src/common/Toolchain.defs @@ -70,6 +70,11 @@ ARCHCPUFLAGS = -fno-pic -mcmodel=large -mno-red-zone -mrdrnd ARCHPICFLAGS = -fPIC ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +# LLVM target definitions +LLVM_ARCHTYPE := x86_64 +LLVM_CPUTYPE := x86-64 +LLVM_ABITYPE := sysv + # We have to use a cross-development toolchain under Cygwin because the native # Cygwin toolchains don't generate ELF binaries.