aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Hall <julian.hall@arm.com>2020-11-23 17:45:16 +0100
committerGyorgy Szing <Gyorgy.Szing@arm.com>2020-11-27 16:47:02 +0100
commit07679f2dedd45801ba3bc155685617d177ecbbba (patch)
tree0cf26740e74590b8a27789497ee7a656049f04ee
parenta7e89b0474fdc61a314c31f95a803c443e6ccd9a (diff)
downloadtrusted-services-07679f2dedd45801ba3bc155685617d177ecbbba.tar.gz
Add Linux PC and Arm environments
Adds build system config and toolchain options to enable building for x86 and Arm AArch64 Linux environments. Change-Id: Id1cf40842fcdc9648a4e06b5ac82e5385f6b2fa4 Signed-off-by: Julian Hall <julian.hall@arm.com>
-rw-r--r--environments/arm-linux/default_toolchain_file.cmake16
-rw-r--r--environments/arm-linux/env.cmake25
-rw-r--r--environments/arm-linux/env_shared_lib.cmake27
-rw-r--r--environments/arm-linux/link_options.cmake50
-rw-r--r--environments/linux-pc/default_toolchain_file.cmake8
-rw-r--r--environments/linux-pc/env.cmake21
-rw-r--r--environments/linux-pc/env_shared_lib.cmake25
-rw-r--r--tools/cmake/compiler/shared_lib_toolchain_file.cmake11
-rw-r--r--tools/cmake/compiler/static_lib_toolchain_file.cmake9
9 files changed, 192 insertions, 0 deletions
diff --git a/environments/arm-linux/default_toolchain_file.cmake b/environments/arm-linux/default_toolchain_file.cmake
new file mode 100644
index 0000000..bc04fdd
--- /dev/null
+++ b/environments/arm-linux/default_toolchain_file.cmake
@@ -0,0 +1,16 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+set(ENV{CROSS_COMPILE} "aarch64-linux-gnu-;aarch64-none-linux-gnu-")
+
+set(CMAKE_CROSSCOMPILING True)
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR arm)
+
+set(CMAKE_C_FLAGS_INIT "-fdiagnostics-show-option -gdwarf-2 -mstrict-align -O0 -DARM64=1")
+set(CMAKE_CXX_FLAGS_INIT "-fdiagnostics-show-option -gdwarf-2 -mstrict-align -O0 -DARM64=1")
+
+include($ENV{TS_ROOT}/tools/cmake/compiler/GCC.cmake REQUIRED)
diff --git a/environments/arm-linux/env.cmake b/environments/arm-linux/env.cmake
new file mode 100644
index 0000000..fccb28d
--- /dev/null
+++ b/environments/arm-linux/env.cmake
@@ -0,0 +1,25 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Environment file for deployments to arm-linux. This is a cross-compiled
+# enviroment where built executables or libraries run in Linux userspace
+# on Arm devices.
+#-------------------------------------------------------------------------------
+set(TS_ENV "arm-linux" CACHE STRING "Environment identifier")
+
+include(${CMAKE_CURRENT_LIST_DIR}/link_options.cmake)
+
+# Default to using the base toolcahin file for the enviroment
+set(TS_BASE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/default_toolchain_file.cmake" CACHE STRING "Base toolchainfile")
+
+# Replicate in environment variable for access from child cmake contexts
+set(ENV{TS_BASE_TOOLCHAIN_FILE} "${TS_BASE_TOOLCHAIN_FILE}")
+
+# Set toolchain files to use
+set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/default_toolchain_file.cmake" CACHE STRING "Toolchain file")
+set(TS_EXTERNAL_LIB_TOOLCHAIN_FILE "${TS_ROOT}/tools/cmake/compiler/static_lib_toolchain_file.cmake" CACHE STRING "External lib Toolchain file") \ No newline at end of file
diff --git a/environments/arm-linux/env_shared_lib.cmake b/environments/arm-linux/env_shared_lib.cmake
new file mode 100644
index 0000000..1224eeb
--- /dev/null
+++ b/environments/arm-linux/env_shared_lib.cmake
@@ -0,0 +1,27 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Environment file for shared library deployments to linux-pc.
+#-------------------------------------------------------------------------------
+set(TS_ENV "arm-linux" CACHE STRING "Environment identifier")
+
+if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ message(FATAL_ERROR "Building shared libraries is not yet working on Windows. Sorry!")
+endif()
+
+include(${CMAKE_CURRENT_LIST_DIR}/link_options.cmake)
+
+# Default to using the base toolcahin file for the enviroment
+set(TS_BASE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/default_toolchain_file.cmake" CACHE STRING "Base toolchainfile")
+
+# Replicate in environment variable for access from child cmake contexts
+set(ENV{TS_BASE_TOOLCHAIN_FILE} "${TS_BASE_TOOLCHAIN_FILE}")
+
+# Set toolchain files to use
+set(CMAKE_TOOLCHAIN_FILE "${TS_ROOT}/tools/cmake/compiler/shared_lib_toolchain_file.cmake" CACHE STRING "Toolchain file")
+set(TS_EXTERNAL_LIB_TOOLCHAIN_FILE "${TS_ROOT}/tools/cmake/compiler/static_lib_toolchain_file.cmake" CACHE STRING "External lib Toolchain file")
diff --git a/environments/arm-linux/link_options.cmake b/environments/arm-linux/link_options.cmake
new file mode 100644
index 0000000..717b1ae
--- /dev/null
+++ b/environments/arm-linux/link_options.cmake
@@ -0,0 +1,50 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#[===[.rst:
+.. cmake:command:: env_set_link_options
+
+ .. code-block:: cmake
+
+ env_set_link_options(TGT foo)
+
+ Set default compile options for the arm-linux environment.
+
+ Inputs:
+
+ ``TGT``
+ Name of target to compile generated source files.
+
+#]===]
+function(env_set_link_options)
+ set(_options )
+ set(_oneValueArgs TGT)
+ set(_multiValueArgs )
+
+ cmake_parse_arguments(PARAMS "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
+
+ #Verify mandatory parameters
+ if (NOT DEFINED PARAMS_TGT)
+ message(FATAL_ERROR "env_set_link_options(): mandatory parameter TGT missing.")
+ endif()
+
+ if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ # Options for GCC that control linking
+ target_link_options(${PARAMS_TGT} PRIVATE
+ -fno-lto
+ -pie
+ -zmax-page-size=4096
+ )
+ # Options directly for LD, these are not understood by GCC
+ target_link_options(${PARAMS_TGT} PRIVATE
+ -Wl,--as-needed
+ -Wl,--sort-section=alignment
+ # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list
+ )
+ endif()
+
+endfunction()
diff --git a/environments/linux-pc/default_toolchain_file.cmake b/environments/linux-pc/default_toolchain_file.cmake
new file mode 100644
index 0000000..93e716f
--- /dev/null
+++ b/environments/linux-pc/default_toolchain_file.cmake
@@ -0,0 +1,8 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+# Empty.
diff --git a/environments/linux-pc/env.cmake b/environments/linux-pc/env.cmake
new file mode 100644
index 0000000..f16b49b
--- /dev/null
+++ b/environments/linux-pc/env.cmake
@@ -0,0 +1,21 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Environment file for binary executable deployments to linux-pc.
+#-------------------------------------------------------------------------------
+set(TS_ENV "linux-pc" CACHE STRING "Environment identifier")
+
+# Default to using the base toolcahin file for the enviroment
+set(TS_BASE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/default_toolchain_file.cmake" CACHE STRING "Base toolchain file")
+
+# Replicate in environment variable for access from child cmake contexts
+set(ENV{TS_BASE_TOOLCHAIN_FILE} "${TS_BASE_TOOLCHAIN_FILE}")
+
+# Set toolchain files to use
+set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/default_toolchain_file.cmake" CACHE STRING "Toolchain file")
+set(TS_EXTERNAL_LIB_TOOLCHAIN_FILE "${TS_ROOT}/tools/cmake/compiler/static_lib_toolchain_file.cmake" CACHE STRING "External lib Toolchain file")
diff --git a/environments/linux-pc/env_shared_lib.cmake b/environments/linux-pc/env_shared_lib.cmake
new file mode 100644
index 0000000..8872c28
--- /dev/null
+++ b/environments/linux-pc/env_shared_lib.cmake
@@ -0,0 +1,25 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Environment file for shared library deployments to linux-pc.
+#-------------------------------------------------------------------------------
+set(TS_ENV "linux-pc" CACHE STRING "Environment identifier")
+
+if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ message(FATAL_ERROR "Building shared libraries is not yet working on Windows. Sorry!")
+endif()
+
+# Default to using the base toolcahin file for the enviroment
+set(TS_BASE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/default_toolchain_file.cmake" CACHE STRING "Base toolchainfile")
+
+# Replicate in environment variable for access from child cmake contexts
+set(ENV{TS_BASE_TOOLCHAIN_FILE} "${TS_BASE_TOOLCHAIN_FILE}")
+
+# Set toolchain files to use
+set(CMAKE_TOOLCHAIN_FILE "${TS_ROOT}/tools/cmake/compiler/shared_lib_toolchain_file.cmake" CACHE STRING "Toolchain file")
+set(TS_EXTERNAL_LIB_TOOLCHAIN_FILE "${TS_ROOT}/tools/cmake/compiler/static_lib_toolchain_file.cmake" CACHE STRING "External lib Toolchain file")
diff --git a/tools/cmake/compiler/shared_lib_toolchain_file.cmake b/tools/cmake/compiler/shared_lib_toolchain_file.cmake
new file mode 100644
index 0000000..2151ffc
--- /dev/null
+++ b/tools/cmake/compiler/shared_lib_toolchain_file.cmake
@@ -0,0 +1,11 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+include($ENV{TS_BASE_TOOLCHAIN_FILE} REQUIRED)
+
+set(CMAKE_POSITION_INDEPENDENT_CODE True)
+set(CMAKE_C_VISIBILITY_PRESET hidden)
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
diff --git a/tools/cmake/compiler/static_lib_toolchain_file.cmake b/tools/cmake/compiler/static_lib_toolchain_file.cmake
new file mode 100644
index 0000000..c5326f1
--- /dev/null
+++ b/tools/cmake/compiler/static_lib_toolchain_file.cmake
@@ -0,0 +1,9 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+include($ENV{TS_BASE_TOOLCHAIN_FILE} REQUIRED)
+
+set(CMAKE_POSITION_INDEPENDENT_CODE True)