Skip to content

Commit

Permalink
sim: Align LLVM target info across CMake and Makefile
Browse files Browse the repository at this point in the history
Summary:
- Unified the specification of LLVM architecture and ABI types across the CMake and Makefile configurations.
- Introduced `LLVM_ARCHTYPE` and `LLVM_CPUTYPE` variables in the CMake configuration to match the Makefile's approach.
- Standardized the ABI type (`LLVM_ABITYPE`) to `sysv` for both Linux and macOS host configurations.

Impact:
- Ensures consistent LLVM target definitions across build systems (CMake and Makefile).
- Simplifies future maintenance by avoiding divergence in LLVM-related configurations.
- No functional changes to the build output; only the internal representation of LLVM target information is aligned.

Signed-off-by: Huang Qi <[email protected]>
  • Loading branch information
no1wudi committed Jan 27, 2025
1 parent 1452f32 commit a627262
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions arch/sim/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,32 @@ if(WIN32)
return()
endif()

# LLVM style architecture flags
if(CONFIG_HOST_X86_64)
if(CONFIG_SIM_M32)
set(LLVM_ARCHTYPE "x86")
set(LLVM_CPUTYPE "i686")
else()
set(LLVM_ARCHTYPE "x86_64")
set(LLVM_CPUTYPE "skylake")
endif()
elseif(CONFIG_HOST_X86_32)
set(LLVM_ARCHTYPE "x86")
set(LLVM_CPUTYPE "i686")
elseif(CONFIG_HOST_ARM64)
set(LLVM_ARCHTYPE "aarch64")
set(LLVM_CPUTYPE "cortex-a53")
elseif(CONFIG_HOST_ARM)
set(LLVM_ARCHTYPE "arm")
set(LLVM_CPUTYPE "cortex-a9")
endif()

if(CONFIG_HOST_LINUX OR CONFIG_HOST_MACOS)
set(LLVM_ABITYPE "sysv")
elseif(WIN32)
set(LLVM_ABITYPE "msvc")
endif()

# NuttX is sometimes built as a native target. In that case, the __NuttX__ macro
# is predefined by the compiler. https://github.com/NuttX/buildroot
#
Expand Down
4 changes: 2 additions & 2 deletions boards/sim/sim/sim/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ else ifeq ($(CONFIG_HOST_ARM),y)
endif

ifeq ($(CONFIG_HOST_LINUX),y)
LLVM_ABITYPE := gnu
LLVM_ABITYPE := sysv
else ifeq ($(CONFIG_HOST_MACOS),y)
LLVM_ABITYPE := darwin
LLVM_ABITYPE := sysv
endif

ARCHPICFLAGS = -fpic
Expand Down

0 comments on commit a627262

Please sign in to comment.