Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sim: Align LLVM target info across CMake and Makefile #15706

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions tools/Rust.defs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ ifeq ($(CONFIG_ARCH_SIM),y)
ifeq ($(CONFIG_HOST_LINUX),y)
ifeq ($(LLVM_ARCHTYPE),x86)
# Only for x86 based host or x64 but m32 build
RUSTFLAGS += --target i686-unknown-linux-$(LLVM_ABITYPE)
RUSTFLAGS += --target i686-unknown-linux-gnu
else
# For other archs, such as aarch64, arm etc
RUSTFLAGS += --target $(LLVM_ARCHTYPE)-unknown-linux-$(LLVM_ABITYPE)
RUSTFLAGS += --target $(LLVM_ARCHTYPE)-unknown-linux-gnu
endif
else ifeq ($(CONFIG_HOST_MACOS),y)
RUSTFLAGS += --target $(LLVM_ARCHTYPE)-apple-$(LLVM_ABITYPE)
RUSTFLAGS += --target $(LLVM_ARCHTYPE)-apple-darwin
endif
else ifeq ($(CONFIG_ARCH_RISCV),y)
# Target triple is riscv[32|64][isa]-unknown-none-elf
Expand Down
Loading