Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Gyorgy Szing | d80f856 | 2021-02-11 19:31:43 +0100 | [diff] [blame] | 2 | # Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. |
Gyorgy Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | #GNUARM v8 and v9 compilers use a different triplet. |
Gyorgy Szing | d80f856 | 2021-02-11 19:31:43 +0100 | [diff] [blame] | 9 | if(NOT CROSS_COMPILE AND NOT DEFINED ENV{CROSS_COMPILE}) |
Gyorgy Szing | daf2efd | 2021-03-09 07:30:34 +0100 | [diff] [blame] | 10 | 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 Szing | 4909180 | 2020-11-24 00:33:09 +0100 | [diff] [blame] | 11 | endif() |
| 12 | |
| 13 | set(CMAKE_CROSSCOMPILING True) |
| 14 | set(CMAKE_SYSTEM_NAME Generic) |
| 15 | set(CMAKE_SYSTEM_PROCESSOR arm) |
| 16 | set(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 | |
| 22 | include($ENV{TS_ROOT}/tools/cmake/compiler/GCC.cmake REQUIRED) |
Julian Hall | 0051ed1 | 2021-07-22 13:59:24 +0100 | [diff] [blame^] | 23 | include($ENV{TS_ROOT}/tools/cmake/compiler/config_iface.cmake REQUIRED) |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 24 | # 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. |
| 27 | string(APPEND CMAKE_C_FLAGS_INIT " -nostartfiles -nodefaultlibs -nostdinc -I ${CMAKE_CURRENT_LIST_DIR}/include") |
| 28 | # - Compile position independent code |
| 29 | string(APPEND CMAKE_C_FLAGS_INIT " -fpic") |
| 30 | # -set entry point |
| 31 | # -disable link time optimization |
| 32 | # -link position independent executable |
| 33 | string(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. |
| 36 | gcc_get_lib_location("libgcc.a" _TMP_VAR) |
| 37 | string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${_TMP_VAR} ") |
| 38 | unset(_TMP_VAR) |