yang.li | 5bef2f6 | 2022-01-11 14:08:06 +0800 | [diff] [blame] | 1 | # Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved. |
| 2 | |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | |
Xiaohu.Huang | be56506 | 2021-10-15 17:29:19 +0800 | [diff] [blame] | 5 | set(common_flags "") |
Xiaohu.Huang | be56506 | 2021-10-15 17:29:19 +0800 | [diff] [blame] | 6 | set(c_flags "") |
| 7 | |
| 8 | set(linker_flags "-Wl,--print-memory-usage,-Map=${TARGET_NAME}.map,--gc-sections") |
| 9 | |
xiaohu.huang | 9044261 | 2022-05-27 17:13:59 +0800 | [diff] [blame] | 10 | if(CONFIG_LTO_OPTIMIZATION) |
| 11 | set(LTO_OPTIONS "-flto -ffat-lto-objects") |
| 12 | endif() |
| 13 | |
Xiaohu.Huang | be56506 | 2021-10-15 17:29:19 +0800 | [diff] [blame] | 14 | if(CONFIG_LIBC_STD) |
Xiaohu.Huang | 89a650b | 2021-12-31 17:31:55 +0800 | [diff] [blame] | 15 | set(linker_flags "${linker_flags},--wrap=_malloc_r,--wrap=_free_r,--wrap=_realloc_r,--wrap=_calloc_r") |
Xiaohu.Huang | be56506 | 2021-10-15 17:29:19 +0800 | [diff] [blame] | 16 | endif() |
| 17 | |
xiaohu.huang | 9044261 | 2022-05-27 17:13:59 +0800 | [diff] [blame] | 18 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -g -ffunction-sections -fdata-sections -fno-common -fgnu89-inline -march=rv32imc -mabi=ilp32 ${LTO_OPTIONS}") |
Xiaohu.Huang | be56506 | 2021-10-15 17:29:19 +0800 | [diff] [blame] | 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --specs=nano.specs --specs=nosys.specs") |
xiaohu.huang | 9044261 | 2022-05-27 17:13:59 +0800 | [diff] [blame] | 20 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -ffunction-sections -fdata-sections -fno-common -fno-builtin -fgnu89-inline -march=rv32imc -mabi=ilp32 ${LTO_OPTIONS} -nostdlib") |
Xiaohu.Huang | be56506 | 2021-10-15 17:29:19 +0800 | [diff] [blame] | 21 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --specs=nano.specs --specs=nosys.specs") |
xiaohu.huang | 9044261 | 2022-05-27 17:13:59 +0800 | [diff] [blame] | 22 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -O2 -g -ffunction-sections -fdata-sections -fno-common -fgnu89-inline -march=rv32imc -mabi=ilp32 ${LTO_OPTIONS} -D__ASM") |
Xiaohu.Huang | be56506 | 2021-10-15 17:29:19 +0800 | [diff] [blame] | 23 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} --specs=nano.specs --specs=nosys.specs") |