38 lines
1.7 KiB
CMake
38 lines
1.7 KiB
CMake
# Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
set(common_flags "")
|
|
set(c_flags "")
|
|
set(MARCH ${CONFIG_MARCH})
|
|
set(MABI ${CONFIG_MABI})
|
|
set(MEXTRA ${CONFIG_MEXTRA})
|
|
|
|
set(linker_flags "-Wl,--print-memory-usage,-Map=${TARGET_NAME}.map,--gc-sections")
|
|
set(WARNINGS "-Werror -Wall -Wextra -Wshadow -Wpointer-arith -Wbad-function-cast -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wno-comment")
|
|
|
|
if(CONFIG_LTO_OPTIMIZATION)
|
|
set(LTO_OPTIONS "-flto -ffat-lto-objects")
|
|
endif()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -g -ffunction-sections -fdata-sections -fno-common -fgnu89-inline -march=${MARCH} -mabi=${MABI} ${MEXTRA} ${LTO_OPTIONS}")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --specs=nano.specs --specs=nosys.specs")
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -ffunction-sections -fdata-sections -fno-common -fgnu89-inline -march=${MARCH} -mabi=${MABI} ${MEXTRA} ${LTO_OPTIONS} -nostdlib ${WARNINGS}")
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --specs=nano.specs --specs=nosys.specs")
|
|
string(APPEND CMAKE_C_FLAGS " -U__UINT32_TYPE__ -D\"__UINT32_TYPE__=unsigned int\" -U__INT32_TYPE__ -D\"__INT32_TYPE__=int\" ")
|
|
|
|
if(CONFIG_BACKTRACE)
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls")
|
|
endif()
|
|
|
|
if(CONFIG_STACK_PROTECTOR_STRONG)
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong")
|
|
endif()
|
|
|
|
if(CONFIG_M_SAVE_RESTORE)
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msave-restore")
|
|
endif()
|
|
|
|
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -O2 -g -ffunction-sections -fdata-sections -fno-common -fgnu89-inline -march=${MARCH} -mabi=${MABI} ${MEXTRA} ${LTO_OPTIONS} -D__ASM")
|
|
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} --specs=nano.specs --specs=nosys.specs")
|