blob: 34ca0c936db0ce269a68fbeb49401d93c515de8a [file] [log] [blame]
Gyorgy Szing49091802020-11-24 00:33:09 +01001#-------------------------------------------------------------------------------
Gyorgy Szingd80f8562021-02-11 19:31:43 +01002# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
Gyorgy Szing49091802020-11-24 00:33:09 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#GNUARM v8 and v9 compilers use a different triplet.
Gyorgy Szingd80f8562021-02-11 19:31:43 +01009if(NOT CROSS_COMPILE AND NOT DEFINED ENV{CROSS_COMPILE})
Gyorgy Szingdaf2efd2021-03-09 07:30:34 +010010 set(CROSS_COMPILE "aarch64-elf-;aarch64-none-elf-;aarch64-linux-gnu-;aarch64-none-linux-gnu-" CACHE STRING "List of GCC prefix triplets to use.")
Gyorgy Szing49091802020-11-24 00:33:09 +010011endif()
12
13set(CMAKE_CROSSCOMPILING True)
14set(CMAKE_SYSTEM_NAME Generic)
15set(CMAKE_SYSTEM_PROCESSOR arm)
16set(CMAKE_POSITION_INDEPENDENT_CODE True)
17
18#set(CMAKE_C_FLAGS_INIT --specs=nosys.specs)
19#set(CMAKE_CXX_FLAGS_INIT --specs=nosys.specs)
20#set(CMAKE_EXE_LINKER_FLAGS_INIT --specs=nosys.specs)
21
22include($ENV{TS_ROOT}/tools/cmake/compiler/GCC.cmake REQUIRED)
Julian Hall0051ed12021-07-22 13:59:24 +010023include($ENV{TS_ROOT}/tools/cmake/compiler/config_iface.cmake REQUIRED)
Andrew Beggs97a00d42021-06-15 15:45:46 +000024# Set mandatory compiler and linker flags for this environment:
25# - This environment uses a libc implementation from SPDEV-KIT. Disable standard
26# include search paths, startup files and default libraries.
27string(APPEND CMAKE_C_FLAGS_INIT " -nostartfiles -nodefaultlibs -nostdinc -I ${CMAKE_CURRENT_LIST_DIR}/include")
28# - Compile position independent code
29string(APPEND CMAKE_C_FLAGS_INIT " -fpic")
30# -set entry point
31# -disable link time optimization
32# -link position independent executable
33string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -e __sp_entry -fno-lto -pie")
34
35# -link libgcc with full PATH to work around disabled linker search paths.
36gcc_get_lib_location("libgcc.a" _TMP_VAR)
37string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${_TMP_VAR} ")
38unset(_TMP_VAR)