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

Include fprime-arm-linux toolchain files #2101

Merged
merged 3 commits into from
Jun 26, 2023
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
3 changes: 3 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Aadil
aarch
abcd
ABCDE
ABCDEF
Expand Down Expand Up @@ -391,6 +392,8 @@ dumpobj
DVI
DWN
dylib
eabi
eabihf
EACCES
EAGAIN
eay
Expand Down
18 changes: 18 additions & 0 deletions cmake/toolchain/aarch64-linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
####
# ARM 64-bit Toolchain
#
# This ARM toolchain will compile for 64-bit ARM systems running linux. It uses the arm packages installed on the system
# path for cross-compilation. To override the location of the tools use -DARM_TOOLS_PATH=... to specify the root
# directory of the tools installation. That directory should contain folders bin, lib, etc where the tools are located.
#
# These toolchains will use the linux libraries shipped with the compiler to build the final image. To override this,
# users should set -DCMAKE_SYSROOT=... to a directory containing a valid sysroot for their device.
#
# Cautions:
# 1. Care must be taken to ensure that the Linux OS running on the target is newer than the cross-compilers, or sysroot
# should be used to specify fixed library targets to compile against.
# 2. Specifying sysroot should be used with care as both libraries and headers must exist both in the sysroot
#
####
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
include("${CMAKE_CURRENT_LIST_DIR}/helpers/arm-linux-base.cmake")
20 changes: 20 additions & 0 deletions cmake/toolchain/arm-hf-linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
####
# ARM 32-bit Toolchain with Hardware Floating Point
#
# This ARM toolchain will compile for 32-bit ARM linux systems supporting hardware floating point operations. It uses
# the arm packages installed on the system path for cross-compilation. To override the location of the tools use
# -DARM_TOOLS_PATH=... to specify the root directory of the tools installation. That directory should contain folders
# bin, lib, etc where the tools are located.
#
# These toolchains will use the linux libraries shipped with the compiler to build the final image. To override this,
# users should set -DCMAKE_SYSROOT=... to a directory containing a valid sysroot for their device.
#
# Cautions:
# 1. Care must be taken to ensure that the Linux OS running on the target is newer than the cross-compilers, or sysroot
# should be used to specify fixed library targets to compile against.
# 2. Specifying sysroot should be used with care as both libraries and headers must both exist in the sysroot
#
####
set(CMAKE_SYSTEM_PROCESSOR "arm")
set(ARM_TOOL_SUFFIX eabihf)
include("${CMAKE_CURRENT_LIST_DIR}/helpers/arm-linux-base.cmake")
20 changes: 20 additions & 0 deletions cmake/toolchain/arm-sf-linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
####
# ARM 32-bit Toolchain with Software Floating Point
#
# This ARM toolchain will compile for 32-bit ARM linux systems supporting software floating point operations. It uses
# the arm packages installed on the system path for cross-compilation. To override the location of the tools use
# -DARM_TOOLS_PATH=... to specify the root directory of the tools installation. That directory should contain folders
# bin, lib, etc where the tools are located.
#
# These toolchains will use the linux libraries shipped with the compiler to build the final image. To override this,
# users should set -DCMAKE_SYSROOT=... to a directory containing a valid sysroot for their device.
#
# Cautions:
# 1. Care must be taken to ensure that the Linux OS running on the target is newer than the cross-compilers, or sysroot
# should be used to specify fixed library targets to compile against.
# 2. Specifying sysroot should be used with care as both libraries and headers must both exist in the sysroot
#
####
set(CMAKE_SYSTEM_PROCESSOR "arm")
set(ARM_TOOL_SUFFIX eabi)
include("${CMAKE_CURRENT_LIST_DIR}/helpers/arm-linux-base.cmake")
42 changes: 42 additions & 0 deletions cmake/toolchain/helpers/arm-linux-base.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
####
# ARM Linux Toolchain Base:
#
# This file provides the basic work for ARM toolchains running on Linux systems. It uses the ARM_TOOL_PREFIX variable to
# determine the names of the tools to search for. This variable must be set in the calling script. This toolchain will
# find the ARM tools under the path specified with -DARM_TOOLS_PATH=... and if -DCMAKE_SYSROOT=... is specified then
# this path will be used for searching for libraries/headers to compile against.
####
# Set the system information
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 0.2)

# Check ARM tools path
set(FIND_INPUTS PATHS ENV ARM_TOOLS_PATH PATH_SUFFIXES bin REQUIRED)
set(PREFIX_1 "${CMAKE_SYSTEM_PROCESSOR}-linux-gnu${ARM_TOOL_SUFFIX}")
set(PREFIX_2 "${CMAKE_SYSTEM_PROCESSOR}-none-linux-gnu${ARM_TOOL_SUFFIX}")
# Set the GNU ARM toolchain
find_program(CMAKE_ASM_COMPILER NAMES ${PREFIX_1}-as ${PREFIX_2}-as ${FIND_INPUTS})
find_program(CMAKE_C_COMPILER NAMES ${PREFIX_1}-gcc ${PREFIX_2}-gcc ${FIND_INPUTS})
find_program(CMAKE_CXX_COMPILER NAMES ${PREFIX_1}-g++ ${PREFIX_2}-g++ ${FIND_INPUTS})
find_program(CMAKE_AR NAMES ${PREFIX_1}-ar ${PREFIX_2}-ar ${FIND_INPUTS})
find_program(CMAKE_OBJCOPY NAMES ${PREFIX_1}-objcopy ${PREFIX_2}-objcopy ${FIND_INPUTS})
find_program(CMAKE_OBJDUMP NAMES ${PREFIX_1}-objdump ${PREFIX_2}-objdump ${FIND_INPUTS})

# List programs as found
if (CMAKE_DEBUG_OUTPUT)
message(STATUS "[arm-linux] Assembler: ${CMAKE_ASM_COMPILER}")
message(STATUS "[arm-linux] C Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "[arm-linux] CXX Compiler: ${CMAKE_CXX_COMPILER}")
endif()

# Force sysroot onto
if (DEFINED CMAKE_SYSROOT)
message(STATUS "sysroot set to: ${CMAKE_SYSROOT}")
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} "${CMAKE_SYSROOT}")
endif()

# Configure the find commands for finding the toolchain
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
29 changes: 6 additions & 23 deletions cmake/toolchain/raspberrypi.cmake
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
####
# Raspberry PI Toolchain
#
# This is a toolchain for the Raspberry Pi. This toolchain can be used ot build
# This is a toolchain for the Raspberry Pi. This toolchain can be used to build
# against the Raspberry Pi embedded Linux target. In order to use this toolchain,
# the Raspberry Pi cross-compiler should be installed on a Linux host. These
# tools are installable as follows:
# sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf gdb-multiarch
####

jwest115 marked this conversation as resolved.
Show resolved Hide resolved
# Set the system information
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSTEM_VERSION 1)
# Configure the find commands for cross-compiling: tools from host, libraries, includes, and packages from cross-compiler/sysroot
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_SYSTEM_PROCESSOR "arm")
set(ARM_TOOL_SUFFIX eabihf)

# Check CMake sysroot
if (DEFINED CMAKE_SYSROOT)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT} )
if(DEFINED ENV{RPI_TOOLCHAIN_DIR})
set(ENV{ARM_TOOLS_PATH} "$ENV{RPI_TOOLCHAIN_DIR}")
endif()

# Set the GNU ARM toolchain
find_program(CMAKE_AR NAMES arm-linux-gnueabihf-ar PATHS ENV RPI_TOOLCHAIN_DIR PATH_SUFFIXES bin REQUIRED)
find_program(CMAKE_C_COMPILER NAMES arm-linux-gnueabihf-gcc PATHS ENV RPI_TOOLCHAIN_DIR PATH_SUFFIXES bin REQUIRED)
find_program(CMAKE_CXX_COMPILER NAMES arm-linux-gnueabihf-g++ PATHS ENV RPI_TOOLCHAIN_DIR PATH_SUFFIXES bin REQUIRED)
message(STATUS "[arm-linux] C Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "[arm-linux] CXX Compiler: ${CMAKE_CXX_COMPILER}")
find_program(CMAKE_ASM_COMPILER NAMES arm-linux-gnueabihf-as PATHS ENV RPI_TOOLCHAIN_DIR PATH_SUFFIXES bin REQUIRED)
find_program(CMAKE_OBJCOPY NAMES arm-linux-gnueabihf-objcopy PATHS ENV RPI_TOOLCHAIN_DIR PATH_SUFFIXES bin REQUIRED)
find_program(CMAKE_OBJDUMP NAMES arm-linux-gnueabihf-objdump PATHS ENV RPI_TOOLCHAIN_DIR PATH_SUFFIXES bin REQUIRED)

include("${CMAKE_CURRENT_LIST_DIR}/helpers/arm-linux-base.cmake")